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

Commit ccdba575 authored by Yifan Hong's avatar Yifan Hong
Browse files

fs_mgr: overlayfs clears readonly on scratch devices

Fixes adb-remount-test and flashstation because the scratch device
was set to readonly before.

Test: adb-remount-test

Change-Id: I12551d1ed99fb7cfd04f84fcc2b77d3cb94275b2
Fixes: 122454600
Fixes: 122602260
parent e7f492dc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -523,13 +523,13 @@ static int prepare_fs_for_mount(const std::string& blk_device, const FstabEntry&
}

// Mark the given block device as read-only, using the BLKROSET ioctl.
bool fs_mgr_set_blk_ro(const std::string& blockdev) {
bool fs_mgr_set_blk_ro(const std::string& blockdev, bool readonly) {
    unique_fd fd(TEMP_FAILURE_RETRY(open(blockdev.c_str(), O_RDONLY | O_CLOEXEC)));
    if (fd < 0) {
        return false;
    }

    int ON = 1;
    int ON = readonly;
    return ioctl(fd, BLKROSET, &ON) == 0;
}

+6 −1
Original line number Diff line number Diff line
@@ -598,7 +598,11 @@ bool fs_mgr_overlayfs_mount_scratch(const std::string& device_path, const std::s
    entry.mount_point = kScratchMountPoint;
    entry.fs_type = mnt_type;
    entry.flags = MS_RELATIME;
    if (readonly) entry.flags |= MS_RDONLY;
    if (readonly) {
        entry.flags |= MS_RDONLY;
    } else {
        fs_mgr_set_blk_ro(device_path, false);
    }
    auto save_errno = errno;
    auto mounted = fs_mgr_do_mount_one(entry) == 0;
    if (!mounted) {
@@ -656,6 +660,7 @@ bool fs_mgr_overlayfs_make_scratch(const std::string& scratch_device, const std:
        return false;
    }
    command += " " + scratch_device;
    fs_mgr_set_blk_ro(scratch_device, false);
    auto ret = system(command.c_str());
    if (ret) {
        LERROR << "make " << mnt_type << " filesystem on " << scratch_device << " return=" << ret;
+1 −1
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ bool fs_mgr_wait_for_file(const std::string& filename,
                          const std::chrono::milliseconds relative_timeout,
                          FileWaitMode wait_mode = FileWaitMode::Exists);

bool fs_mgr_set_blk_ro(const std::string& blockdev);
bool fs_mgr_set_blk_ro(const std::string& blockdev, bool readonly = true);
bool fs_mgr_update_for_slotselect(Fstab* fstab);
bool fs_mgr_is_device_unlocked();
const std::string& get_android_dt_dir();