adb: use fs_mgr_has_shared_blocks
Use fs_mgr_has_shared_blocks in fs_mgr for adb. Test: compile Bug: 109821005 Change-Id: Idccaa252c7630375e49f58727a014e61b50a96d6
This commit is contained in:
parent
3a6c7519a3
commit
7c2020bf64
|
@ -38,7 +38,6 @@
|
|||
#include <android-base/properties.h>
|
||||
#include <bootloader_message/bootloader_message.h>
|
||||
#include <cutils/android_reboot.h>
|
||||
#include <ext4_utils/ext4_utils.h>
|
||||
#include <fs_mgr.h>
|
||||
#include <fs_mgr_overlayfs.h>
|
||||
|
||||
|
@ -96,27 +95,6 @@ bool make_block_device_writable(const std::string& dev) {
|
|||
return result;
|
||||
}
|
||||
|
||||
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(path.c_str(), &fs) == -1 || fs.f_type != EXT4_SUPER_MAGIC) {
|
||||
return false;
|
||||
}
|
||||
unique_fd fd(unix_open(device.c_str(), O_RDONLY));
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
struct ext4_super_block sb;
|
||||
if (lseek64(fd, 1024, SEEK_SET) < 0 || unix_read(fd, &sb, sizeof(sb)) < 0) {
|
||||
return false;
|
||||
}
|
||||
struct fs_info info;
|
||||
if (ext4_parse_sb(&sb, &info) < 0) {
|
||||
return false;
|
||||
}
|
||||
return (info.feat_ro_compat & EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS) != 0;
|
||||
}
|
||||
|
||||
static bool can_unshare_blocks(int fd, const char* dev) {
|
||||
const char* E2FSCK_BIN = "/system/bin/e2fsck";
|
||||
if (access(E2FSCK_BIN, X_OK)) {
|
||||
|
@ -250,7 +228,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(partition, dev)) {
|
||||
if (dev.empty() || !fs_mgr_has_shared_blocks(partition, dev)) {
|
||||
continue;
|
||||
}
|
||||
if (can_unshare_blocks(fd.get(), dev.c_str())) {
|
||||
|
|
Loading…
Reference in New Issue