Loading init/builtins.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -1278,6 +1278,14 @@ static Result<void> GenerateLinkerConfiguration() { return ErrnoError() << "failed to execute linkerconfig"; } auto current_mount_ns = GetCurrentMountNamespace(); if (!current_mount_ns.ok()) { return current_mount_ns.error(); } if (*current_mount_ns == NS_DEFAULT) { SetDefaultMountNamespaceReady(); } LOG(INFO) << "linkerconfig generated " << linkerconfig_target << " with mounted APEX modules info"; Loading init/mount_namespace.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -301,5 +301,20 @@ Result<void> SwitchToMountNamespaceIfNeeded(MountNamespace target_mount_namespac return {}; } base::Result<MountNamespace> GetCurrentMountNamespace() { std::string current_namespace_id = GetMountNamespaceId(); if (current_namespace_id == "") { return Error() << "Failed to get current mount namespace ID"; } if (current_namespace_id == bootstrap_ns_id) { return NS_BOOTSTRAP; } else if (current_namespace_id == default_ns_id) { return NS_DEFAULT; } return Error() << "Failed to find current mount namespace"; } } // namespace init } // namespace android init/mount_namespace.h +2 −0 Original line number Diff line number Diff line Loading @@ -26,5 +26,7 @@ enum MountNamespace { NS_BOOTSTRAP, NS_DEFAULT }; bool SetupMountNamespaces(); base::Result<void> SwitchToMountNamespaceIfNeeded(MountNamespace target_mount_namespace); base::Result<MountNamespace> GetCurrentMountNamespace(); } // namespace init } // namespace android init/service.cpp +6 −11 Original line number Diff line number Diff line Loading @@ -125,11 +125,6 @@ static bool ExpandArgsAndExecv(const std::vector<std::string>& args, bool sigsto return execv(c_strings[0], c_strings.data()) == 0; } static bool AreRuntimeApexesReady() { struct stat buf; return stat("/apex/com.android.runtime/", &buf) == 0; } unsigned long Service::next_start_order_ = 1; bool Service::is_exec_service_running_ = false; Loading Loading @@ -312,7 +307,7 @@ void Service::Reap(const siginfo_t& siginfo) { #else static bool is_apex_updatable = false; #endif const bool is_process_updatable = !pre_apexd_ && is_apex_updatable; const bool is_process_updatable = !use_bootstrap_ns_ && is_apex_updatable; // If we crash > 4 times in 'fatal_crash_window_' minutes or before boot_completed, // reboot into bootloader or set crashing property Loading Loading @@ -465,12 +460,12 @@ Result<void> Service::Start() { scon = *result; } if (!AreRuntimeApexesReady() && !pre_apexd_) { // If this service is started before the Runtime and ART APEXes get // available, mark it as pre-apexd one. Note that this marking is if (!IsDefaultMountNamespaceReady() && name_ != "apexd") { // If this service is started before APEXes and corresponding linker configuration // get available, mark it as pre-apexd one. Note that this marking is // permanent. So for example, if the service is re-launched (e.g., due // to crash), it is still recognized as pre-apexd... for consistency. pre_apexd_ = true; use_bootstrap_ns_ = true; } // For pre-apexd services, override mount namespace as "bootstrap" one before starting. Loading @@ -479,7 +474,7 @@ Result<void> Service::Start() { std::optional<MountNamespace> override_mount_namespace; if (name_ == "ueventd") { override_mount_namespace = NS_DEFAULT; } else if (pre_apexd_) { } else if (use_bootstrap_ns_) { override_mount_namespace = NS_BOOTSTRAP; } Loading init/service.h +1 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,7 @@ class Service { std::vector<std::function<void(const siginfo_t& siginfo)>> reap_callbacks_; bool pre_apexd_ = false; bool use_bootstrap_ns_ = false; bool post_data_ = false; Loading Loading
init/builtins.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -1278,6 +1278,14 @@ static Result<void> GenerateLinkerConfiguration() { return ErrnoError() << "failed to execute linkerconfig"; } auto current_mount_ns = GetCurrentMountNamespace(); if (!current_mount_ns.ok()) { return current_mount_ns.error(); } if (*current_mount_ns == NS_DEFAULT) { SetDefaultMountNamespaceReady(); } LOG(INFO) << "linkerconfig generated " << linkerconfig_target << " with mounted APEX modules info"; Loading
init/mount_namespace.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -301,5 +301,20 @@ Result<void> SwitchToMountNamespaceIfNeeded(MountNamespace target_mount_namespac return {}; } base::Result<MountNamespace> GetCurrentMountNamespace() { std::string current_namespace_id = GetMountNamespaceId(); if (current_namespace_id == "") { return Error() << "Failed to get current mount namespace ID"; } if (current_namespace_id == bootstrap_ns_id) { return NS_BOOTSTRAP; } else if (current_namespace_id == default_ns_id) { return NS_DEFAULT; } return Error() << "Failed to find current mount namespace"; } } // namespace init } // namespace android
init/mount_namespace.h +2 −0 Original line number Diff line number Diff line Loading @@ -26,5 +26,7 @@ enum MountNamespace { NS_BOOTSTRAP, NS_DEFAULT }; bool SetupMountNamespaces(); base::Result<void> SwitchToMountNamespaceIfNeeded(MountNamespace target_mount_namespace); base::Result<MountNamespace> GetCurrentMountNamespace(); } // namespace init } // namespace android
init/service.cpp +6 −11 Original line number Diff line number Diff line Loading @@ -125,11 +125,6 @@ static bool ExpandArgsAndExecv(const std::vector<std::string>& args, bool sigsto return execv(c_strings[0], c_strings.data()) == 0; } static bool AreRuntimeApexesReady() { struct stat buf; return stat("/apex/com.android.runtime/", &buf) == 0; } unsigned long Service::next_start_order_ = 1; bool Service::is_exec_service_running_ = false; Loading Loading @@ -312,7 +307,7 @@ void Service::Reap(const siginfo_t& siginfo) { #else static bool is_apex_updatable = false; #endif const bool is_process_updatable = !pre_apexd_ && is_apex_updatable; const bool is_process_updatable = !use_bootstrap_ns_ && is_apex_updatable; // If we crash > 4 times in 'fatal_crash_window_' minutes or before boot_completed, // reboot into bootloader or set crashing property Loading Loading @@ -465,12 +460,12 @@ Result<void> Service::Start() { scon = *result; } if (!AreRuntimeApexesReady() && !pre_apexd_) { // If this service is started before the Runtime and ART APEXes get // available, mark it as pre-apexd one. Note that this marking is if (!IsDefaultMountNamespaceReady() && name_ != "apexd") { // If this service is started before APEXes and corresponding linker configuration // get available, mark it as pre-apexd one. Note that this marking is // permanent. So for example, if the service is re-launched (e.g., due // to crash), it is still recognized as pre-apexd... for consistency. pre_apexd_ = true; use_bootstrap_ns_ = true; } // For pre-apexd services, override mount namespace as "bootstrap" one before starting. Loading @@ -479,7 +474,7 @@ Result<void> Service::Start() { std::optional<MountNamespace> override_mount_namespace; if (name_ == "ueventd") { override_mount_namespace = NS_DEFAULT; } else if (pre_apexd_) { } else if (use_bootstrap_ns_) { override_mount_namespace = NS_BOOTSTRAP; } Loading
init/service.h +1 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,7 @@ class Service { std::vector<std::function<void(const siginfo_t& siginfo)>> reap_callbacks_; bool pre_apexd_ = false; bool use_bootstrap_ns_ = false; bool post_data_ = false; Loading