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
This commit is contained in:
parent
d5f825c78b
commit
6dc508671b
1 changed files with 5 additions and 4 deletions
|
|
@ -92,12 +92,13 @@ bool make_block_device_writable(const std::string& dev) {
|
|||
return result;
|
||||
}
|
||||
|
||||
static bool fs_has_shared_blocks(const char* dev) {
|
||||
static bool fs_has_shared_blocks(const std::string& mount_point, const std::string& device) {
|
||||
std::string path = mount_point + "/lost+found";
|
||||
struct statfs fs;
|
||||
if (statfs(dev, &fs) == -1 || fs.f_type == EXT4_SUPER_MAGIC) {
|
||||
if (statfs(path.c_str(), &fs) == -1 || fs.f_type != EXT4_SUPER_MAGIC) {
|
||||
return false;
|
||||
}
|
||||
unique_fd fd(unix_open(dev, O_RDONLY));
|
||||
unique_fd fd(unix_open(device.c_str(), O_RDONLY));
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -237,7 +238,7 @@ void remount_service(unique_fd fd, const std::string& cmd) {
|
|||
std::set<std::string> dedup;
|
||||
for (const auto& partition : partitions) {
|
||||
std::string dev = find_mount(partition.c_str(), partition == "/");
|
||||
if (dev.empty() || !fs_has_shared_blocks(dev.c_str())) {
|
||||
if (dev.empty() || !fs_has_shared_blocks(partition, dev)) {
|
||||
continue;
|
||||
}
|
||||
if (can_unshare_blocks(fd.get(), dev.c_str())) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue