summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2014-05-29 12:02:50 +0000
committerkrw <krw@openbsd.org>2014-05-29 12:02:50 +0000
commit0ab28d6efcbc8dc7340fb44adf7291e8c77d9150 (patch)
tree4bfc51ac434f184a5500dd8e9c7220ad4e021675
parentFix another two cases where the return value of ssl_replace_hash() is (diff)
downloadwireguard-openbsd-0ab28d6efcbc8dc7340fb44adf7291e8c77d9150.tar.xz
wireguard-openbsd-0ab28d6efcbc8dc7340fb44adf7291e8c77d9150.zip
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.
-rw-r--r--sbin/fsck_ffs/setup.c15
-rw-r--r--share/man/man5/fs.514
-rw-r--r--sys/ufs/ffs/fs.h12
3 files changed, 22 insertions, 19 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),
diff --git a/share/man/man5/fs.5 b/share/man/man5/fs.5
index b91cadf5b21..4fadc7d8dec 100644
--- a/share/man/man5/fs.5
+++ b/share/man/man5/fs.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: fs.5,v 1.16 2007/06/25 16:15:29 jmc Exp $
+.\" $OpenBSD: fs.5,v 1.17 2014/05/29 12:02:50 krw Exp $
.\" $NetBSD: fs.5,v 1.3 1994/11/30 19:31:17 jtc Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
@@ -30,7 +30,7 @@
.\"
.\" @(#)fs.5 8.2 (Berkeley) 4/19/94
.\"
-.Dd $Mdocdate: June 25 2007 $
+.Dd $Mdocdate: May 29 2014 $
.Dt FS 5
.Os
.Sh NAME
@@ -107,12 +107,12 @@ struct fs {
int32_t fs_csshift; /* csum block number (now unused) */
int32_t fs_nindir; /* value of NINDIR */
int32_t fs_inopb; /* inodes per file system block */
- int32_t fs_nspf; /* value of NSPF */
+ int32_t fs_nspf; /* DEV_BSIZE sectors per frag */
/* yet another configuration parameter */
int32_t fs_optim; /* optimization preference, see below */
/* these fields are derived from the hardware */
- int32_t fs_npsect; /* # sectors/track including spares */
- int32_t fs_interleave; /* hardware sector interleave */
+ int32_t fs_npsect; /* DEV_BSIZE sectors/track + spares */
+ int32_t fs_interleave; /* DEV_BSIZE sector interleave */
int32_t fs_trackskew; /* sector 0 skew, per track */
/* fs_id takes the space of unused fs_headswitch and fs_trkseek fields */
int32_t fs_id[2]; /* unique filesystem id */
@@ -122,8 +122,8 @@ struct fs {
int32_t fs_cgsize; /* cyl grp block size / bytes */
/* these fields are derived from the hardware */
int32_t fs_ntrak; /* tracks per cylinder */
- int32_t fs_nsect; /* sectors per track */
- int32_t fs_spc; /* sectors per cylinder */
+ int32_t fs_nsect; /* DEV_BSIZE sectors per track */
+ int32_t fs_spc; /* DEV_BSIZE sectors per cylinder */
/* this comes from the disk driver partitioning */
int32_t fs_ncyl; /* cylinders in file system */
/* these fields can be computed from the others */
diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h
index 95e44832df1..98aa23006d3 100644
--- a/sys/ufs/ffs/fs.h
+++ b/sys/ufs/ffs/fs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fs.h,v 1.39 2013/11/12 14:20:52 krw Exp $ */
+/* $OpenBSD: fs.h,v 1.40 2014/05/29 12:02:50 krw Exp $ */
/* $NetBSD: fs.h,v 1.6 1995/04/12 21:21:02 mycroft Exp $ */
/*
@@ -224,12 +224,12 @@ struct fs {
int32_t fs_csshift; /* csum block number (now unused) */
int32_t fs_nindir; /* value of NINDIR */
int32_t fs_inopb; /* inodes per file system block */
- int32_t fs_nspf; /* value of NSPF */
+ int32_t fs_nspf; /* DEV_BSIZE sectors per frag */
/* yet another configuration parameter */
int32_t fs_optim; /* optimization preference, see below */
/* these fields are derived from the hardware */
- int32_t fs_npsect; /* # sectors/track including spares */
- int32_t fs_interleave; /* hardware sector interleave */
+ int32_t fs_npsect; /* DEV_BSIZE sectors/track + spares */
+ int32_t fs_interleave; /* DEV_BSIZE sector interleave */
int32_t fs_trackskew; /* sector 0 skew, per track */
/* fs_id takes the space of the unused fs_headswitch and fs_trkseek fields */
int32_t fs_id[2]; /* unique filesystem id */
@@ -239,8 +239,8 @@ struct fs {
int32_t fs_cgsize; /* cyl grp block size / bytes */
/* these fields are derived from the hardware */
int32_t fs_ntrak; /* tracks per cylinder */
- int32_t fs_nsect; /* sectors per track */
- int32_t fs_spc; /* sectors per cylinder */
+ int32_t fs_nsect; /* DEV_BSIZE sectors per track */
+ int32_t fs_spc; /* DEV_BSIZE sectors per cylinder */
/* this comes from the disk driver partitioning */
int32_t fs_ncyl; /* cylinders in file system */
/* these fields can be computed from the others */