From beb4cb8e436b348efcf4e5f57f0a855991a57363 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Tue, 6 Nov 2018 08:27:05 -0800 Subject: [PATCH] adb: overlayfs failed to remount /system Regression introduced commit bb1efbd1c603181f1d9817aa43dad546a55aec29 By not first checking if overlayfs mount on /system is in /proc/mounts remount fails to discover the override and take the selected action. Test: adb-remount-test.sh Bug: 109821005 Change-Id: I1f0bae22caae1bca84fc1e33b508b54d98f4ed5c --- adb/daemon/remount_service.cpp | 10 +++++++++- fs_mgr/tests/adb-remount-test.sh | 5 ++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/adb/daemon/remount_service.cpp b/adb/daemon/remount_service.cpp index 2dcfb5330..b72ed1634 100644 --- a/adb/daemon/remount_service.cpp +++ b/adb/daemon/remount_service.cpp @@ -97,8 +97,12 @@ static std::string find_mount(const char* dir, bool is_root) { } } +bool dev_is_overlayfs(const std::string& dev) { + return (dev == "overlay") || (dev == "overlayfs"); +} + bool make_block_device_writable(const std::string& dev) { - if ((dev == "overlay") || (dev == "overlayfs")) return true; + if (dev_is_overlayfs(dev)) return true; int fd = unix_open(dev.c_str(), O_RDONLY | O_CLOEXEC); if (fd == -1) { return false; @@ -161,6 +165,10 @@ static bool remount_partition(int fd, const char* dir) { return true; } bool is_root = strcmp(dir, "/") == 0; + if (is_root && dev_is_overlayfs(find_mount("/system", false))) { + dir = "/system"; + is_root = false; + } std::string dev = find_mount(dir, is_root); if (is_root && dev.empty()) { // The fstab entry will be /system if the device switched roots during diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh index 6b908d3c3..98c0879d2 100755 --- a/fs_mgr/tests/adb-remount-test.sh +++ b/fs_mgr/tests/adb-remount-test.sh @@ -274,9 +274,8 @@ H=`echo "${D}" | head -1` && echo "${D}" | grep "^overlay .* /system\$" >/dev/null || die "overlay takeover after remount" !(adb_sh grep "^overlay " /proc/mounts