xref: /freebsd/sbin/newfs/newfs.c (revision 61afd5bb22d787b0641523e7b9b95c964d669bd5)
1 /*
2  * Copyright (c) 1983, 1989, 1993, 1994
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *	This product includes software developed by the University of
16  *	California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33 
34 #ifndef lint
35 static char sccsid[] = "@(#)newfs.c	8.8 (Berkeley) 4/18/94";
36 #endif /* not lint */
37 
38 #ifndef lint
39 static char copyright[] =
40 "@(#) Copyright (c) 1983, 1989, 1993, 1994\n\
41 	The Regents of the University of California.  All rights reserved.\n";
42 #endif /* not lint */
43 
44 /*
45  * newfs: friendly front end to mkfs
46  */
47 #include <sys/param.h>
48 #include <sys/stat.h>
49 #include <sys/ioctl.h>
50 #include <sys/disklabel.h>
51 #include <sys/file.h>
52 #include <sys/mount.h>
53 
54 #include <ufs/ufs/dir.h>
55 #include <ufs/ffs/fs.h>
56 
57 #include <ctype.h>
58 #include <errno.h>
59 #include <paths.h>
60 #include <stdio.h>
61 #include <stdlib.h>
62 #include <string.h>
63 #include <syslog.h>
64 #include <unistd.h>
65 
66 #if __STDC__
67 #include <stdarg.h>
68 #else
69 #include <varargs.h>
70 #endif
71 
72 #include "mntopts.h"
73 
74 struct mntopt mopts[] = {
75 	MOPT_STDOPTS,
76 	MOPT_ASYNC,
77 	{ NULL },
78 };
79 
80 #if __STDC__
81 void	fatal(const char *fmt, ...);
82 #else
83 void	fatal();
84 #endif
85 
86 #define	COMPAT			/* allow non-labeled disks */
87 
88 /*
89  * The following two constants set the default block and fragment sizes.
90  * Both constants must be a power of 2 and meet the following constraints:
91  *	MINBSIZE <= DESBLKSIZE <= MAXBSIZE
92  *	sectorsize <= DESFRAGSIZE <= DESBLKSIZE
93  *	DESBLKSIZE / DESFRAGSIZE <= 8
94  */
95 #define	DFL_FRAGSIZE	1024
96 #define	DFL_BLKSIZE	8192
97 
98 /*
99  * Cylinder groups may have up to many cylinders. The actual
100  * number used depends upon how much information can be stored
101  * on a single cylinder. The default is to use 16 cylinders
102  * per group.
103  */
104 #define	DESCPG		16	/* desired fs_cpg */
105 
106 /*
107  * Once upon a time...
108  *    ROTDELAY gives the minimum number of milliseconds to initiate
109  *    another disk transfer on the same cylinder. It is used in
110  *    determining the rotationally optimal layout for disk blocks
111  *    within a file; the default of fs_rotdelay is 4ms.
112  *
113  * ...but now we make this 0 to disable the rotdelay delay because
114  * modern drives with read/write-behind achieve higher performance
115  * without the delay.
116  */
117 #define ROTDELAY	0
118 
119 /*
120  * MAXBLKPG determines the maximum number of data blocks which are
121  * placed in a single cylinder group. The default is one indirect
122  * block worth of data blocks.
123  */
124 #define MAXBLKPG(bsize)	((bsize) / sizeof(daddr_t))
125 
126 /*
127  * Each file system has a number of inodes statically allocated.
128  * We allocate one inode slot per NFPI fragments, expecting this
129  * to be far more than we will ever need.
130  */
131 #define	NFPI		4
132 
133 /*
134  * Once upon a time...
135  *    For each cylinder we keep track of the availability of blocks at different
136  *    rotational positions, so that we can lay out the data to be picked
137  *    up with minimum rotational latency.  NRPOS is the default number of
138  *    rotational positions that we distinguish.  With NRPOS of 8 the resolution
139  *    of our summary information is 2ms for a typical 3600 rpm drive.
140  *
141  * ...but now we make this 1 (which escentially disables the rotational
142  * position table because modern drives with read-ahead and write-behind do
143  * better without the rotational position table.
144  */
145 #define	NRPOS		1	/* number distinct rotational positions */
146 
147 /*
148  * About the same time as the above, we knew what went where on the disks.
149  * no longer so, so kill the code which finds the different platters too...
150  * We do this by saying one head, with a lot of sectors on it.
151  * The number of sectors are used to determine the size of a cyl-group.
152  * Kirk suggested one or two meg per "cylinder" so we say two.
153  */
154 
155 #define NTRACKS		1	/* number of heads */
156 
157 #define NSECTORS	4096	/* number of sectors */
158 
159 int	mfs;			/* run as the memory based filesystem */
160 int	Nflag;			/* run without writing file system */
161 int	Oflag;			/* format as an 4.3BSD file system */
162 int	fssize;			/* file system size */
163 int	ntracks = NTRACKS;	/* # tracks/cylinder */
164 int	nsectors = NSECTORS;	/* # sectors/track */
165 int	nphyssectors;		/* # sectors/track including spares */
166 int	secpercyl;		/* sectors per cylinder */
167 int	trackspares = -1;	/* spare sectors per track */
168 int	cylspares = -1;		/* spare sectors per cylinder */
169 int	sectorsize;		/* bytes/sector */
170 int	realsectorsize;		/* bytes/sector in hardware */
171 int	rpm;			/* revolutions/minute of drive */
172 int	interleave;		/* hardware sector interleave */
173 int	trackskew = -1;		/* sector 0 skew, per track */
174 int	headswitch;		/* head switch time, usec */
175 int	trackseek;		/* track-to-track seek, usec */
176 int	fsize = 0;		/* fragment size */
177 int	bsize = 0;		/* block size */
178 int	cpg = DESCPG;		/* cylinders/cylinder group */
179 int	cpgflg;			/* cylinders/cylinder group flag was given */
180 int	minfree = MINFREE;	/* free space threshold */
181 int	opt = DEFAULTOPT;	/* optimization preference (space or time) */
182 int	density;		/* number of bytes per inode */
183 int	maxcontig = 0;		/* max contiguous blocks to allocate */
184 int	rotdelay = ROTDELAY;	/* rotational delay between blocks */
185 int	maxbpg;			/* maximum blocks per file in a cyl group */
186 int	nrpos = NRPOS;		/* # of distinguished rotational positions */
187 int	bbsize = BBSIZE;	/* boot block size */
188 int	sbsize = SBSIZE;	/* superblock size */
189 int	mntflags = MNT_ASYNC;	/* flags to be passed to mount */
190 int	t_or_u_flag = 0;	/* user has specified -t or -u */
191 u_long	memleft;		/* virtual memory available */
192 caddr_t	membase;		/* start address of memory based filesystem */
193 char	*filename;
194 #ifdef COMPAT
195 char	*disktype;
196 int	unlabeled;
197 #endif
198 
199 char	device[MAXPATHLEN];
200 char	*progname;
201 
202 int
203 main(argc, argv)
204 	int argc;
205 	char *argv[];
206 {
207 	extern char *optarg;
208 	extern int optind;
209 	register int ch;
210 	register struct partition *pp;
211 	register struct disklabel *lp;
212 	struct disklabel *getdisklabel();
213 	struct partition oldpartition;
214 	struct stat st;
215 	struct statfs *mp;
216 	int fsi, fso, len, n;
217 	char *cp, *s1, *s2, *special, *opstring, buf[BUFSIZ];
218 #ifdef MFS
219 	struct vfsconf *vfc;
220 #endif
221 
222 	if (progname = rindex(*argv, '/'))
223 		++progname;
224 	else
225 		progname = *argv;
226 
227 	if (strstr(progname, "mfs")) {
228 		mfs = 1;
229 		Nflag++;
230 	}
231 
232 	opstring = mfs ?
233 	    "NF:T:a:b:c:d:e:f:i:m:o:s:" :
234 	    "NOS:T:a:b:c:d:e:f:i:k:l:m:n:o:p:r:s:t:u:x:";
235 	while ((ch = getopt(argc, argv, opstring)) != EOF)
236 		switch (ch) {
237 		case 'N':
238 			Nflag = 1;
239 			break;
240 		case 'O':
241 			Oflag = 1;
242 			break;
243 		case 'S':
244 			if ((sectorsize = atoi(optarg)) <= 0)
245 				fatal("%s: bad sector size", optarg);
246 			break;
247 #ifdef COMPAT
248 		case 'T':
249 			disktype = optarg;
250 			break;
251 #endif
252 		case 'F':
253 			filename = optarg;
254 			break;
255 		case 'a':
256 			if ((maxcontig = atoi(optarg)) <= 0)
257 				fatal("%s: bad maximum contiguous blocks\n",
258 				    optarg);
259 			break;
260 		case 'b':
261 			if ((bsize = atoi(optarg)) < MINBSIZE)
262 				fatal("%s: bad block size", optarg);
263 			break;
264 		case 'c':
265 			if ((cpg = atoi(optarg)) <= 0)
266 				fatal("%s: bad cylinders/group", optarg);
267 			cpgflg++;
268 			break;
269 		case 'd':
270 			if ((rotdelay = atoi(optarg)) < 0)
271 				fatal("%s: bad rotational delay\n", optarg);
272 			break;
273 		case 'e':
274 			if ((maxbpg = atoi(optarg)) <= 0)
275 		fatal("%s: bad blocks per file in a cylinder group\n",
276 				    optarg);
277 			break;
278 		case 'f':
279 			if ((fsize = atoi(optarg)) <= 0)
280 				fatal("%s: bad fragment size", optarg);
281 			break;
282 		case 'i':
283 			if ((density = atoi(optarg)) <= 0)
284 				fatal("%s: bad bytes per inode\n", optarg);
285 			break;
286 		case 'k':
287 			if ((trackskew = atoi(optarg)) < 0)
288 				fatal("%s: bad track skew", optarg);
289 			break;
290 		case 'l':
291 			if ((interleave = atoi(optarg)) <= 0)
292 				fatal("%s: bad interleave", optarg);
293 			break;
294 		case 'm':
295 			if ((minfree = atoi(optarg)) < 0 || minfree > 99)
296 				fatal("%s: bad free space %%\n", optarg);
297 			break;
298 		case 'n':
299 			if ((nrpos = atoi(optarg)) < 0)
300 				fatal("%s: bad rotational layout count\n",
301 				    optarg);
302 			if (nrpos == 0)
303 				nrpos = 1;
304 			break;
305 		case 'o':
306 			if (mfs)
307 				getmntopts(optarg, mopts, &mntflags, 0);
308 			else {
309 				if (strcmp(optarg, "space") == 0)
310 					opt = FS_OPTSPACE;
311 				else if (strcmp(optarg, "time") == 0)
312 					opt = FS_OPTTIME;
313 				else
314 	fatal("%s: unknown optimization preference: use `space' or `time'.");
315 			}
316 			break;
317 		case 'p':
318 			if ((trackspares = atoi(optarg)) < 0)
319 				fatal("%s: bad spare sectors per track",
320 				    optarg);
321 			break;
322 		case 'r':
323 			if ((rpm = atoi(optarg)) <= 0)
324 				fatal("%s: bad revolutions/minute\n", optarg);
325 			break;
326 		case 's':
327 			if ((fssize = atoi(optarg)) <= 0)
328 				fatal("%s: bad file system size", optarg);
329 			break;
330 		case 't':
331 			t_or_u_flag++;
332 			if ((ntracks = atoi(optarg)) < 0)
333 				fatal("%s: bad total tracks", optarg);
334 			break;
335 		case 'u':
336 			t_or_u_flag++;
337 			if ((nsectors = atoi(optarg)) < 0)
338 				fatal("%s: bad sectors/track", optarg);
339 			break;
340 		case 'x':
341 			if ((cylspares = atoi(optarg)) < 0)
342 				fatal("%s: bad spare sectors per cylinder",
343 				    optarg);
344 			break;
345 		case '?':
346 		default:
347 			usage();
348 		}
349 	argc -= optind;
350 	argv += optind;
351 
352 	if (argc != 2 && (mfs || argc != 1))
353 		usage();
354 
355 	special = argv[0];
356 	cp = rindex(special, '/');
357 	if (cp == 0) {
358 		/*
359 		 * No path prefix; try /dev/r%s then /dev/%s.
360 		 */
361 		(void)sprintf(device, "%sr%s", _PATH_DEV, special);
362 		if (stat(device, &st) == -1)
363 			(void)sprintf(device, "%s%s", _PATH_DEV, special);
364 		special = device;
365 	}
366 	if (Nflag) {
367 		fso = -1;
368 	} else {
369 		fso = open(special, O_WRONLY);
370 		if (fso < 0)
371 			fatal("%s: %s", special, strerror(errno));
372 
373 		/* Bail if target special is mounted */
374 		n = getmntinfo(&mp, MNT_NOWAIT);
375 		if (n == 0)
376 			fatal("%s: getmntinfo: %s", special, strerror(errno));
377 
378 		len = sizeof(_PATH_DEV) - 1;
379 		s1 = special;
380 		if (strncmp(_PATH_DEV, s1, len) == 0)
381 			s1 += len;
382 
383 		while (--n >= 0) {
384 			s2 = mp->f_mntfromname;
385 			if (strncmp(_PATH_DEV, s2, len) == 0) {
386 				s2 += len - 1;
387 				*s2 = 'r';
388 			}
389 			if (strcmp(s1, s2) == 0 || strcmp(s1, &s2[1]) == 0)
390 				fatal("%s is mounted on %s",
391 				    special, mp->f_mntonname);
392 			++mp;
393 		}
394 	}
395 	if (mfs && disktype != NULL) {
396 		lp = (struct disklabel *)getdiskbyname(disktype);
397 		if (lp == NULL)
398 			fatal("%s: unknown disk type", disktype);
399 		pp = &lp->d_partitions[1];
400 	} else {
401 		fsi = open(special, O_RDONLY);
402 		if (fsi < 0)
403 			fatal("%s: %s", special, strerror(errno));
404 		if (fstat(fsi, &st) < 0)
405 			fatal("%s: %s", special, strerror(errno));
406 		if ((st.st_mode & S_IFMT) != S_IFCHR && !mfs)
407 			printf("%s: %s: not a character-special device\n",
408 			    progname, special);
409 		cp = index(argv[0], '\0') - 1;
410 		if (cp == 0 || (*cp < 'a' || *cp > 'h') && !isdigit(*cp))
411 			fatal("%s: can't figure out file system partition",
412 			    argv[0]);
413 #ifdef COMPAT
414 		if (!mfs && disktype == NULL)
415 			disktype = argv[1];
416 #endif
417 		lp = getdisklabel(special, fsi);
418 		if (isdigit(*cp))
419 			pp = &lp->d_partitions[0];
420 		else
421 			pp = &lp->d_partitions[*cp - 'a'];
422 		if (pp->p_size == 0)
423 			fatal("%s: `%c' partition is unavailable",
424 			    argv[0], *cp);
425 		if (pp->p_fstype == FS_BOOT)
426 			fatal("%s: `%c' partition overlaps boot program",
427 			      argv[0], *cp);
428 	}
429 	if (fssize == 0)
430 		fssize = pp->p_size;
431 	if (fssize > pp->p_size && !mfs)
432 	       fatal("%s: maximum file system size on the `%c' partition is %d",
433 			argv[0], *cp, pp->p_size);
434 	if (rpm == 0) {
435 		rpm = lp->d_rpm;
436 		if (rpm <= 0)
437 			rpm = 3600;
438 	}
439 	if (ntracks == 0) {
440 		ntracks = lp->d_ntracks;
441 		if (ntracks <= 0)
442 			fatal("%s: no default #tracks", argv[0]);
443 	}
444 	if (nsectors == 0) {
445 		nsectors = lp->d_nsectors;
446 		if (nsectors <= 0)
447 			fatal("%s: no default #sectors/track", argv[0]);
448 	}
449 	if (sectorsize == 0) {
450 		sectorsize = lp->d_secsize;
451 		if (sectorsize <= 0)
452 			fatal("%s: no default sector size", argv[0]);
453 	}
454 	if (trackskew == -1) {
455 		trackskew = lp->d_trackskew;
456 		if (trackskew < 0)
457 			trackskew = 0;
458 	}
459 	if (interleave == 0) {
460 		interleave = lp->d_interleave;
461 		if (interleave <= 0)
462 			interleave = 1;
463 	}
464 	if (fsize == 0) {
465 		fsize = pp->p_fsize;
466 		if (fsize <= 0)
467 			fsize = MAX(DFL_FRAGSIZE, lp->d_secsize);
468 	}
469 	if (bsize == 0) {
470 		bsize = pp->p_frag * pp->p_fsize;
471 		if (bsize <= 0)
472 			bsize = MIN(DFL_BLKSIZE, 8 * fsize);
473 	}
474 	/*
475 	 * Maxcontig sets the default for the maximum number of blocks
476 	 * that may be allocated sequentially. With filesystem clustering
477 	 * it is possible to allocate contiguous blocks up to the maximum
478 	 * transfer size permitted by the controller or buffering.
479 	 */
480 	if (maxcontig == 0)
481 		maxcontig = MAX(1, MAXPHYS / bsize - 1);
482 	if (density == 0)
483 		density = NFPI * fsize;
484 	if (minfree < MINFREE && opt != FS_OPTSPACE) {
485 		fprintf(stderr, "Warning: changing optimization to space ");
486 		fprintf(stderr, "because minfree is less than %d%%\n", MINFREE);
487 		opt = FS_OPTSPACE;
488 	}
489 	if (trackspares == -1) {
490 		trackspares = lp->d_sparespertrack;
491 		if (trackspares < 0)
492 			trackspares = 0;
493 	}
494 	nphyssectors = nsectors + trackspares;
495 	if (cylspares == -1) {
496 		cylspares = lp->d_sparespercyl;
497 		if (cylspares < 0)
498 			cylspares = 0;
499 	}
500 	secpercyl = nsectors * ntracks - cylspares;
501 	/*
502 	 * Only complain if -t or -u have been specified; the default
503 	 * case (4096 sectors per cylinder) is intented to disagree
504 	 * with the disklabel.
505 	 */
506 	if (t_or_u_flag && secpercyl != lp->d_secpercyl)
507 		fprintf(stderr, "%s (%d) %s (%lu)\n",
508 			"Warning: calculated sectors per cylinder", secpercyl,
509 			"disagrees with disk label", lp->d_secpercyl);
510 	if (maxbpg == 0)
511 		maxbpg = MAXBLKPG(bsize);
512 	headswitch = lp->d_headswitch;
513 	trackseek = lp->d_trkseek;
514 #ifdef notdef /* label may be 0 if faked up by kernel */
515 	bbsize = lp->d_bbsize;
516 	sbsize = lp->d_sbsize;
517 #endif
518 	oldpartition = *pp;
519 #ifdef tahoe
520 	realsectorsize = sectorsize;
521 	if (sectorsize != DEV_BSIZE) {		/* XXX */
522 		int secperblk = DEV_BSIZE / sectorsize;
523 
524 		sectorsize = DEV_BSIZE;
525 		nsectors /= secperblk;
526 		nphyssectors /= secperblk;
527 		secpercyl /= secperblk;
528 		fssize /= secperblk;
529 		pp->p_size /= secperblk;
530 	}
531 #else
532 	realsectorsize = sectorsize;
533 	if (sectorsize != DEV_BSIZE) {		/* XXX */
534 		int secperblk = sectorsize / DEV_BSIZE;
535 
536 		sectorsize = DEV_BSIZE;
537 		nsectors *= secperblk;
538 		nphyssectors *= secperblk;
539 		secpercyl *= secperblk;
540 		fssize *= secperblk;
541 		pp->p_size *= secperblk;
542 	}
543 #endif
544 	mkfs(pp, special, fsi, fso);
545 #ifdef tahoe
546 	if (realsectorsize != DEV_BSIZE)
547 		pp->p_size *= DEV_BSIZE / realsectorsize;
548 #else
549 	if (realsectorsize != DEV_BSIZE)
550 		pp->p_size /= realsectorsize /DEV_BSIZE;
551 #endif
552 	if (!Nflag)
553 		close(fso);
554 	close(fsi);
555 #ifdef MFS
556 	if (mfs) {
557 		struct mfs_args args;
558 
559 		sprintf(buf, "mfs:%d", getpid());
560 		args.fspec = buf;
561 		args.export.ex_root = -2;
562 		if (mntflags & MNT_RDONLY)
563 			args.export.ex_flags = MNT_EXRDONLY;
564 		else
565 			args.export.ex_flags = 0;
566 		args.base = membase;
567 		args.size = fssize * sectorsize;
568 
569 		vfc = getvfsbyname("mfs");
570 		if(!vfc && vfsisloadable("mfs")) {
571 			if(vfsload("mfs")) {
572 				err(1, "vfsload(mfs)");
573 			}
574 			endvfsent();	/* flush cache */
575 			vfc = getvfsbyname("mfs");
576 		}
577 
578 		if (mount(vfc ? vfc->vfc_index : MOUNT_MFS, argv[1], mntflags,
579 				&args) < 0)
580 			fatal("%s: %s", argv[1], strerror(errno));
581 		if(filename) {
582 			munmap(membase,fssize * sectorsize);
583 		}
584 	}
585 #endif
586 	exit(0);
587 }
588 
589 #ifdef COMPAT
590 char lmsg[] = "%s: can't read disk label; disk type must be specified";
591 #else
592 char lmsg[] = "%s: can't read disk label";
593 #endif
594 
595 struct disklabel *
596 getdisklabel(s, fd)
597 	char *s;
598 	int fd;
599 {
600 	static struct disklabel lab;
601 
602 	if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
603 #ifdef COMPAT
604 		if (disktype) {
605 			struct disklabel *lp, *getdiskbyname();
606 
607 			unlabeled++;
608 			lp = getdiskbyname(disktype);
609 			if (lp == NULL)
610 				fatal("%s: unknown disk type", disktype);
611 			return (lp);
612 		}
613 #endif
614 		warn("ioctl (GDINFO)");
615 		fatal(lmsg, s);
616 	}
617 	return (&lab);
618 }
619 
620 /*VARARGS*/
621 void
622 #if __STDC__
623 fatal(const char *fmt, ...)
624 #else
625 fatal(fmt, va_alist)
626 	char *fmt;
627 	va_dcl
628 #endif
629 {
630 	va_list ap;
631 
632 #if __STDC__
633 	va_start(ap, fmt);
634 #else
635 	va_start(ap);
636 #endif
637 	if (fcntl(STDERR_FILENO, F_GETFL) < 0) {
638 		openlog(progname, LOG_CONS, LOG_DAEMON);
639 		vsyslog(LOG_ERR, fmt, ap);
640 		closelog();
641 	} else {
642 		vwarnx(fmt, ap);
643 	}
644 	va_end(ap);
645 	exit(1);
646 	/*NOTREACHED*/
647 }
648 
649 usage()
650 {
651 	if (mfs) {
652 		fprintf(stderr,
653 		    "usage: %s [ -fsoptions ] special-device mount-point\n",
654 			progname);
655 	} else
656 		fprintf(stderr,
657 		    "usage: %s [ -fsoptions ] special-device%s\n",
658 		    progname,
659 #ifdef COMPAT
660 		    " [device-type]");
661 #else
662 		    "");
663 #endif
664 	fprintf(stderr, "where fsoptions are:\n");
665 	fprintf(stderr,
666 	    "\t-N do not create file system, just print out parameters\n");
667 	fprintf(stderr, "\t-O create a 4.3BSD format filesystem\n");
668 	fprintf(stderr, "\t-S sector size\n");
669 #ifdef COMPAT
670 	fprintf(stderr, "\t-T disktype\n");
671 #endif
672 	fprintf(stderr, "\t-a maximum contiguous blocks\n");
673 	fprintf(stderr, "\t-b block size\n");
674 	fprintf(stderr, "\t-c cylinders/group\n");
675 	fprintf(stderr, "\t-d rotational delay between contiguous blocks\n");
676 	fprintf(stderr, "\t-e maximum blocks per file in a cylinder group\n");
677 	fprintf(stderr, "\t-f frag size\n");
678 	fprintf(stderr, "\t-i number of bytes per inode\n");
679 	fprintf(stderr, "\t-k sector 0 skew, per track\n");
680 	fprintf(stderr, "\t-l hardware sector interleave\n");
681 	fprintf(stderr, "\t-m minimum free space %%\n");
682 	fprintf(stderr, "\t-n number of distinguished rotational positions\n");
683 	fprintf(stderr, "\t-o optimization preference (`space' or `time')\n");
684 	fprintf(stderr, "\t-p spare sectors per track\n");
685 	fprintf(stderr, "\t-s file system size (sectors)\n");
686 	fprintf(stderr, "\t-r revolutions/minute\n");
687 	fprintf(stderr, "\t-t tracks/cylinder\n");
688 	fprintf(stderr, "\t-u sectors/track\n");
689 	fprintf(stderr, "\t-x spare sectors per cylinder\n");
690 	exit(1);
691 }
692