From 653b063871b10be412f9fb25caa271e1acd13dbd Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Thu, 29 Jul 2021 17:11:23 +0900 Subject: [PATCH] init: no bootstrap mount namespace for microdroid The reason for two mount namespace (bootstrap/default) is that we have two sets of different APEXes to activate. But in microdroid, we don't need two separate mount namespaces because there's only one set of non-updatable APEXes in built-in directories and payloads (passed from host Android). Bug: 185991357 Test: MicrodroidHostTestCases Change-Id: I4469f3b1d90f9543ecb980a450eaaf1c20b94c58 --- init/mount_namespace.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/init/mount_namespace.cpp b/init/mount_namespace.cpp index 2a578082b..575cae94c 100644 --- a/init/mount_namespace.cpp +++ b/init/mount_namespace.cpp @@ -82,6 +82,21 @@ static bool IsApexUpdatable() { return updatable; } +static bool IsMicrodroid() { + static bool is_microdroid = android::base::GetProperty("ro.hardware", "") == "microdroid"; + return is_microdroid; +} + +// In case we have two sets of APEXes (non-updatable, updatable), we need two separate mount +// namespaces. +static bool NeedsTwoMountNamespaces() { + if (!IsApexUpdatable()) return false; + if (IsRecoveryMode()) return false; + // In microdroid, there's only one set of APEXes in built-in directories include block devices. + if (IsMicrodroid()) return false; + return true; +} + #ifdef ACTIVATE_FLATTENED_APEX static Result MountDir(const std::string& path, const std::string& mount_path) { @@ -260,7 +275,7 @@ bool SetupMountNamespaces() { // number of essential APEXes (e.g. com.android.runtime) are activated. // In the namespace for post-apexd processes, all APEXes are activated. bool success = true; - if (IsApexUpdatable() && !IsRecoveryMode()) { + if (NeedsTwoMountNamespaces()) { // Creating a new namespace by cloning, saving, and switching back to // the original namespace. if (unshare(CLONE_NEWNS) == -1) {