Hello, 2021년 5월 12일 (수) 오전 8:57, Eric Sandeen <sandeen@xxxxxxxxxxx>님이 작성: > > On 5/11/21 6:53 PM, Namjae Jeon wrote: > > >> One other thing that I ran across is that fsck seems to validate an image against the sector size of > >> the device hosting the image rather than the sector size found in the boot sector, which seems like > >> another issue that will come up: > >> > >> # fsck/fsck.exfat /dev/sdb > >> exfatprogs version : 1.1.1 > >> /dev/sdb: clean. directories 1, files 0 > >> > >> # dd if=/dev/sdb of=test.img > >> 524288+0 records in > >> 524288+0 records out > >> 268435456 bytes (268 MB) copied, 1.27619 s, 210 MB/s > >> > >> # fsck.exfat test.img > >> exfatprogs version : 1.1.1 > >> checksum of boot region is not correct. 0, but expected 0x3ee721 boot region is corrupted. try to > >> restore the region from backup. Fix (y/N)? n > >> > >> Right now the utilities seem to assume that the device they're pointed at is always a block device, > >> and image files are problematic. > > Okay, Will fix it. > > Right now I have a hack like this. > > 1) don't validate the in-image sector size against the host device size > (maybe should only skip this check if it's not a bdev? Or is it OK to have > a 4k sector size fs on a 512 device? Probably?) > > 2) populate the "bd" sector size information from the values read from the image. > > It feels a bit messy, but it works so far. I guess the messiness stems from > assuming that we always have a "bd" block device. > I think we need to keep the "bd" sector size to avoid confusion between the device's sector size and the exfat's sector size. > -Eric > > diff --git a/dump/dump.c b/dump/dump.c > index 85d5101..30ec8cb 100644 > --- a/dump/dump.c > +++ b/dump/dump.c > @@ -100,6 +100,9 @@ static int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd) > goto free_ppbr; > } > > + bd->sector_size_bits = pbsx->sect_size_bits; > + bd->sector_size = 1 << pbsx->sect_size_bits; > + > if (pbsx->sect_per_clus_bits > 25 - pbsx->sect_size_bits) { > exfat_err("bogus sectors bits per cluster : %u\n", > pbsx->sect_per_clus_bits); > @@ -107,13 +110,6 @@ static int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd) > goto free_ppbr; > } > > - if (bd->sector_size != 1 << pbsx->sect_size_bits) { > - exfat_err("bogus sector size : %u (sector size bits : %u)\n", > - bd->sector_size, pbsx->sect_size_bits); > - ret = -EINVAL; > - goto free_ppbr; > - } > - > clu_offset = le32_to_cpu(pbsx->clu_offset); > total_clus = le32_to_cpu(pbsx->clu_count); > root_clu = le32_to_cpu(pbsx->root_cluster); > diff --git a/fsck/fsck.c b/fsck/fsck.c > index 747a771..5ea8278 100644 > --- a/fsck/fsck.c > +++ b/fsck/fsck.c > @@ -682,6 +682,9 @@ static int read_boot_region(struct exfat_blk_dev *bd, struct pbr **pbr, > goto err; > } > > + bd->sector_size_bits = bs->bsx.sect_size_bits; > + bd->sector_size = 1 << bs->bsx.sect_size_bits; > + Is it better to add a sector size parameter to read_boot_region function? This function is also called to read the backup boot region to restore the corrupted main boot region. During this restoration, we need to read the backup boot region with various sector sizes, Because we don't have a certain exfat sector size. > ret = boot_region_checksum(bd, bs_offset); > if (ret < 0) > goto err; > > I sent the pull request to fix these problems. Could you check this request? https://github.com/exfatprogs/exfatprogs/pull/167 Thanks, Hyunchul.