summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/newfs/mkfs.c10
-rw-r--r--sys/ufs/ffs/fs.h13
2 files changed, 10 insertions, 13 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 900fb1a30a4..76db8bf2af2 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkfs.c,v 1.58 2007/04/23 10:18:30 pedro Exp $ */
+/* $OpenBSD: mkfs.c,v 1.59 2007/05/03 20:11:55 millert Exp $ */
/* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */
/*
@@ -341,7 +341,6 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode,
if (sblock.fs_fpg < minfpg)
sblock.fs_fpg = minfpg;
- sblock.fs_spc = sblock.fs_fpg * sblock.fs_nspf;
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
INOPB(&sblock));
@@ -371,9 +370,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode,
* grow any larger, the number of cylinder groups drops below
* mincylgrps, or we reach the requested size.
*/
- for (; sblock.fs_fpg < maxblkspercg;
- sblock.fs_fpg += sblock.fs_frag,
- sblock.fs_spc = sblock.fs_fpg * sblock.fs_nspf) {
+ for (; sblock.fs_fpg < maxblkspercg; sblock.fs_fpg += sblock.fs_frag) {
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
INOPB(&sblock));
@@ -387,7 +384,6 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode,
break;
sblock.fs_fpg -= sblock.fs_frag;
- sblock.fs_spc = sblock.fs_fpg * sblock.fs_nspf;
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
INOPB(&sblock));
@@ -414,7 +410,6 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode,
break;
sblock.fs_fpg -= sblock.fs_frag;
- sblock.fs_spc = sblock.fs_fpg * sblock.fs_nspf;
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
INOPB(&sblock));
}
@@ -428,6 +423,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode,
* Back to filling superblock fields.
*/
if (Oflag <= 1) {
+ sblock.fs_spc = sblock.fs_fpg * sblock.fs_nspf;
sblock.fs_nsect = sblock.fs_spc;
sblock.fs_npsect = sblock.fs_spc;
sblock.fs_ncyl = sblock.fs_ncg;
diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h
index 545b7f15d72..0c056b2f052 100644
--- a/sys/ufs/ffs/fs.h
+++ b/sys/ufs/ffs/fs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fs.h,v 1.29 2007/04/23 10:18:30 pedro Exp $ */
+/* $OpenBSD: fs.h,v 1.30 2007/05/03 20:11:55 millert Exp $ */
/* $NetBSD: fs.h,v 1.6 1995/04/12 21:21:02 mycroft Exp $ */
/*
@@ -357,10 +357,10 @@ struct fs {
/* blktot size */ (fs)->fs_cpg * sizeof(int32_t) + \
/* blks size */ (fs)->fs_cpg * (fs)->fs_nrpos * sizeof(int16_t) + \
/* inode map */ howmany((fs)->fs_ipg, NBBY) + \
- /* block map */ howmany((fs)->fs_cpg * (fs)->fs_spc / NSPF(fs), NBBY) +\
+ /* block map */ howmany((fs)->fs_fpg, NBBY) + \
/* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \
/* cluster sum */ (fs)->fs_contigsumsize * sizeof(int32_t) + \
- /* cluster map */ howmany((fs)->fs_cpg * (fs)->fs_spc / NSPB(fs), NBBY)))
+ /* cluster map */ howmany(fragstoblks(fs, (fs)->fs_fpg), NBBY)))
/*
* Convert cylinder group to base address of its global summary info.
@@ -497,10 +497,11 @@ struct ocg {
#define blkmap(fs, map, loc) \
(((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag)))
#define cbtocylno(fs, bno) \
- ((bno) * NSPF(fs) / (fs)->fs_spc)
+ (fsbtodb(fs, bno) / (fs)->fs_spc)
#define cbtorpos(fs, bno) \
- (((bno) * NSPF(fs) % (fs)->fs_spc / (fs)->fs_nsect * (fs)->fs_trackskew + \
- (bno) * NSPF(fs) % (fs)->fs_spc % (fs)->fs_nsect * (fs)->fs_interleave) % \
+ ((fs)->fs_nrpos <= 1 ? 0 : \
+ (fsbtodb(fs, bno) % (fs)->fs_spc / (fs)->fs_nsect * (fs)->fs_trackskew + \
+ fsbtodb(fs, bno) % (fs)->fs_spc % (fs)->fs_nsect * (fs)->fs_interleave) % \
(fs)->fs_nsect * (fs)->fs_nrpos / (fs)->fs_npsect)
/*