diff options
author | Martijn Coenen <maco@google.com> | 2019-05-07 06:41:01 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-05-07 06:41:01 +0000 |
commit | fc78be29352653e13e4c9ecdb75ad0a166b61ee7 (patch) | |
tree | 10bc64fc8e22be30e95fd09f7649f3825ed723ea /init/builtins.cpp | |
parent | eaf203d301fcc61b76d7d58019cd641b24c744c2 (diff) | |
parent | 70788f93ba5e8262790db9a473715362b8372501 (diff) |
Merge "Support for stopping/starting post-data-mount class subsets."
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r-- | init/builtins.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp index 62e0f8fa6..ba1c94d65 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -104,23 +104,37 @@ static void ForEachServiceInClass(const std::string& classname, F function) { } } -static Result<Success> do_class_start(const BuiltinArguments& args) { +static Result<Success> class_start(const std::string& class_name, bool post_data_only) { // Do not start a class if it has a property persist.dont_start_class.CLASS set to 1. - if (android::base::GetBoolProperty("persist.init.dont_start_class." + args[1], false)) + if (android::base::GetBoolProperty("persist.init.dont_start_class." + class_name, false)) return Success(); // Starting a class does not start services which are explicitly disabled. // They must be started individually. for (const auto& service : ServiceList::GetInstance()) { - if (service->classnames().count(args[1])) { + if (service->classnames().count(class_name)) { + if (post_data_only && !service->is_post_data()) { + continue; + } if (auto result = service->StartIfNotDisabled(); !result) { LOG(ERROR) << "Could not start service '" << service->name() - << "' as part of class '" << args[1] << "': " << result.error(); + << "' as part of class '" << class_name << "': " << result.error(); } } } return Success(); } +static Result<Success> do_class_start(const BuiltinArguments& args) { + return class_start(args[1], false /* post_data_only */); +} + +static Result<Success> do_class_start_post_data(const BuiltinArguments& args) { + if (args.context != kInitContext) { + return Error() << "command 'class_start_post_data' only available in init context"; + } + return class_start(args[1], true /* post_data_only */); +} + static Result<Success> do_class_stop(const BuiltinArguments& args) { ForEachServiceInClass(args[1], &Service::Stop); return Success(); @@ -131,6 +145,14 @@ static Result<Success> do_class_reset(const BuiltinArguments& args) { return Success(); } +static Result<Success> do_class_reset_post_data(const BuiltinArguments& args) { + if (args.context != kInitContext) { + return Error() << "command 'class_reset_post_data' only available in init context"; + } + ForEachServiceInClass(args[1], &Service::ResetIfPostData); + return Success(); +} + static Result<Success> do_class_restart(const BuiltinArguments& args) { // Do not restart a class if it has a property persist.dont_start_class.CLASS set to 1. if (android::base::GetBoolProperty("persist.init.dont_start_class." + args[1], false)) @@ -1042,6 +1064,12 @@ static Result<Success> do_init_user0(const BuiltinArguments& args) { {{"exec", "/system/bin/vdc", "--wait", "cryptfs", "init_user0"}, args.context}); } +static Result<Success> do_mark_post_data(const BuiltinArguments& args) { + ServiceList::GetInstance().MarkPostData(); + + return Success(); +} + static Result<Success> do_parse_apex_configs(const BuiltinArguments& args) { glob_t glob_result; // @ is added to filter out the later paths, which are bind mounts of the places @@ -1093,8 +1121,10 @@ const BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const { {"chmod", {2, 2, {true, do_chmod}}}, {"chown", {2, 3, {true, do_chown}}}, {"class_reset", {1, 1, {false, do_class_reset}}}, + {"class_reset_post_data", {1, 1, {false, do_class_reset_post_data}}}, {"class_restart", {1, 1, {false, do_class_restart}}}, {"class_start", {1, 1, {false, do_class_start}}}, + {"class_start_post_data", {1, 1, {false, do_class_start_post_data}}}, {"class_stop", {1, 1, {false, do_class_stop}}}, {"copy", {2, 2, {true, do_copy}}}, {"domainname", {1, 1, {true, do_domainname}}}, @@ -1114,6 +1144,7 @@ const BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const { {"load_persist_props", {0, 0, {false, do_load_persist_props}}}, {"load_system_props", {0, 0, {false, do_load_system_props}}}, {"loglevel", {1, 1, {false, do_loglevel}}}, + {"mark_post_data", {0, 0, {false, do_mark_post_data}}}, {"mkdir", {1, 4, {true, do_mkdir}}}, // TODO: Do mount operations in vendor_init. // mount_all is currently too complex to run in vendor_init as it queues action triggers, |