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