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 fs_mgr/liblp/writer.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,12 @@ bool FlashPartitionTable(const IPartitionOpener& opener, const std::string& supe return false; } // On retrofit devices, super_partition is system_other and might be set to readonly by // fs_mgr_set_blk_ro(). Unset readonly so that fd can be written to. if (!SetBlockReadonly(fd.get(), false)) { PWARNING << __PRETTY_FUNCTION__ << " BLKROSET 0 failed: " << super_partition; } // Write zeroes to the first block. std::string zeroes(LP_PARTITION_RESERVED_BYTES, 0); if (SeekFile64(fd, 0, SEEK_SET) < 0) { Loading 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
fs_mgr/liblp/writer.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,12 @@ bool FlashPartitionTable(const IPartitionOpener& opener, const std::string& supe return false; } // On retrofit devices, super_partition is system_other and might be set to readonly by // fs_mgr_set_blk_ro(). Unset readonly so that fd can be written to. if (!SetBlockReadonly(fd.get(), false)) { PWARNING << __PRETTY_FUNCTION__ << " BLKROSET 0 failed: " << super_partition; } // Write zeroes to the first block. std::string zeroes(LP_PARTITION_RESERVED_BYTES, 0); if (SeekFile64(fd, 0, SEEK_SET) < 0) { Loading