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
diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp
index 4bbbc20..1c0189b 100644
--- a/init/first_stage_mount.cpp
+++ b/init/first_stage_mount.cpp
@@ -518,6 +518,12 @@
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;
}