diff options
author | Daniel Norman <danielnorman@google.com> | 2020-08-31 12:05:50 -0700 |
---|---|---|
committer | Brian Orr <brianorr@google.com> | 2020-09-03 11:08:10 -0700 |
commit | 9a1114d8a44e4d93a719095ad81c119273d43ee4 (patch) | |
tree | e50f8133f3f65cafa0d1d2235044e2d65e75bc0a /init/builtins.cpp | |
parent | 600e96934a288c86ff438e6d8cea6f55acddd615 (diff) | |
parent | 0ba167e991c75828b215580220230fdec95f85c2 (diff) |
Merge SP1A.200727.001
Change-Id: I8f6750352c361cdc5b23825395234de12384ddd7
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r-- | init/builtins.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp index d7c8965b5..f85246d5c 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -1243,6 +1243,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; @@ -1341,11 +1355,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 |