From 379be50f9c714871bbdebabeb3d1dd9e87c94d51 Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Wed, 20 Jul 2022 15:59:01 +0800 Subject: [PATCH] fs_mgr_overlayfs: Try "/system" and "/" when setting "/system" shared type b/239574953 uncovers an obscure test device configuration that breaks with aosp/2146960. Without aosp/2146960, "/system" is not a mountpoint, because after switch_root, the "/system" mount entry becomes "/", thus changing the subtree propagation type of "/system" would fail. With aosp/2146960, "/system" is bind-mounted to itself after switch_root, ensuring "/system" being a mountpoint, thus changing the subtree propagation type of "/system" is allowed. Before we can re-land aosp/2146960, just try both "/system" and "/" when changing the subtree shared propagation type of "/system", so both scenarios are handled. Test: Add submount under /system and adb remount Change-Id: I4006a5c1b1987d5f6452efa069ec5c7d2ac7c8ec --- fs_mgr/fs_mgr_overlayfs.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp index 6942d0ccd..07eaf58fe 100644 --- a/fs_mgr/fs_mgr_overlayfs.cpp +++ b/fs_mgr/fs_mgr_overlayfs.cpp @@ -642,6 +642,10 @@ bool fs_mgr_overlayfs_set_shared_mount(const std::string& mount_point, bool shar if (ret) { PERROR << "__mount(target=" << mount_point << ",flag=" << (shared_flag ? "MS_SHARED" : "MS_PRIVATE") << ")=" << ret; + // If "/system" doesn't look like a mountpoint, retry with "/". + if (errno == EINVAL && mount_point == "/system") { + return fs_mgr_overlayfs_set_shared_mount("/", shared_flag); + } return false; } return true;