Loading fs_mgr/fs_mgr.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading fs_mgr/fs_mgr_overlayfs.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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; Loading fs_mgr/fs_mgr_priv.h +1 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading fs_mgr/liblp/utility.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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 fs_mgr/liblp/utility.h +4 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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 Loading
fs_mgr/fs_mgr.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading
fs_mgr/fs_mgr_overlayfs.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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; Loading
fs_mgr/fs_mgr_priv.h +1 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading
fs_mgr/liblp/utility.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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
fs_mgr/liblp/utility.h +4 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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