summaryrefslogtreecommitdiff
path: root/init/import_parser.cpp
AgeCommit message (Collapse)Author
2020-02-06Convert system/core to Result::ok()Bernie Innocenti
No functionality changes, this is a mechanical cleanup. Test: m Test: cd system/core && atest Change-Id: Ifdaa3ce1947ed578f656d5a446978726eb416c36
2019-08-01init: don't log in expand_props directlyTom Cherry
It's better to pass the error message to the caller to determine how best to print the error. Test: build Change-Id: Id8857c459df2f26c031650166609608d20e4d051
2019-06-10init: replace Result<Success> with Result<void>Tom Cherry
Now that Result<T> is actually expected<T, ...>, and the expected proposal states expected<void, ...> as the way to indicate an expected object that returns either successfully with no object or an error, let's move init's Result<Success> to the preferred Result<void>. Bug: 132145659 Test: boot, init unit tests Change-Id: Ib2f98396d8e6e274f95a496fcdfd8341f77585ee
2018-05-30init: handle properties and imports for host init verifierTom Cherry
Allow specifying properties on the command line when running host init verifier. This is needed particularly for importing files that have a property expansion in their path. Handle the import statement on host, basing paths off of the out directory of Android builds. Bug: 36970783 Test: verify that bullhead imports the correct files and checks them Change-Id: I4fe263016b3764a372708b559bc0c739b1b7e5e3
2017-08-14init: use Result<T> for the parsing functionsTom Cherry
Test: boot bullhead Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
2017-06-23init: create android::init:: namespaceTom Cherry
With some small fixups along the way Test: Boot bullhead Test: init unit tests Change-Id: I7beaa473cfa9397f845f810557d1631b4a462d6a
2017-04-21init: clean up the SectionParser interface and Parser classTom Cherry
Remove the dependency on Action and Service from what should be a generic Parser class. Make ActionParser, ImportParser, and ServiceParser take a pointer to their associated classes instead of accessing them through a singleton. Misc fixes to SectionParser Interface: 1) Make SectionParser::ParseLineSection() non-const as it always should have been. 2) Use Rvalue references where appropriate 3) Remove extra std::string& filename in SectionParser::EndFile() 4) Only have SectionParser::ParseSection() as pure virtual Document SectionParser. Make ImportParser report the filename and line number of failed imports. Make ServiceParser report the filename and line number of duplicated services. Test: Boot bullhead Change-Id: I86568a5b375fb4f27f4cb235ed1e37635f01d630
2017-04-19init: Stop combining actionsTom Cherry
In the past, I had thought it didn't make sense to have multiple Action classes with identical triggers within ActionManager::actions_, and opted to instead combine these into a single action. In theory, it should reduce memory overhead as only one copy of the triggers needs to be stored. In practice, this ends up not being a good idea. Most importantly, given a file with the below three sections in this same order: on boot setprop a b on boot && property:true=true setprop c d on boot setprop e f Assuming that property 'true' == 'true', when the `boot` event happens, the order of the setprop commands will actually be: setprop a b setprop e f setprop c d instead of the more intuitive order of: setprop a b setprop c d setprop e f This is a mistake and this CL fixes it. It also documents this order. Secondly, with a given 'Action' now spanning multiple files, in order to keep track of which file a command is run from, the 'Command' itself needs to store this. Ironically to the original intention, this increases total ram usage. This change now only stores the file name in each 'Action' instead of each 'Command'. All in all this is a negligible trade off of ram usage. Thirdly, this requires a bunch of extra code and assumptions that don't help anything else. In particular it forces to keep property triggers sorted for easy comparison, which I'm using an std::map for currently, but that is not the best data structure to contain them. Lastly, I added the filename and line number to the 'processing action' LOG(INFO) message. Test: Boot bullhead, observe above changes Test: Boot sailfish, observe no change in boot time Change-Id: I3fbcac4ee677351314e33012c758145be82346e9
2017-04-06init: more header cleanupTom Cherry
Remove includes of "log.h" that really want <android-base/logging.h> Fix header include order Remove headers included in .cpp files that their associated .h already includes Remove some unused headers Test: boot bullhead Change-Id: I2b415adfe86a5c8bbe4fb1ebc53c7b0ee2253824
2016-06-27Move init to libbase logging.Elliott Hughes
Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
2015-09-01init: Use classes for parsing and clean up memory allocationsTom Cherry
Create a Parser class that uses multiple SectionParser interfaces to handle parsing the different sections of an init rc. Create an ActionParser and ServiceParser that implement SectionParser and parse the sections corresponding to Action and Service classes. Remove the legacy keyword structure and replace it with std::map's that map keyword -> (minimum args, maximum args, function pointer) for Commands and Service Options. Create an ImportParser that implements SectionParser and handles the import 'section'. Clean up the unsafe memory handling of the Action class by using std::unique_ptr. Change-Id: Ic5ea5510cb956dbc3f78745a35096ca7d6da7085