summaryrefslogtreecommitdiff
path: root/sbin/newfs/mkfs.c
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 /sbin/newfs/mkfs.c
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@
Diffstat (limited to 'sbin/newfs/mkfs.c')
-rw-r--r--sbin/newfs/mkfs.c32
1 files changed, 14 insertions, 18 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