aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2008-02-26 03:03:17 +0000
committerXin LI <delphij@FreeBSD.org>2008-02-26 03:03:17 +0000
commit8f0931174a3e973773dfea895712cefa5e49e4fb (patch)
treee009d3a7726429cd49e6ffa6159a56505e6a0581 /sbin
parent404825a72b6fdaada592ae93c5e39f0536a96d5a (diff)
downloadsrc-8f0931174a3e973773dfea895712cefa5e49e4fb.tar.gz
src-8f0931174a3e973773dfea895712cefa5e49e4fb.zip
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.
Notes
Notes: svn path=/head/; revision=176573
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck_ffs/setup.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index bdf88b4b0dfd..f6b37a31cdec 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -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) {