xref: /freebsd/sbin/newfs/newfs.c (revision afe61c15161c324a7af299a9b8457aba5afc92db)
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  * ROTDELAY gives the minimum number of milliseconds to initiate
108  * another disk transfer on the same cylinder. It is used in
109  * determining the rotationally optimal layout for disk blocks
110  * within a file; the default of fs_rotdelay is 4ms.
111  */
112 #define ROTDELAY	4
113 
114 /*
115  * MAXBLKPG determines the maximum number of data blocks which are
116  * placed in a single cylinder group. The default is one indirect
117  * block worth of data blocks.
118  */
119 #define MAXBLKPG(bsize)	((bsize) / sizeof(daddr_t))
120 
121 /*
122  * Each file system has a number of inodes statically allocated.
123  * We allocate one inode slot per NFPI fragments, expecting this
124  * to be far more than we will ever need.
125  */
126 #define	NFPI		4
127 
128 /*
129  * For each cylinder we keep track of the availability of blocks at different
130  * rotational positions, so that we can lay out the data to be picked
131  * up with minimum rotational latency.  NRPOS is the default number of
132  * rotational positions that we distinguish.  With NRPOS of 8 the resolution
133  * of our summary information is 2ms for a typical 3600 rpm drive.
134  */
135 #define	NRPOS		8	/* number distinct rotational positions */
136 
137 
138 int	mfs;			/* run as the memory based filesystem */
139 int	Nflag;			/* run without writing file system */
140 int	Oflag;			/* format as an 4.3BSD file system */
141 int	fssize;			/* file system size */
142 int	ntracks;		/* # tracks/cylinder */
143 int	nsectors;		/* # sectors/track */
144 int	nphyssectors;		/* # sectors/track including spares */
145 int	secpercyl;		/* sectors per cylinder */
146 int	trackspares = -1;	/* spare sectors per track */
147 int	cylspares = -1;		/* spare sectors per cylinder */
148 int	sectorsize;		/* bytes/sector */
149 #ifdef tahoe
150 int	realsectorsize;		/* bytes/sector in hardware */
151 #endif
152 int	rpm;			/* revolutions/minute of drive */
153 int	interleave;		/* hardware sector interleave */
154 int	trackskew = -1;		/* sector 0 skew, per track */
155 int	headswitch;		/* head switch time, usec */
156 int	trackseek;		/* track-to-track seek, usec */
157 int	fsize = 0;		/* fragment size */
158 int	bsize = 0;		/* block size */
159 int	cpg = DESCPG;		/* cylinders/cylinder group */
160 int	cpgflg;			/* cylinders/cylinder group flag was given */
161 int	minfree = MINFREE;	/* free space threshold */
162 int	opt = DEFAULTOPT;	/* optimization preference (space or time) */
163 int	density;		/* number of bytes per inode */
164 int	maxcontig = 0;		/* max contiguous blocks to allocate */
165 int	rotdelay = ROTDELAY;	/* rotational delay between blocks */
166 int	maxbpg;			/* maximum blocks per file in a cyl group */
167 int	nrpos = NRPOS;		/* # of distinguished rotational positions */
168 int	bbsize = BBSIZE;	/* boot block size */
169 int	sbsize = SBSIZE;	/* superblock size */
170 int	mntflags = MNT_ASYNC;	/* flags to be passed to mount */
171 u_long	memleft;		/* virtual memory available */
172 caddr_t	membase;		/* start address of memory based filesystem */
173 #ifdef COMPAT
174 char	*disktype;
175 int	unlabeled;
176 #endif
177 
178 char	device[MAXPATHLEN];
179 char	*progname;
180 
181 int
182 main(argc, argv)
183 	int argc;
184 	char *argv[];
185 {
186 	extern char *optarg;
187 	extern int optind;
188 	register int ch;
189 	register struct partition *pp;
190 	register struct disklabel *lp;
191 	struct disklabel *getdisklabel();
192 	struct partition oldpartition;
193 	struct stat st;
194 	struct statfs *mp;
195 	int fsi, fso, len, n;
196 	char *cp, *s1, *s2, *special, *opstring, buf[BUFSIZ];
197 
198 	if (progname = rindex(*argv, '/'))
199 		++progname;
200 	else
201 		progname = *argv;
202 
203 	if (strstr(progname, "mfs")) {
204 		mfs = 1;
205 		Nflag++;
206 	}
207 
208 	opstring = mfs ?
209 	    "NT:a:b:c:d:e:f:i:m:o:s:" :
210 	    "NOS:T:a:b:c:d:e:f:i:k:l:m:n:o:p:r:s:t:u:x:";
211 	while ((ch = getopt(argc, argv, opstring)) != EOF)
212 		switch (ch) {
213 		case 'N':
214 			Nflag = 1;
215 			break;
216 		case 'O':
217 			Oflag = 1;
218 			break;
219 		case 'S':
220 			if ((sectorsize = atoi(optarg)) <= 0)
221 				fatal("%s: bad sector size", optarg);
222 			break;
223 #ifdef COMPAT
224 		case 'T':
225 			disktype = optarg;
226 			break;
227 #endif
228 		case 'a':
229 			if ((maxcontig = atoi(optarg)) <= 0)
230 				fatal("%s: bad maximum contiguous blocks\n",
231 				    optarg);
232 			break;
233 		case 'b':
234 			if ((bsize = atoi(optarg)) < MINBSIZE)
235 				fatal("%s: bad block size", optarg);
236 			break;
237 		case 'c':
238 			if ((cpg = atoi(optarg)) <= 0)
239 				fatal("%s: bad cylinders/group", optarg);
240 			cpgflg++;
241 			break;
242 		case 'd':
243 			if ((rotdelay = atoi(optarg)) < 0)
244 				fatal("%s: bad rotational delay\n", optarg);
245 			break;
246 		case 'e':
247 			if ((maxbpg = atoi(optarg)) <= 0)
248 		fatal("%s: bad blocks per file in a cylinder group\n",
249 				    optarg);
250 			break;
251 		case 'f':
252 			if ((fsize = atoi(optarg)) <= 0)
253 				fatal("%s: bad fragment size", optarg);
254 			break;
255 		case 'i':
256 			if ((density = atoi(optarg)) <= 0)
257 				fatal("%s: bad bytes per inode\n", optarg);
258 			break;
259 		case 'k':
260 			if ((trackskew = atoi(optarg)) < 0)
261 				fatal("%s: bad track skew", optarg);
262 			break;
263 		case 'l':
264 			if ((interleave = atoi(optarg)) <= 0)
265 				fatal("%s: bad interleave", optarg);
266 			break;
267 		case 'm':
268 			if ((minfree = atoi(optarg)) < 0 || minfree > 99)
269 				fatal("%s: bad free space %%\n", optarg);
270 			break;
271 		case 'n':
272 			if ((nrpos = atoi(optarg)) <= 0)
273 				fatal("%s: bad rotational layout count\n",
274 				    optarg);
275 			break;
276 		case 'o':
277 			if (mfs)
278 				getmntopts(optarg, mopts, &mntflags);
279 			else {
280 				if (strcmp(optarg, "space") == 0)
281 					opt = FS_OPTSPACE;
282 				else if (strcmp(optarg, "time") == 0)
283 					opt = FS_OPTTIME;
284 				else
285 	fatal("%s: unknown optimization preference: use `space' or `time'.");
286 			}
287 			break;
288 		case 'p':
289 			if ((trackspares = atoi(optarg)) < 0)
290 				fatal("%s: bad spare sectors per track",
291 				    optarg);
292 			break;
293 		case 'r':
294 			if ((rpm = atoi(optarg)) <= 0)
295 				fatal("%s: bad revolutions/minute\n", optarg);
296 			break;
297 		case 's':
298 			if ((fssize = atoi(optarg)) <= 0)
299 				fatal("%s: bad file system size", optarg);
300 			break;
301 		case 't':
302 			if ((ntracks = atoi(optarg)) <= 0)
303 				fatal("%s: bad total tracks", optarg);
304 			break;
305 		case 'u':
306 			if ((nsectors = atoi(optarg)) <= 0)
307 				fatal("%s: bad sectors/track", optarg);
308 			break;
309 		case 'x':
310 			if ((cylspares = atoi(optarg)) < 0)
311 				fatal("%s: bad spare sectors per cylinder",
312 				    optarg);
313 			break;
314 		case '?':
315 		default:
316 			usage();
317 		}
318 	argc -= optind;
319 	argv += optind;
320 
321 	if (argc != 2 && (mfs || argc != 1))
322 		usage();
323 
324 	special = argv[0];
325 	cp = rindex(special, '/');
326 	if (cp == 0) {
327 		/*
328 		 * No path prefix; try /dev/r%s then /dev/%s.
329 		 */
330 		(void)sprintf(device, "%sr%s", _PATH_DEV, special);
331 		if (stat(device, &st) == -1)
332 			(void)sprintf(device, "%s%s", _PATH_DEV, special);
333 		special = device;
334 	}
335 	if (Nflag) {
336 		fso = -1;
337 	} else {
338 		fso = open(special, O_WRONLY);
339 		if (fso < 0)
340 			fatal("%s: %s", special, strerror(errno));
341 
342 		/* Bail if target special is mounted */
343 		n = getmntinfo(&mp, MNT_NOWAIT);
344 		if (n == 0)
345 			fatal("%s: getmntinfo: %s", special, strerror(errno));
346 
347 		len = sizeof(_PATH_DEV) - 1;
348 		s1 = special;
349 		if (strncmp(_PATH_DEV, s1, len) == 0)
350 			s1 += len;
351 
352 		while (--n >= 0) {
353 			s2 = mp->f_mntfromname;
354 			if (strncmp(_PATH_DEV, s2, len) == 0) {
355 				s2 += len - 1;
356 				*s2 = 'r';
357 			}
358 			if (strcmp(s1, s2) == 0 || strcmp(s1, &s2[1]) == 0)
359 				fatal("%s is mounted on %s",
360 				    special, mp->f_mntonname);
361 			++mp;
362 		}
363 	}
364 	if (mfs && disktype != NULL) {
365 		lp = (struct disklabel *)getdiskbyname(disktype);
366 		if (lp == NULL)
367 			fatal("%s: unknown disk type", disktype);
368 		pp = &lp->d_partitions[1];
369 	} else {
370 		fsi = open(special, O_RDONLY);
371 		if (fsi < 0)
372 			fatal("%s: %s", special, strerror(errno));
373 		if (fstat(fsi, &st) < 0)
374 			fatal("%s: %s", special, strerror(errno));
375 		if ((st.st_mode & S_IFMT) != S_IFCHR && !mfs)
376 			printf("%s: %s: not a character-special device\n",
377 			    progname, special);
378 		cp = index(argv[0], '\0') - 1;
379 		if (cp == 0 || (*cp < 'a' || *cp > 'h') && !isdigit(*cp))
380 			fatal("%s: can't figure out file system partition",
381 			    argv[0]);
382 #ifdef COMPAT
383 		if (!mfs && disktype == NULL)
384 			disktype = argv[1];
385 #endif
386 		lp = getdisklabel(special, fsi);
387 		if (isdigit(*cp))
388 			pp = &lp->d_partitions[0];
389 		else
390 			pp = &lp->d_partitions[*cp - 'a'];
391 		if (pp->p_size == 0)
392 			fatal("%s: `%c' partition is unavailable",
393 			    argv[0], *cp);
394 		if (pp->p_fstype == FS_BOOT)
395 			fatal("%s: `%c' partition overlaps boot program",
396 			      argv[0], *cp);
397 	}
398 	if (fssize == 0)
399 		fssize = pp->p_size;
400 	if (fssize > pp->p_size && !mfs)
401 	       fatal("%s: maximum file system size on the `%c' partition is %d",
402 			argv[0], *cp, pp->p_size);
403 	if (rpm == 0) {
404 		rpm = lp->d_rpm;
405 		if (rpm <= 0)
406 			rpm = 3600;
407 	}
408 	if (ntracks == 0) {
409 		ntracks = lp->d_ntracks;
410 		if (ntracks <= 0)
411 			fatal("%s: no default #tracks", argv[0]);
412 	}
413 	if (nsectors == 0) {
414 		nsectors = lp->d_nsectors;
415 		if (nsectors <= 0)
416 			fatal("%s: no default #sectors/track", argv[0]);
417 	}
418 	if (sectorsize == 0) {
419 		sectorsize = lp->d_secsize;
420 		if (sectorsize <= 0)
421 			fatal("%s: no default sector size", argv[0]);
422 	}
423 	if (trackskew == -1) {
424 		trackskew = lp->d_trackskew;
425 		if (trackskew < 0)
426 			trackskew = 0;
427 	}
428 	if (interleave == 0) {
429 		interleave = lp->d_interleave;
430 		if (interleave <= 0)
431 			interleave = 1;
432 	}
433 	if (fsize == 0) {
434 		fsize = pp->p_fsize;
435 		if (fsize <= 0)
436 			fsize = MAX(DFL_FRAGSIZE, lp->d_secsize);
437 	}
438 	if (bsize == 0) {
439 		bsize = pp->p_frag * pp->p_fsize;
440 		if (bsize <= 0)
441 			bsize = MIN(DFL_BLKSIZE, 8 * fsize);
442 	}
443 	/*
444 	 * Maxcontig sets the default for the maximum number of blocks
445 	 * that may be allocated sequentially. With filesystem clustering
446 	 * it is possible to allocate contiguous blocks up to the maximum
447 	 * transfer size permitted by the controller or buffering.
448 	 */
449 	if (maxcontig == 0)
450 		maxcontig = MAX(1, MIN(MAXPHYS, MAXBSIZE) / bsize - 1);
451 	if (density == 0)
452 		density = NFPI * fsize;
453 	if (minfree < MINFREE && opt != FS_OPTSPACE) {
454 		fprintf(stderr, "Warning: changing optimization to space ");
455 		fprintf(stderr, "because minfree is less than %d%%\n", MINFREE);
456 		opt = FS_OPTSPACE;
457 	}
458 	if (trackspares == -1) {
459 		trackspares = lp->d_sparespertrack;
460 		if (trackspares < 0)
461 			trackspares = 0;
462 	}
463 	nphyssectors = nsectors + trackspares;
464 	if (cylspares == -1) {
465 		cylspares = lp->d_sparespercyl;
466 		if (cylspares < 0)
467 			cylspares = 0;
468 	}
469 	secpercyl = nsectors * ntracks - cylspares;
470 	if (secpercyl != lp->d_secpercyl)
471 		fprintf(stderr, "%s (%d) %s (%lu)\n",
472 			"Warning: calculated sectors per cylinder", secpercyl,
473 			"disagrees with disk label", lp->d_secpercyl);
474 	if (maxbpg == 0)
475 		maxbpg = MAXBLKPG(bsize);
476 	headswitch = lp->d_headswitch;
477 	trackseek = lp->d_trkseek;
478 #ifdef notdef /* label may be 0 if faked up by kernel */
479 	bbsize = lp->d_bbsize;
480 	sbsize = lp->d_sbsize;
481 #endif
482 	oldpartition = *pp;
483 #ifdef tahoe
484 	realsectorsize = sectorsize;
485 	if (sectorsize != DEV_BSIZE) {		/* XXX */
486 		int secperblk = DEV_BSIZE / sectorsize;
487 
488 		sectorsize = DEV_BSIZE;
489 		nsectors /= secperblk;
490 		nphyssectors /= secperblk;
491 		secpercyl /= secperblk;
492 		fssize /= secperblk;
493 		pp->p_size /= secperblk;
494 	}
495 #endif
496 	mkfs(pp, special, fsi, fso);
497 #ifdef tahoe
498 	if (realsectorsize != DEV_BSIZE)
499 		pp->p_size *= DEV_BSIZE / realsectorsize;
500 #endif
501 	if (!Nflag && bcmp(pp, &oldpartition, sizeof(oldpartition)))
502 		rewritelabel(special, fso, lp);
503 	if (!Nflag)
504 		close(fso);
505 	close(fsi);
506 #ifdef MFS
507 	if (mfs) {
508 		struct mfs_args args;
509 
510 		sprintf(buf, "mfs:%d", getpid());
511 		args.fspec = buf;
512 		args.export.ex_root = -2;
513 		if (mntflags & MNT_RDONLY)
514 			args.export.ex_flags = MNT_EXRDONLY;
515 		else
516 			args.export.ex_flags = 0;
517 		args.base = membase;
518 		args.size = fssize * sectorsize;
519 		if (mount(MOUNT_MFS, argv[1], mntflags, &args) < 0)
520 			fatal("%s: %s", argv[1], strerror(errno));
521 	}
522 #endif
523 	exit(0);
524 }
525 
526 #ifdef COMPAT
527 char lmsg[] = "%s: can't read disk label; disk type must be specified";
528 #else
529 char lmsg[] = "%s: can't read disk label";
530 #endif
531 
532 struct disklabel *
533 getdisklabel(s, fd)
534 	char *s;
535 	int fd;
536 {
537 	static struct disklabel lab;
538 
539 	if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
540 #ifdef COMPAT
541 		if (disktype) {
542 			struct disklabel *lp, *getdiskbyname();
543 
544 			unlabeled++;
545 			lp = getdiskbyname(disktype);
546 			if (lp == NULL)
547 				fatal("%s: unknown disk type", disktype);
548 			return (lp);
549 		}
550 #endif
551 		warn("ioctl (GDINFO)");
552 		fatal(lmsg, s);
553 	}
554 	return (&lab);
555 }
556 
557 rewritelabel(s, fd, lp)
558 	char *s;
559 	int fd;
560 	register struct disklabel *lp;
561 {
562 #ifdef COMPAT
563 	if (unlabeled)
564 		return;
565 #endif
566 	lp->d_checksum = 0;
567 	lp->d_checksum = dkcksum(lp);
568 	if (ioctl(fd, DIOCWDINFO, (char *)lp) < 0) {
569 		warn("ioctl (WDINFO)");
570 		fatal("%s: can't rewrite disk label", s);
571 	}
572 #if vax
573 	if (lp->d_type == DTYPE_SMD && lp->d_flags & D_BADSECT) {
574 		register i;
575 		int cfd;
576 		daddr_t alt;
577 		char specname[64];
578 		char blk[1024];
579 		char *cp;
580 
581 		/*
582 		 * Make name for 'c' partition.
583 		 */
584 		strcpy(specname, s);
585 		cp = specname + strlen(specname) - 1;
586 		if (!isdigit(*cp))
587 			*cp = 'c';
588 		cfd = open(specname, O_WRONLY);
589 		if (cfd < 0)
590 			fatal("%s: %s", specname, strerror(errno));
591 		bzero(blk, sizeof(blk));
592 		*(struct disklabel *)(blk + LABELOFFSET) = *lp;
593 		alt = lp->d_ncylinders * lp->d_secpercyl - lp->d_nsectors;
594 		for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) {
595 			if (lseek(cfd, (off_t)(alt + i) * lp->d_secsize,
596 			    L_SET) == -1)
597 				fatal("lseek to badsector area: %s",
598 				    strerror(errno));
599 			if (write(cfd, blk, lp->d_secsize) < lp->d_secsize)
600 				warn("alternate label %d write", i/2);
601 		}
602 		close(cfd);
603 	}
604 #endif
605 }
606 
607 /*VARARGS*/
608 void
609 #if __STDC__
610 fatal(const char *fmt, ...)
611 #else
612 fatal(fmt, va_alist)
613 	char *fmt;
614 	va_dcl
615 #endif
616 {
617 	va_list ap;
618 
619 #if __STDC__
620 	va_start(ap, fmt);
621 #else
622 	va_start(ap);
623 #endif
624 	if (fcntl(STDERR_FILENO, F_GETFL) < 0) {
625 		openlog(progname, LOG_CONS, LOG_DAEMON);
626 		vsyslog(LOG_ERR, fmt, ap);
627 		closelog();
628 	} else {
629 		vwarnx(fmt, ap);
630 	}
631 	va_end(ap);
632 	exit(1);
633 	/*NOTREACHED*/
634 }
635 
636 usage()
637 {
638 	if (mfs) {
639 		fprintf(stderr,
640 		    "usage: %s [ -fsoptions ] special-device mount-point\n",
641 			progname);
642 	} else
643 		fprintf(stderr,
644 		    "usage: %s [ -fsoptions ] special-device%s\n",
645 		    progname,
646 #ifdef COMPAT
647 		    " [device-type]");
648 #else
649 		    "");
650 #endif
651 	fprintf(stderr, "where fsoptions are:\n");
652 	fprintf(stderr,
653 	    "\t-N do not create file system, just print out parameters\n");
654 	fprintf(stderr, "\t-O create a 4.3BSD format filesystem\n");
655 	fprintf(stderr, "\t-S sector size\n");
656 #ifdef COMPAT
657 	fprintf(stderr, "\t-T disktype\n");
658 #endif
659 	fprintf(stderr, "\t-a maximum contiguous blocks\n");
660 	fprintf(stderr, "\t-b block size\n");
661 	fprintf(stderr, "\t-c cylinders/group\n");
662 	fprintf(stderr, "\t-d rotational delay between contiguous blocks\n");
663 	fprintf(stderr, "\t-e maximum blocks per file in a cylinder group\n");
664 	fprintf(stderr, "\t-f frag size\n");
665 	fprintf(stderr, "\t-i number of bytes per inode\n");
666 	fprintf(stderr, "\t-k sector 0 skew, per track\n");
667 	fprintf(stderr, "\t-l hardware sector interleave\n");
668 	fprintf(stderr, "\t-m minimum free space %%\n");
669 	fprintf(stderr, "\t-n number of distinguished rotational positions\n");
670 	fprintf(stderr, "\t-o optimization preference (`space' or `time')\n");
671 	fprintf(stderr, "\t-p spare sectors per track\n");
672 	fprintf(stderr, "\t-s file system size (sectors)\n");
673 	fprintf(stderr, "\t-r revolutions/minute\n");
674 	fprintf(stderr, "\t-t tracks/cylinder\n");
675 	fprintf(stderr, "\t-u sectors/track\n");
676 	fprintf(stderr, "\t-x spare sectors per cylinder\n");
677 	exit(1);
678 }
679