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

Commit 3c1cdaf5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic "fsmgr_system_other"

* changes:
  fs_mgr: overlayfs clears readonly on scratch devices
  liblp: BLKROSET 0 prior to FlashPartitionTable
  fs_mgr: system_other does not want overlayfs.
parents 2f171cc6 ccdba575
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;
}

+9 −1
Original line number Diff line number Diff line
@@ -277,6 +277,9 @@ bool fs_mgr_wants_overlayfs(FstabEntry* entry) {
    // Don't check entries that are managed by vold.
    if (entry->fs_mgr_flags.vold_managed || entry->fs_mgr_flags.recovery_only) return false;

    // *_other doesn't want overlayfs.
    if (entry->fs_mgr_flags.slot_select_other) return false;

    // Only concerned with readonly partitions.
    if (!(entry->flags & MS_RDONLY)) return false;

@@ -595,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) {
@@ -653,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();
+16 −0
Original line number Diff line number Diff line
@@ -19,6 +19,11 @@
#include <sys/stat.h>
#include <unistd.h>

#if defined(__linux__)
#include <linux/fs.h>
#include <sys/ioctl.h>
#endif

#include <android-base/file.h>
#include <ext4_utils/ext4_utils.h>
#include <openssl/sha.h>
@@ -155,5 +160,16 @@ bool UpdatePartitionGroupName(LpMetadataPartitionGroup* group, const std::string
    return true;
}

bool SetBlockReadonly(int fd, bool readonly) {
#if defined(__linux__)
    int val = readonly;
    return ioctl(fd, BLKROSET, &val) == 0;
#else
    (void)fd;
    (void)readonly;
    return true;
#endif
}

}  // namespace fs_mgr
}  // namespace android
+4 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#define LWARN LOG(WARNING) << LP_TAG
#define LINFO LOG(INFO) << LP_TAG
#define LERROR LOG(ERROR) << LP_TAG
#define PWARNING PLOG(WARNING) << LP_TAG
#define PERROR PLOG(ERROR) << LP_TAG

namespace android {
@@ -88,6 +89,9 @@ constexpr uint64_t AlignTo(uint64_t base, uint32_t alignment, uint32_t alignment
bool UpdateBlockDevicePartitionName(LpMetadataBlockDevice* device, const std::string& name);
bool UpdatePartitionGroupName(LpMetadataPartitionGroup* group, const std::string& name);

// Call BLKROSET ioctl on fd so that fd is readonly / read-writable.
bool SetBlockReadonly(int fd, bool readonly);

}  // namespace fs_mgr
}  // namespace android

Loading