From d7e6353a69f6cc0b66198eb0a2726abe0f655dcb Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Tue, 5 Jul 2022 17:55:24 +0800 Subject: [PATCH] first_stage_mount: Bind mount /system after switch root This ensures /system to be a mountpoint, which allows adb-remount to change the subtree propagation type of /system and MS_MOVE submounts under /system. Test: Add submount under /system and adb remount Change-Id: Ib281be41eaf86bc3e6b7dfac893e5e27b8374da8 --- init/first_stage_mount.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp index 4bbbc20cb..1c0189bd7 100644 --- a/init/first_stage_mount.cpp +++ b/init/first_stage_mount.cpp @@ -518,6 +518,12 @@ bool FirstStageMount::TrySwitchSystemAsRoot() { return false; } + // Make /system a mountpoint so that adb-remount can move submounts under /system. + if (access("/system", F_OK) == 0 && + mount("/system", "/system", nullptr, MS_BIND, nullptr) != 0) { + PLOG(WARNING) << "Failed to bind mount /system for overlayfs"; + } + return true; }