summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-05-18 19:08:17 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-05-18 19:08:17 +0000
commit2569a0e5f59f73e1671e575fbf7cbc495e991559 (patch)
treeee29ed17c7a96c8310d7990334ecda0bb0faa0d1
parent4b7609c1336009809d34f52bd71cbb1b75c63cd4 (diff)
The unit of the -c options is fragments, so adjust man page and
variable name; correct the loop packing more inodes into the cg: in some cases it could put more fragments into the cg than requested; give an error if the -c option cannot be honoured. ok millert@ pedro@
-rw-r--r--sbin/newfs/mkfs.c32
-rw-r--r--sbin/newfs/newfs.810
-rw-r--r--sbin/newfs/newfs.c10
3 files changed, 24 insertions, 28 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index a99ecc8be57..154271dd127 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkfs.c,v 1.60 2007/05/18 18:57:06 otto Exp $ */
+/* $OpenBSD: mkfs.c,v 1.61 2007/05/18 19:08:16 otto Exp $ */
/* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */
/*
@@ -88,7 +88,7 @@ extern int fssize; /* file system size */
extern int sectorsize; /* bytes/sector */
extern int fsize; /* fragment size */
extern int bsize; /* block size */
-extern int maxblkspercg; /* maximum blocks per cylinder group */
+extern int maxfrgspercg; /* maximum fragments per cylinder group */
extern int minfree; /* free space threshold */
extern int opt; /* optimization preference (space or time) */
extern int density; /* number of bytes per inode */
@@ -359,8 +359,8 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode,
* install media which needs to pack 2 files very tightly.
*/
mincylgrps = MINCYLGRPS;
- if (maxblkspercg != INT_MAX) {
- i = sblock.fs_size / maxblkspercg;
+ if (maxfrgspercg != INT_MAX) {
+ i = sblock.fs_size / maxfrgspercg;
if (i < MINCYLGRPS)
mincylgrps = i <= 0 ? 1 : i;
}
@@ -370,25 +370,21 @@ 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) {
+ for (;;) {
+ sblock.fs_fpg += sblock.fs_frag;
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
INOPB(&sblock));
- if (sblock.fs_size / sblock.fs_fpg < mincylgrps)
- break;
-
- if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize)
- continue;
-
- if (CGSIZE(&sblock) == (unsigned long)sblock.fs_bsize)
+ if (sblock.fs_fpg > maxfrgspercg ||
+ sblock.fs_size / sblock.fs_fpg < mincylgrps ||
+ CGSIZE(&sblock) > (unsigned long)sblock.fs_bsize)
break;
-
- sblock.fs_fpg -= sblock.fs_frag;
- sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
- INOPB(&sblock));
-
- break;
}
+ sblock.fs_fpg -= sblock.fs_frag;
+ sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
+ INOPB(&sblock));
+ if (sblock.fs_fpg > maxfrgspercg)
+ errx(22, "can't honour -c: minimum is %d", sblock.fs_fpg);
/*
* Check to be sure that the last cylinder group has enough blocks to
diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8
index 2a7c8a01644..7506e5249b2 100644
--- a/sbin/newfs/newfs.8
+++ b/sbin/newfs/newfs.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: newfs.8,v 1.55 2007/04/13 20:20:54 jmc Exp $
+.\" $OpenBSD: newfs.8,v 1.56 2007/05/18 19:08:16 otto Exp $
.\" $NetBSD: newfs.8,v 1.12 1995/03/18 14:58:41 cgd Exp $
.\"
.\" Copyright (c) 1983, 1987, 1991, 1993, 1994
@@ -41,7 +41,7 @@
.Bk -words
.Op Fl Nq
.Op Fl b Ar block-size
-.Op Fl c Ar blocks-per-cylinder-group
+.Op Fl c Ar fragments-per-cylinder-group
.Op Fl e Ar maxbpg
.Op Fl f Ar frag-size
.Op Fl g Ar avgfilesize
@@ -59,7 +59,7 @@
.Nm mount_mfs
.Bk -words
.Op Fl b Ar block-size
-.Op Fl c Ar blocks-per-cylinder-group
+.Op Fl c Ar fragments-per-cylinder-group
.Op Fl e Ar maxbpg
.Op Fl f Ar frag-size
.Op Fl i Ar bytes
@@ -131,8 +131,8 @@ The following options define the general layout policies:
.It Fl b Ar block-size
The block size of the file system, in bytes.
The default is 16KB.
-.It Fl c Ar blocks-per-cylinder-group
-The number of blocks per cylinder group in a file system.
+.It Fl c Ar fragments-per-cylinder-group
+The number of fragments per cylinder group in a file system.
The default is to compute the maximum allowed by the other parameters.
This value is dependent on a number of other parameters,
in particular the block size and the number of bytes per inode.
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index 4c667e1413c..7d6a24c9c76 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newfs.c,v 1.60 2007/05/15 09:35:47 thib Exp $ */
+/* $OpenBSD: newfs.c,v 1.61 2007/05/18 19:08:16 otto Exp $ */
/* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */
/*
@@ -116,7 +116,7 @@ int sectorsize; /* bytes/sector */
int realsectorsize; /* bytes/sector in hardware */
int fsize = 0; /* fragment size */
int bsize = 0; /* block size */
-int maxblkspercg = INT_MAX; /* maximum blocks per cylinder group */
+int maxfrgspercg = INT_MAX; /* maximum fragments per cylinder group */
int minfree = MINFREE; /* free space threshold */
int opt = DEFAULTOPT; /* optimization preference (space or time) */
int reqopt = -1; /* opt preference has not been specified */
@@ -205,9 +205,9 @@ main(int argc, char *argv[])
fatal("block size is %s: %s", errstr, optarg);
break;
case 'c':
- maxblkspercg = strtonum(optarg, 1, INT_MAX, &errstr);
+ maxfrgspercg = strtonum(optarg, 1, INT_MAX, &errstr);
if (errstr)
- fatal("blocks per cylinder group is %s: %s",
+ fatal("fragments per cylinder group is %s: %s",
errstr, optarg);
break;
case 'e':
@@ -668,7 +668,7 @@ usage(void)
} else {
fprintf(stderr,
"usage: %s [-Nq] [-b block-size] "
- "[-c blocks-per-cylinder-group] [-e maxbpg]\n"
+ "[-c fragments-per-cylinder-group] [-e maxbpg]\n"
"\t[-f frag-size] [-g avgfilesize] [-h avgfpdir] [-i bytes]\n"
"\t[-m free-space] [-O filesystem-format] [-o optimization]\n"
"\t[-S sector-size] [-s size] [-t fstype] special\n",