summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorJooyung Han <jooyung@google.com>2020-06-09 13:44:17 +0900
committerJooyung Han <jooyung@google.com>2020-06-11 15:10:40 +0900
commit4f23d5a236e08ed2d9413cf2681f8ed967d01deb (patch)
tree7bfcca78b214cafaf6d024269d07d0cc4a49831b /init/builtins.cpp
parent3447cdc741214db36f47dd1138b12215a070efa6 (diff)
init: start ueventd in the default mount namespace
Init starts ueventd in the default mount namespace to support loading firmware from APEXes. Bug: 155023652 Test: devices boots adb$ nsenter -t (pid of ueventd) -m ls /apex => shows all APEXes Change-Id: Ibb8b33a07eb014752275e3bca4541b8b694dc64b
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r--init/builtins.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 0ac66f272..0b456e70a 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -1221,6 +1221,20 @@ static Result<void> GenerateLinkerConfiguration() {
return {};
}
+static Result<void> MountLinkerConfigForDefaultNamespace() {
+ // No need to mount linkerconfig for default mount namespace if the path does not exist (which
+ // would mean it is already mounted)
+ if (access("/linkerconfig/default", 0) != 0) {
+ return {};
+ }
+
+ if (mount("/linkerconfig/default", "/linkerconfig", nullptr, MS_BIND | MS_REC, nullptr) != 0) {
+ return ErrnoError() << "Failed to mount linker configuration for default mount namespace.";
+ }
+
+ return {};
+}
+
static bool IsApexUpdatable() {
static bool updatable = android::sysprop::ApexProperties::updatable().value_or(false);
return updatable;
@@ -1319,11 +1333,14 @@ static Result<void> do_perform_apex_config(const BuiltinArguments& args) {
}
static Result<void> do_enter_default_mount_ns(const BuiltinArguments& args) {
- if (SwitchToDefaultMountNamespace()) {
- return {};
- } else {
- return Error() << "Failed to enter into default mount namespace";
+ if (auto result = SwitchToMountNamespaceIfNeeded(NS_DEFAULT); !result.ok()) {
+ return result.error();
+ }
+ if (auto result = MountLinkerConfigForDefaultNamespace(); !result.ok()) {
+ return result.error();
}
+ LOG(INFO) << "Switched to default mount namespace";
+ return {};
}
// Builtin-function-map start