From 04aa426c5f280a593271604f2cf8e6523ab62f3a Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Wed, 6 Jun 2018 13:10:40 -0700 Subject: [PATCH] adb: remount for /system as root We can not mount overlayfs on root / as it will intercept all file transactions. Thus must remount /system instead. Test: manual Bug: 109821005 Bug: 115751838 Change-Id: Idf646b8c1ca8a0d006bf64e23a76a7e909f9162a --- adb/daemon/remount_service.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/adb/daemon/remount_service.cpp b/adb/daemon/remount_service.cpp index e96c03502..380dfa653 100644 --- a/adb/daemon/remount_service.cpp +++ b/adb/daemon/remount_service.cpp @@ -146,6 +146,10 @@ static bool remount_partition(int fd, const char* dir) { return true; } bool is_root = strcmp(dir, "/") == 0; + if (is_root && !find_mount("/system", false).empty()) { + dir = "/system"; + is_root = false; + } std::string dev = find_mount(dir, is_root); // Even if the device for the root is not found, we still try to remount it // as rw. This typically only happens when running Android in a container: @@ -226,7 +230,9 @@ void remount_service(unique_fd fd, const std::string& cmd) { // Find partitions that are deduplicated, and can be un-deduplicated. std::set dedup; - for (const auto& partition : partitions) { + for (const auto& part : partitions) { + auto partition = part; + if ((part == "/") && !find_mount("/system", false).empty()) partition = "/system"; std::string dev = find_mount(partition.c_str(), partition == "/"); if (dev.empty() || !fs_mgr_has_shared_blocks(partition, dev)) { continue;