From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Elros Date: Wed, 26 Apr 2023 23:10:15 +0300 Subject: [PATCH] linkerconfig switch for no updatable apex Change-Id: Ia4dfcb8723a1f513ea195fa175242fbb26873022 diff --git a/init/init.cpp b/init/init.cpp index 9377f0743..e66ef9e3e 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -795,6 +795,10 @@ int SecondStageMain(int argc, char** argv) { if (!SetupMountNamespaces()) { PLOG(FATAL) << "SetupMountNamespaces failed"; } +#else + if (!SetupFlattenedApexes()) { + LOG(INFO) << "SetupFlattenedApexes failed"; + } #endif InitializeSubcontext(); diff --git a/init/mount_namespace.cpp b/init/mount_namespace.cpp index 3875adac3..fabf319e3 100644 --- a/init/mount_namespace.cpp +++ b/init/mount_namespace.cpp @@ -300,11 +300,16 @@ bool SetupMountNamespaces() { return success; } +bool SetupFlattenedApexes() { + return ActivateFlattenedApexesIfPossible(); +} + bool SwitchToDefaultMountNamespace() { if (IsRecoveryMode()) { // we don't have multiple namespaces in recovery mode return true; } +#ifdef DISABLED_FOR_HYBRIS_SUPPORT if (default_ns_id != GetMountNamespaceId()) { if (setns(default_ns_fd.get(), CLONE_NEWNS) == -1) { PLOG(ERROR) << "Failed to switch back to the default mount namespace."; @@ -318,6 +323,12 @@ bool SwitchToDefaultMountNamespace() { } LOG(INFO) << "Switched to default mount namespace"; +#else + if (auto result = MountLinkerConfigForDefaultNamespace(); !result.ok()) { + LOG(ERROR) << result.error(); + return false; + } +#endif return true; } diff --git a/init/mount_namespace.h b/init/mount_namespace.h index c41a449f3..d72736e4d 100644 --- a/init/mount_namespace.h +++ b/init/mount_namespace.h @@ -22,6 +22,7 @@ namespace init { bool SetupMountNamespaces(); bool SwitchToDefaultMountNamespace(); bool SwitchToBootstrapMountNamespaceIfNeeded(); +bool SetupFlattenedApexes(); } // namespace init } // namespace android