diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-05-29 12:02:51 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-05-29 12:02:51 +0000 |
commit | f5ac28745ff831ff91a1c2aedb32eedfec92d13a (patch) | |
tree | dcf6f9c03fe623540fb9d8f52af5160aa333df71 /sbin | |
parent | 460364710c8e88762893a2039aba177087b2b897 (diff) |
fsck should use the same values in checking as newfs does in creating
a filesystem. fs_nspf and its derivitives like fs_spc are DEV_BSIZE
values, not actual hardware disk sector values. Adjust initializations
accordingly.
Tweak header and man page comments to make the DEV_BSIZE'ness more
obvious for future spelunkers.
No-op for DEV_BSIZE (a.k.a. 512-byte) sector devices but should help
checking filesystems on, e.g., 4k-byte sector devices.
ok jmc@ on the man page tweaks.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck_ffs/setup.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 7b35e9e120b..6c5304ee532 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.53 2014/05/09 13:56:33 krw Exp $ */ +/* $OpenBSD: setup.c,v 1.54 2014/05/29 12:02:50 krw Exp $ */ /* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */ /* @@ -602,12 +602,15 @@ calcsb(char *dev, int devfd, struct fs *fs) fs->fs_frag = DISKLABELV1_FFS_FRAG(pp->p_fragblock); fs->fs_bsize = fs->fs_fsize * fs->fs_frag; fs->fs_cpg = pp->p_cpg; - fs->fs_nspf = fs->fs_fsize / lp->d_secsize; - /* unit for fs->fs_size is fragments, for DL_GETPSIZE() it is sectors */ - fs->fs_size = DL_GETPSIZE(pp) / fs->fs_nspf; + fs->fs_nspf = DL_SECTOBLK(lp, fs->fs_fsize / lp->d_secsize); + /* + * fs->fs_size is in fragments, DL_GETPSIZE() is in disk sectors + * and fs_nspf is in DEV_BSIZE blocks. Shake well. + */ + fs->fs_size = DL_SECTOBLK(lp, DL_GETPSIZE(pp)) / fs->fs_nspf; fs->fs_ntrak = lp->d_ntracks; - fs->fs_nsect = lp->d_nsectors; - fs->fs_spc = lp->d_secpercyl; + fs->fs_nsect = DL_SECTOBLK(lp, lp->d_nsectors); + fs->fs_spc = DL_SECTOBLK(lp, lp->d_secpercyl); /* we can't use lp->d_sbsize, it is the max sb size */ fs->fs_sblkno = roundup( howmany(lp->d_bbsize + SBSIZE, fs->fs_fsize), |