diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-12-04 08:39:00 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-12-04 08:39:00 +0000 |
commit | 8721f0fdc5583092c66c35cd6969304cf52d4d21 (patch) | |
tree | 7faa0375e2a311d3f8b39cd9cfded7ce76d28336 /sbin/newfs | |
parent | 2f0c9c64be88f777170b6671e7d4c47dee53e98e (diff) |
first cut at "newfs -t fstype device". this is very neat
Diffstat (limited to 'sbin/newfs')
-rw-r--r-- | sbin/newfs/newfs.8 | 11 | ||||
-rw-r--r-- | sbin/newfs/newfs.c | 43 | ||||
-rw-r--r-- | sbin/newfs/pathnames.h | 34 |
3 files changed, 78 insertions, 10 deletions
diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8 index a995f43eebd..dbc6c339774 100644 --- a/sbin/newfs/newfs.8 +++ b/sbin/newfs/newfs.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: newfs.8,v 1.3 1996/06/23 14:31:46 deraadt Exp $ +.\" $OpenBSD: newfs.8,v 1.4 1996/12/04 08:38:58 deraadt Exp $ .\" $NetBSD: newfs.8,v 1.12 1995/03/18 14:58:41 cgd Exp $ .\" .\" Copyright (c) 1983, 1987, 1991, 1993, 1994 @@ -60,9 +60,10 @@ .Op Fl p Ar sectors .Op Fl r Ar revolutions .Op Fl s Ar size -.Op Fl t Ar tracks +.Op Fl t Ar fstype .Op Fl u Ar sectors .Op Fl x Ar sectors +.Op Fl z Ar tracks .Ar special .Nm mount_mfs .Op Fl N @@ -226,9 +227,13 @@ They are not counted as part of the sectors/track since they are not available to the file system for data allocation. .It Fl r Ar revolutions/minute The speed of the disk in revolutions per minute. -.It Fl t Ar #tracks/cylinder +.It Fl z Ar #tracks/cylinder The number of tracks/cylinder available for data allocation by the file system. +.It Fl t Ar fstype +Set the filesystem type of which filesystem you wish to create. +.Nm newfs +will be smart enough to run the alternate newfs_XXX program instead. .It Fl u Ar sectors/track The number of sectors per track available for data allocation by the file system. diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 05b24156e2d..4c0a5b30909 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs.c,v 1.5 1996/11/24 23:46:44 millert Exp $ */ +/* $OpenBSD: newfs.c,v 1.6 1996/12/04 08:38:59 deraadt Exp $ */ /* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)newfs.c 8.8 (Berkeley) 4/18/94"; #else -static char rcsid[] = "$OpenBSD: newfs.c,v 1.5 1996/11/24 23:46:44 millert Exp $"; +static char rcsid[] = "$OpenBSD: newfs.c,v 1.6 1996/12/04 08:38:59 deraadt Exp $"; #endif #endif /* not lint */ @@ -79,6 +79,7 @@ static char rcsid[] = "$OpenBSD: newfs.c,v 1.5 1996/11/24 23:46:44 millert Exp $ #endif #include "mntopts.h" +#include "pathnames.h" struct mntopt mopts[] = { MOPT_STDOPTS, @@ -205,6 +206,9 @@ main(argc, argv) struct statfs *mp; int fsi, fso, len, n, maxpartitions; char *cp, *s1, *s2, *special, *opstring, buf[BUFSIZ]; + char *fstype = NULL; + char **saveargv = argv; + int ffs = 1; if (progname = strrchr(*argv, '/')) ++progname; @@ -222,8 +226,8 @@ main(argc, argv) opstring = mfs ? "NT:a:b:c:d:e:f:i:m:o:s:" : - "NOS:T:a:b:c:d:e:f:i:k:l:m:n:o:p:r:s:t:u:x:"; - while ((ch = getopt(argc, argv, opstring)) != EOF) + "NOS:T:a:b:c:d:e:f:i:k:l:m:n:o:p:r:s:t:u:x:z:"; + while ((ch = getopt(argc, argv, opstring)) != EOF) { switch (ch) { case 'N': Nflag = 1; @@ -313,9 +317,14 @@ main(argc, argv) if ((fssize = atoi(optarg)) <= 0) fatal("%s: bad file system size", optarg); break; - case 't': + case 'z': + if ((ntracks = atoi(optarg)) <= 0) fatal("%s: bad total tracks", optarg); + case 't': + fstype = optarg; + if (strcmp(fstype, "ffs")) + ffs = 0; break; case 'u': if ((nsectors = atoi(optarg)) <= 0) @@ -330,13 +339,33 @@ main(argc, argv) default: usage(); } + if (!ffs) + break; + } argc -= optind; argv += optind; - if (argc != 2 && (mfs || argc != 1)) + if (ffs && argc != 2 && (mfs || argc != 1)) usage(); special = argv[0]; + if (!mfs) { + char name[MAXPATHLEN]; + + if (fstype == NULL) + fstype = readlabelfs(special); + if (fstype == NULL || strcmp(fstype, "ffs")) { + snprintf(name, sizeof name, "%s/newfs_%s", _PATH_SBIN, + fstype); + saveargv[0] = name; + (void)execv(name, saveargv); + snprintf(name, sizeof name, "%s/newfs_%s", _PATH_USRSBIN, + fstype); + (void)execv(name, saveargv); + err(1, "%s not found", name); + } + } + if (mfs && !strcmp(special, "swap")) { /* * it's an MFS, mounted on "swap." fake up a label. @@ -725,8 +754,8 @@ usage() fprintf(stderr, "\t-p spare sectors per track\n"); fprintf(stderr, "\t-s file system size (sectors)\n"); fprintf(stderr, "\t-r revolutions/minute\n"); - fprintf(stderr, "\t-t tracks/cylinder\n"); fprintf(stderr, "\t-u sectors/track\n"); fprintf(stderr, "\t-x spare sectors per cylinder\n"); + fprintf(stderr, "\t-z tracks/cylinder\n"); exit(1); } diff --git a/sbin/newfs/pathnames.h b/sbin/newfs/pathnames.h new file mode 100644 index 00000000000..86ca8484504 --- /dev/null +++ b/sbin/newfs/pathnames.h @@ -0,0 +1,34 @@ +/* $OpenBSD: pathnames.h,v 1.1 1996/12/04 08:38:59 deraadt Exp $ */ +/* $NetBSD: pathnames.h,v 1.1 1996/09/11 20:27:15 christos Exp $ */ + +/* + * Copyright (c) 1996 Christos Zoulas. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christos Zoulas. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define _PATH_SBIN "/sbin" +#define _PATH_USRSBIN "/usr/sbin" |