summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2016-01-14 11:18:21 +0800
committerHung-ying Tyan <tyanh@google.com>2016-01-21 09:35:43 +0800
commitdc738eaf1547c250979bb9f1ffb64b0836a5e7f3 (patch)
tree2a3c5bae139eac22fefaa4493de6159d243b3037 /init/builtins.cpp
parent13655cdc77a361b8780297b6d7778659cf39d858 (diff)
Allow paths of .rc files to be specified at mount_all
In current implementation, the mount_all command imports all .rc files under /{system,vendor,odm}/etc/init/ after mouting filesystems is complete. There's a need from ODMs to import different .rc files under different boot modes (e.g., factory mode). Without this support, they will have to fiddle around the init implementation. This commit makes mount_all import the .rc files/directories specified as additional arguments. If no path is given, the original ones are applied the same way as the current implementation. BUG: 26549689 Change-Id: Ie67ce13dde4c440ff8bf534826bc392c882a433f
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r--init/builtins.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp
index d2291bb50..35f1a9e04 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -418,20 +418,32 @@ static int wipe_data_via_recovery() {
while (1) { pause(); } // never reached
}
-static void import_late() {
- static const std::vector<std::string> init_directories = {
- "/system/etc/init",
- "/vendor/etc/init",
- "/odm/etc/init"
- };
-
+/* Imports .rc files from the specified paths. Default ones are applied if none is given.
+ *
+ * start_index: index of the first path in the args list
+ */
+static void import_late(const std::vector<std::string>& args, size_t start_index) {
Parser& parser = Parser::GetInstance();
- for (const auto& dir : init_directories) {
- parser.ParseConfig(dir.c_str());
+ if (args.size() <= start_index) {
+ // Use the default set if no path is given
+ static const std::vector<std::string> init_directories = {
+ "/system/etc/init",
+ "/vendor/etc/init",
+ "/odm/etc/init"
+ };
+
+ for (const auto& dir : init_directories) {
+ parser.ParseConfig(dir);
+ }
+ } else {
+ for (size_t i = start_index; i < args.size(); ++i) {
+ parser.ParseConfig(args[i]);
+ }
}
}
-/*
+/* mount_all <fstab> [ <path> ]*
+ *
* This function might request a reboot, in which case it will
* not return.
*/
@@ -478,7 +490,8 @@ static int do_mount_all(const std::vector<std::string>& args) {
return -1;
}
- import_late();
+ /* Paths of .rc files are specified at the 2nd argument and beyond */
+ import_late(args, 2);
if (ret == FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION) {
property_set("vold.decrypt", "trigger_encryption");
@@ -900,7 +913,7 @@ BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
{"load_system_props", {0, 0, do_load_system_props}},
{"loglevel", {1, 1, do_loglevel}},
{"mkdir", {1, 4, do_mkdir}},
- {"mount_all", {1, 1, do_mount_all}},
+ {"mount_all", {1, kMax, do_mount_all}},
{"mount", {3, kMax, do_mount}},
{"powerctl", {1, 1, do_powerctl}},
{"restart", {1, 1, do_restart}},