This patch check sector size if formatted from a regular file, write the sector info to superblock from device info.
Signed-off-by: Yunlei He <[email protected]> --- fsck/mount.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/fsck/mount.c b/fsck/mount.c index f866c4f..daafaa9 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -1923,6 +1923,38 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi) fsck->chk.valid_nat_entry_cnt); } +static int check_sector_size(struct f2fs_super_block * sb) +{ + int index; + u_int32_t log_sectorsize, log_sectors_per_block; + u_int8_t *zero_buff; + + zero_buff = calloc(F2FS_BLKSIZE, 1); + + log_sectorsize = log_base_2(config.sector_size); + log_sectors_per_block = log_base_2(config.sectors_per_blk); + + if (log_sectorsize != get_sb(log_sectorsize)) + set_sb(log_sectorsize, log_sectorsize); + + if (log_sectors_per_block != get_sb(log_sectors_per_block)) + set_sb(log_sectors_per_block, log_sectors_per_block); + + memcpy(zero_buff + F2FS_SUPER_OFFSET, sb, sizeof(*sb)); + DBG(1, "\tWriting super block, at offset 0x%08x\n", 0); + for (index = 0; index < 2; index++) { + if (dev_write(zero_buff, index * F2FS_BLKSIZE, F2FS_BLKSIZE)) { + MSG(1, "\tError: While while writing supe_blk \ + on disk!!! index : %d\n", index); + free(zero_buff); + return -1; + } + } + + free(zero_buff); + return 0; +} + int f2fs_do_mount(struct f2fs_sb_info *sbi) { struct f2fs_checkpoint *cp = NULL; @@ -1936,6 +1968,10 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi) return -1; } + ret = check_sector_size(sbi->raw_super); + if (ret) + return -1; + print_raw_sb_info(F2FS_RAW_SUPER(sbi)); init_sb_info(sbi); -- 1.9.1 ------------------------------------------------------------------------------ Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched! https://ad.doubleclick.net/ddm/clk/304595813;131938128;j _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
