summaryrefslogtreecommitdiff
path: root/sbin/newfs
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2004-10-14 07:40:30 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2004-10-14 07:40:30 +0000
commit847f96280d44d4c3000df1dffb562acaceb5a588 (patch)
tree6159c5f0844fbde82a8be42cc86606aed6b9cab3 /sbin/newfs
parent00c0f0ecc4e868c185f39831a12159bd318e2ac6 (diff)
Do not generate either a too large super block or a negative number
of inodes per cylinder group for large block or fragment sizes. This allows for creation of filesystems with any legal block/fragment size combination. ok tedu@.
Diffstat (limited to 'sbin/newfs')
-rw-r--r--sbin/newfs/mkfs.c29
-rw-r--r--sbin/newfs/newfs.88
2 files changed, 17 insertions, 20 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index e8e54809358..e965a1ee976 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkfs.c,v 1.44 2004/09/10 19:49:15 otto Exp $ */
+/* $OpenBSD: mkfs.c,v 1.45 2004/10/14 07:40:29 otto Exp $ */
/* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)mkfs.c 8.3 (Berkeley) 2/3/94";
#else
-static char rcsid[] = "$OpenBSD: mkfs.c,v 1.44 2004/09/10 19:49:15 otto Exp $";
+static char rcsid[] = "$OpenBSD: mkfs.c,v 1.45 2004/10/14 07:40:29 otto Exp $";
#endif
#endif /* not lint */
@@ -356,7 +356,8 @@ recalc:
*/
inodecramped = 0;
used *= sectorsize;
- inospercg = roundup((mincpg * bpcg - used) / density, INOPB(&sblock));
+ inospercg = roundup(((int64_t)mincpg * bpcg - used) / density,
+ INOPB(&sblock));
sblock.fs_ipg = inospercg;
while (inospercg > MAXIPG(&sblock)) {
inodecramped = 1;
@@ -376,8 +377,8 @@ recalc:
break;
}
mincpg = sblock.fs_cpg;
- inospercg =
- roundup((mincpg * bpcg - used) / density, INOPB(&sblock));
+ inospercg = roundup(((int64_t)mincpg * bpcg - used) / density,
+ INOPB(&sblock));
sblock.fs_ipg = inospercg;
}
if (inodecramped) {
@@ -420,13 +421,13 @@ recalc:
/*
* Must ensure there is enough space for inodes.
*/
- sblock.fs_ipg = roundup((sblock.fs_cpg * bpcg - used) / density,
- INOPB(&sblock));
+ sblock.fs_ipg = roundup(((int64_t)sblock.fs_cpg * bpcg - used) /
+ density, INOPB(&sblock));
while (sblock.fs_ipg > MAXIPG(&sblock)) {
inodecramped = 1;
sblock.fs_cpg -= mincpc;
- sblock.fs_ipg = roundup((sblock.fs_cpg * bpcg - used) / density,
- INOPB(&sblock));
+ sblock.fs_ipg = roundup(((int64_t)sblock.fs_cpg * bpcg - used) /
+ density, INOPB(&sblock));
}
/*
* Must ensure there is enough space to hold block map.
@@ -439,8 +440,8 @@ recalc:
while (CGSIZE(&sblock) > sblock.fs_bsize) {
mapcramped = 1;
sblock.fs_cpg -= mincpc;
- sblock.fs_ipg = roundup((sblock.fs_cpg * bpcg - used) / density,
- INOPB(&sblock));
+ sblock.fs_ipg = roundup(((int64_t)sblock.fs_cpg * bpcg - used) /
+ density, INOPB(&sblock));
}
sblock.fs_fpg = (sblock.fs_cpg * sblock.fs_spc) / NSPF(&sblock);
if ((sblock.fs_cpg * sblock.fs_spc) % NSPB(&sblock) != 0) {
@@ -494,6 +495,8 @@ recalc:
sblock.fs_npsect = nphyssectors;
sblock.fs_postblformat = FS_DYNAMICPOSTBLFMT;
sblock.fs_sbsize = fragroundup(&sblock, sizeof(struct fs));
+ if (sblock.fs_sbsize > SBSIZE)
+ sblock.fs_sbsize = SBSIZE;
if (sblock.fs_ntrak == 1) {
sblock.fs_cpc = 0;
goto next;
@@ -514,8 +517,8 @@ recalc:
sblock.fs_rotbloff = sblock.fs_postbloff + postblsize;
totalsbsize += postblsize;
}
- if (totalsbsize > SBSIZE ||
- sblock.fs_nsect > (1 << NBBY) * NSPB(&sblock)) {
+ if (totalsbsize > SBSIZE || fragroundup(&sblock, totalsbsize) > SBSIZE
+ || sblock.fs_nsect > (1 << NBBY) * NSPB(&sblock)) {
printf("%s %s %d %s %d.%s",
"Warning: insufficient space in super block for\n",
"rotational layout tables with nsect", sblock.fs_nsect,
diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8
index 2bb804fd196..6a7ff9a453b 100644
--- a/sbin/newfs/newfs.8
+++ b/sbin/newfs/newfs.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: newfs.8,v 1.41 2004/08/15 22:06:20 jmc Exp $
+.\" $OpenBSD: newfs.8,v 1.42 2004/10/14 07:40:29 otto Exp $
.\" $NetBSD: newfs.8,v 1.12 1995/03/18 14:58:41 cgd Exp $
.\"
.\" Copyright (c) 1983, 1987, 1991, 1993, 1994
@@ -353,9 +353,3 @@ The
.Nm
command appeared in
.Bx 4.2 .
-.Sh BUGS
-Certain combinations of block and fragment sizes may not produce a valid
-file system.
-If a non-default block or fragment size is specified,
-.Xr fsck 8
-should be run on the newly created filesystem before use.