Be more careful when checking superblock. We have already checked

whether fs_bsize is larger than MINBSIZE, which is larger than the
value that is used to compared with fs_bsize, the sizeof fs, so the
check followed, will be always true.

By inspecting the code and some old commit log, I believe that the
check must be that *fs_sbsize* is larger than sizeof fs.  We round
up the size to nearest dev_bsize, as the smallest accepted fs_sbsize,
personally, I think this can be even changed to equal, because this
number is mostly an invariant in file systems.

With this check, fsck_ffs(8) will be more picky and has better
chance rejecting bad first superblock rather than referring to bad
value it supplied, thus gives better chance for it to check the
filesystem carefully.
This commit is contained in:
Xin LI 2008-02-26 03:03:17 +00:00
parent 404825a72b
commit 8f0931174a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176573

View File

@ -349,7 +349,7 @@ readsb(int listerr)
sblock.fs_sblockloc == sblock_try[i])) &&
sblock.fs_ncg >= 1 &&
sblock.fs_bsize >= MINBSIZE &&
sblock.fs_bsize >= sizeof(struct fs))
sblock.fs_sbsize >= roundup(sizeof(struct fs), dev_bsize))
break;
}
if (sblock_try[i] == -1) {