Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d79a436 authored by David Anderson's avatar David Anderson
Browse files

remount: Remove fs_mgr_overlayfs_scratch_device()

This is no longer needed now that GetScratchDevice exists. The cache can
go away too, since it only existed to avoid libdm spam. The spam is
avoided by checking GetState before calling GetDmDevicePathByName.

Bug: 134949511
Test: adb remount and adb_remount_test.sh
Change-Id: I9d94e2523af9de394a811d0b398fe20415708a6b
parent 43d9f183
Loading
Loading
Loading
Loading
+2 −13
Original line number Original line Diff line number Diff line
@@ -440,13 +440,9 @@ void fs_mgr_overlayfs_umount_scratch() {
    rmdir(kScratchMountPoint.c_str());
    rmdir(kScratchMountPoint.c_str());
}
}


// reduce 'DM_DEV_STATUS failed for scratch: No such device or address' noise
std::string scratch_device_cache;

bool fs_mgr_overlayfs_teardown_scratch(const std::string& overlay, bool* change) {
bool fs_mgr_overlayfs_teardown_scratch(const std::string& overlay, bool* change) {
    // umount and delete kScratchMountPoint storage if we have logical partitions
    // umount and delete kScratchMountPoint storage if we have logical partitions
    if (overlay != kScratchMountPoint) return true;
    if (overlay != kScratchMountPoint) return true;
    scratch_device_cache.erase();
    auto slot_number = fs_mgr_overlayfs_slot_number();
    auto slot_number = fs_mgr_overlayfs_slot_number();
    auto super_device = fs_mgr_overlayfs_super_device(slot_number);
    auto super_device = fs_mgr_overlayfs_super_device(slot_number);
    if (!fs_mgr_rw_access(super_device)) return true;
    if (!fs_mgr_rw_access(super_device)) return true;
@@ -877,13 +873,6 @@ static std::string GetScratchDevice() {
    }
    }
}
}


std::string fs_mgr_overlayfs_scratch_device() {
    if (!scratch_device_cache.empty()) return scratch_device_cache;

    scratch_device_cache = GetScratchDevice();
    return scratch_device_cache;
}

bool fs_mgr_overlayfs_make_scratch(const std::string& scratch_device, const std::string& mnt_type) {
bool fs_mgr_overlayfs_make_scratch(const std::string& scratch_device, const std::string& mnt_type) {
    // Force mkfs by design for overlay support of adb remount, simplify and
    // Force mkfs by design for overlay support of adb remount, simplify and
    // thus do not rely on fsck to correct problems that could creep in.
    // thus do not rely on fsck to correct problems that could creep in.
@@ -1131,7 +1120,7 @@ Fstab fs_mgr_overlayfs_candidate_list(const Fstab& fstab) {
}
}


static void TryMountScratch() {
static void TryMountScratch() {
    auto scratch_device = fs_mgr_overlayfs_scratch_device();
    auto scratch_device = GetScratchDevice();
    if (!fs_mgr_overlayfs_scratch_can_be_mounted(scratch_device)) {
    if (!fs_mgr_overlayfs_scratch_can_be_mounted(scratch_device)) {
        return;
        return;
    }
    }
@@ -1180,7 +1169,7 @@ std::vector<std::string> fs_mgr_overlayfs_required_devices(Fstab* fstab) {
    for (const auto& entry : fs_mgr_overlayfs_candidate_list(*fstab)) {
    for (const auto& entry : fs_mgr_overlayfs_candidate_list(*fstab)) {
        if (fs_mgr_is_verity_enabled(entry)) continue;
        if (fs_mgr_is_verity_enabled(entry)) continue;
        if (fs_mgr_overlayfs_already_mounted(fs_mgr_mount_point(entry.mount_point))) continue;
        if (fs_mgr_overlayfs_already_mounted(fs_mgr_mount_point(entry.mount_point))) continue;
        auto device = fs_mgr_overlayfs_scratch_device();
        auto device = GetScratchDevice();
        if (!fs_mgr_overlayfs_scratch_can_be_mounted(device)) break;
        if (!fs_mgr_overlayfs_scratch_can_be_mounted(device)) break;
        return {device};
        return {device};
    }
    }