diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-06-13 02:09:12 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-06-13 02:09:12 +0000 |
commit | d3011a00ae3c3d232b778e5139a44e22cb89d587 (patch) | |
tree | 1e00514239beb80e012935f9aa48cf5d061bc87a /init/builtins.cpp | |
parent | 32ab56890a47c495101d3d1a689703bbbf70a43a (diff) | |
parent | fa65517cd73ef340e9a2decc59af814ded969daa (diff) |
Snap for 6586161 from fa65517cd73ef340e9a2decc59af814ded969daa to sc-release
Change-Id: I9f9b7239342c2bb743382b58ae3a498b79d931ff
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 0ac66f2727..0b456e70a6 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 |