diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-05-19 20:12:51 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-05-19 20:12:51 +0000 |
commit | d1d03717316dca4efc8d465aadf2eeffe03143ef (patch) | |
tree | 94ae4e04b827eeb4c1686310b82416ace311b834 | |
parent | 258e99dd6167909ae0237a8eb4614f17bdaf6a4c (diff) |
Now that the amd64 floppy and cd image -c setting have been fixed,
recommit the -c changes. For now, we warn only if we cannot honour -c.
ok millert@ deraadt@
-rw-r--r-- | sbin/newfs/mkfs.c | 32 | ||||
-rw-r--r-- | sbin/newfs/newfs.8 | 10 | ||||
-rw-r--r-- | sbin/newfs/newfs.c | 10 |
3 files changed, 24 insertions, 28 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index c19e0cfd755..317260128a0 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.62 2007/05/19 01:28:15 deraadt Exp $ */ +/* $OpenBSD: mkfs.c,v 1.63 2007/05/19 20:12:50 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) + warnx("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 c178a5af5a6..e926e1d5db4 100644 --- a/sbin/newfs/newfs.8 +++ b/sbin/newfs/newfs.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: newfs.8,v 1.59 2007/05/19 11:16:22 jmc Exp $ +.\" $OpenBSD: newfs.8,v 1.60 2007/05/19 20:12:50 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 91c6827c774..8856ba4b726 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs.c,v 1.62 2007/05/19 01:28:15 deraadt Exp $ */ +/* $OpenBSD: newfs.c,v 1.63 2007/05/19 20:12:50 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", |