diff options
author | David Anderson | 2018-07-30 18:06:01 -0500 |
---|---|---|
committer | David Anderson | 2018-07-30 18:08:29 -0500 |
commit | 6dc508671bfd50ac92f71f4fc28c62eb308ad070 (patch) | |
tree | 3330b66ccb0b08114c19e33c4b1e1a92c97c98bc | |
parent | d5f825c78bc98027a485d8bdecd14e8563a449ba (diff) | |
download | platform-system-core-6dc508671bfd50ac92f71f4fc28c62eb308ad070.tar.gz platform-system-core-6dc508671bfd50ac92f71f4fc28c62eb308ad070.tar.xz platform-system-core-6dc508671bfd50ac92f71f4fc28c62eb308ad070.zip |
adb: Correctly detect deduplicated ext4 partitions.
The fs_has_shared_blocks function had two problems. One, it called
statfs() on the mount point, which will return information about the
file system the mount point is on, rather than the filesystem mounted at
that location. Second, the check for EXT4_SUPER_MAGIC was inverted.
Bug: N/A
Test: adb remount -R works on an ext4 deduplicated device
Change-Id: I2e5ef895ea274cb7cc3c35295120da90a026d0d2
-rw-r--r-- | adb/daemon/remount_service.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/adb/daemon/remount_service.cpp b/adb/daemon/remount_service.cpp index 658858717..0e79d824e 100644 --- a/adb/daemon/remount_service.cpp +++ b/adb/daemon/remount_service.cpp | |||
@@ -92,12 +92,13 @@ bool make_block_device_writable(const std::string& dev) { | |||
92 | return result; | 92 | return result; |
93 | } | 93 | } |
94 | 94 | ||
95 | static bool fs_has_shared_blocks(const char* dev) { | 95 | static bool fs_has_shared_blocks(const std::string& mount_point, const std::string& device) { |
96 | std::string path = mount_point + "/lost+found"; | ||
96 | struct statfs fs; | 97 | struct statfs fs; |
97 | if (statfs(dev, &fs) == -1 || fs.f_type == EXT4_SUPER_MAGIC) { | 98 | if (statfs(path.c_str(), &fs) == -1 || fs.f_type != EXT4_SUPER_MAGIC) { |
98 | return false; | 99 | return false; |
99 | } | 100 | } |
100 | unique_fd fd(unix_open(dev, O_RDONLY)); | 101 | unique_fd fd(unix_open(device.c_str(), O_RDONLY)); |
101 | if (fd < 0) { | 102 | if (fd < 0) { |
102 | return false; | 103 | return false; |
103 | } | 104 | } |
@@ -237,7 +238,7 @@ void remount_service(unique_fd fd, const std::string& cmd) { | |||
237 | std::set<std::string> dedup; | 238 | std::set<std::string> dedup; |
238 | for (const auto& partition : partitions) { | 239 | for (const auto& partition : partitions) { |
239 | std::string dev = find_mount(partition.c_str(), partition == "/"); | 240 | std::string dev = find_mount(partition.c_str(), partition == "/"); |
240 | if (dev.empty() || !fs_has_shared_blocks(dev.c_str())) { | 241 | if (dev.empty() || !fs_has_shared_blocks(partition, dev)) { |
241 | continue; | 242 | continue; |
242 | } | 243 | } |
243 | if (can_unshare_blocks(fd.get(), dev.c_str())) { | 244 | if (can_unshare_blocks(fd.get(), dev.c_str())) { |