summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2008-02-26 03:03:17 +0000
committerdelphij <delphij@FreeBSD.org>2008-02-26 03:03:17 +0000
commit8363f7e2b231e42721459e96f229699391b0dd94 (patch)
treee009d3a7726429cd49e6ffa6159a56505e6a0581 /sbin/fsck_ffs
parent3c2b753612b7a8288525cdf8481727ac73cb25ef (diff)
downloadFreeBSD-src-8363f7e2b231e42721459e96f229699391b0dd94.zip
FreeBSD-src-8363f7e2b231e42721459e96f229699391b0dd94.tar.gz
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.
Diffstat (limited to 'sbin/fsck_ffs')
-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 bdf88b4..f6b37a3 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) {
OpenPOWER on IntegriCloud