date and time created 92/07/05 14:15:17 by bostic
[unix-history] / usr / src / sbin / newfs / newfs.c
CommitLineData
c018628f 1/*
ec7b02f7
KM
2 * Copyright (c) 1983, 1989 The Regents of the University of California.
3 * All rights reserved.
4 *
70ab3c27 5 * %sccs.include.redist.c%
c018628f
DF
6 */
7
8#ifndef lint
932690ab 9static char sccsid[] = "@(#)newfs.c 6.31 (Berkeley) %G%";
ec7b02f7 10#endif /* not lint */
c018628f 11
a54c0b3f 12#ifndef lint
ec7b02f7
KM
13char copyright[] =
14"@(#) Copyright (c) 1983, 1989 Regents of the University of California.\n\
15 All rights reserved.\n";
16#endif /* not lint */
a54c0b3f
SL
17
18/*
c6003316 19 * newfs: friendly front end to mkfs
a54c0b3f
SL
20 */
21#include <sys/param.h>
22#include <sys/stat.h>
8485bb11
KM
23#include <sys/ioctl.h>
24#include <sys/disklabel.h>
25#include <sys/file.h>
ec7b02f7 26#include <sys/mount.h>
558b3a30
KB
27#include <ufs/ufs/dir.h>
28#include <ufs/ffs/fs.h>
a54c0b3f 29
fcc01f65 30#include <errno.h>
e99c53de 31#if __STDC__
fcc01f65 32#include <stdarg.h>
e99c53de
CT
33#else
34#include <varargs.h>
35#endif
932690ab 36#include <unistd.h>
a54c0b3f 37#include <stdio.h>
8485bb11 38#include <ctype.h>
fcc01f65
KB
39#include <string.h>
40#include <stdlib.h>
7abf8d65 41#include <paths.h>
a54c0b3f 42
e99c53de
CT
43#if __STDC__
44void fatal(const char *fmt, ...);
45#else
46void fatal();
47#endif
48
fcc01f65 49#define COMPAT /* allow non-labeled disks */
f24e4d82 50
8485bb11
KM
51/*
52 * The following two constants set the default block and fragment sizes.
53 * Both constants must be a power of 2 and meet the following constraints:
54 * MINBSIZE <= DESBLKSIZE <= MAXBSIZE
55 * sectorsize <= DESFRAGSIZE <= DESBLKSIZE
56 * DESBLKSIZE / DESFRAGSIZE <= 8
57 */
58#define DFL_FRAGSIZE 1024
59#define DFL_BLKSIZE 8192
60
61/*
38f1cd11 62 * Cylinder groups may have up to many cylinders. The actual
8485bb11 63 * number used depends upon how much information can be stored
38f1cd11 64 * on a single cylinder. The default is to use 16 cylinders
8485bb11
KM
65 * per group.
66 */
67#define DESCPG 16 /* desired fs_cpg */
89241117 68
8485bb11
KM
69/*
70 * MINFREE gives the minimum acceptable percentage of file system
71 * blocks which may be free. If the freelist drops below this level
72 * only the superuser may continue to allocate blocks. This may
73 * be set to 0 if no reserve of free blocks is deemed necessary,
74 * however throughput drops by fifty percent if the file system
75 * is run at between 90% and 100% full; thus the default value of
76 * fs_minfree is 10%. With 10% free space, fragmentation is not a
77 * problem, so we choose to optimize for time.
78 */
79#define MINFREE 10
80#define DEFAULTOPT FS_OPTTIME
81
82/*
83 * ROTDELAY gives the minimum number of milliseconds to initiate
84 * another disk transfer on the same cylinder. It is used in
85 * determining the rotationally optimal layout for disk blocks
86 * within a file; the default of fs_rotdelay is 4ms.
87 */
88#define ROTDELAY 4
89
90/*
91 * MAXCONTIG sets the default for the maximum number of blocks
92 * that may be allocated sequentially. Since UNIX drivers are
93 * not capable of scheduling multi-block transfers, this defaults
94 * to 1 (ie no contiguous blocks are allocated).
95 */
96#define MAXCONTIG 1
97
3d632f12
KM
98/*
99 * MAXBLKPG determines the maximum number of data blocks which are
100 * placed in a single cylinder group. The default is one indirect
101 * block worth of data blocks.
102 */
103#define MAXBLKPG(bsize) ((bsize) / sizeof(daddr_t))
104
8485bb11
KM
105/*
106 * Each file system has a number of inodes statically allocated.
ec7b02f7 107 * We allocate one inode slot per NFPI fragments, expecting this
8485bb11
KM
108 * to be far more than we will ever need.
109 */
ec7b02f7 110#define NFPI 4
8485bb11 111
38f1cd11
KM
112/*
113 * For each cylinder we keep track of the availability of blocks at different
114 * rotational positions, so that we can lay out the data to be picked
115 * up with minimum rotational latency. NRPOS is the default number of
116 * rotational positions that we distinguish. With NRPOS of 8 the resolution
117 * of our summary information is 2ms for a typical 3600 rpm drive.
118 */
119#define NRPOS 8 /* number distinct rotational positions */
120
121
822f4068 122int mfs; /* run as the memory based filesystem */
8485bb11 123int Nflag; /* run without writing file system */
a54c0b3f 124int fssize; /* file system size */
a54c0b3f
SL
125int ntracks; /* # tracks/cylinder */
126int nsectors; /* # sectors/track */
a20edd44 127int nphyssectors; /* # sectors/track including spares */
8485bb11 128int secpercyl; /* sectors per cylinder */
a20edd44
KM
129int trackspares = -1; /* spare sectors per track */
130int cylspares = -1; /* spare sectors per cylinder */
a54c0b3f 131int sectorsize; /* bytes/sector */
c5d3fd78
MK
132#ifdef tahoe
133int realsectorsize; /* bytes/sector in hardware */
134#endif
c6003316 135int rpm; /* revolutions/minute of drive */
a20edd44
KM
136int interleave; /* hardware sector interleave */
137int trackskew = -1; /* sector 0 skew, per track */
138int headswitch; /* head switch time, usec */
139int trackseek; /* track-to-track seek, usec */
187d180d
MK
140int fsize = 0; /* fragment size */
141int bsize = 0; /* block size */
8485bb11 142int cpg = DESCPG; /* cylinders/cylinder group */
f40b03d9 143int cpgflg; /* cylinders/cylinder group flag was given */
8485bb11
KM
144int minfree = MINFREE; /* free space threshold */
145int opt = DEFAULTOPT; /* optimization preference (space or time) */
ec7b02f7 146int density; /* number of bytes per inode */
8485bb11
KM
147int maxcontig = MAXCONTIG; /* max contiguous blocks to allocate */
148int rotdelay = ROTDELAY; /* rotational delay between blocks */
3d632f12 149int maxbpg; /* maximum blocks per file in a cyl group */
38f1cd11 150int nrpos = NRPOS; /* # of distinguished rotational positions */
c5d3fd78
MK
151int bbsize = BBSIZE; /* boot block size */
152int sbsize = SBSIZE; /* superblock size */
822f4068 153int mntflags; /* flags to be passed to mount */
ec7b02f7
KM
154u_long memleft; /* virtual memory available */
155caddr_t membase; /* start address of memory based filesystem */
f24e4d82 156#ifdef COMPAT
894fc092 157char *disktype;
fcc01f65 158int unlabeled;
f24e4d82 159#endif
8485bb11 160
a54c0b3f 161char device[MAXPATHLEN];
ec7b02f7 162char *progname;
a54c0b3f 163
a54c0b3f 164main(argc, argv)
1b8b6e44 165 int argc;
a54c0b3f
SL
166 char *argv[];
167{
fcc01f65
KB
168 extern char *optarg;
169 extern int optind;
170 register int ch;
a54c0b3f 171 register struct partition *pp;
8485bb11
KM
172 register struct disklabel *lp;
173 struct disklabel *getdisklabel();
174 struct partition oldpartition;
a54c0b3f 175 struct stat st;
8485bb11 176 int fsi, fso;
fcc01f65 177 char *cp, *special, *opstring, buf[BUFSIZ];
990775e9
KM
178 struct statfs *mp;
179 char *s1, *s2;
180 int len, n;
a54c0b3f 181
fcc01f65
KB
182 if (progname = rindex(*argv, '/'))
183 ++progname;
184 else
ec7b02f7 185 progname = *argv;
fcc01f65 186
6bab0c78 187 if (strstr(progname, "mfs")) {
fcc01f65 188 mfs = 1;
ec7b02f7 189 Nflag++;
ec7b02f7 190 }
a54c0b3f 191
fcc01f65
KB
192 opstring = "F:NS:T:a:b:c:d:e:f:i:k:l:m:n:o:p:r:s:t:u:x:";
193 if (!mfs)
194 opstring += 2; /* -F is mfs only */
195
196 while ((ch = getopt(argc, argv, opstring)) != EOF)
197 switch(ch) {
198 case 'F':
199 if ((mntflags = atoi(optarg)) == 0)
200 fatal("%s: bad mount flags", optarg);
201 break;
202 case 'N':
203 Nflag++;
204 break;
205 case 'S':
206 if ((sectorsize = atoi(optarg)) <= 0)
207 fatal("%s: bad sector size", optarg);
208 break;
894fc092 209#ifdef COMPAT
fcc01f65
KB
210 case 'T':
211 disktype = optarg;
212 break;
894fc092 213#endif
fcc01f65
KB
214 case 'a':
215 if ((maxcontig = atoi(optarg)) <= 0)
216 fatal("%s: bad max contiguous blocks\n",
217 optarg);
218 break;
219 case 'b':
220 if ((bsize = atoi(optarg)) < MINBSIZE)
221 fatal("%s: bad block size", optarg);
222 break;
223 case 'c':
224 if ((cpg = atoi(optarg)) <= 0)
225 fatal("%s: bad cylinders/group", optarg);
226 cpgflg++;
227 break;
228 case 'd':
229 if ((rotdelay = atoi(optarg)) < 0)
230 fatal("%s: bad rotational delay\n", optarg);
231 break;
232 case 'e':
233 if ((maxbpg = atoi(optarg)) <= 0)
234 fatal("%s: bad blocks per file in a cyl group\n",
235 optarg);
236 break;
237 case 'f':
238 if ((fsize = atoi(optarg)) <= 0)
239 fatal("%s: bad frag size", optarg);
240 break;
241 case 'i':
242 if ((density = atoi(optarg)) <= 0)
243 fatal("%s: bad bytes per inode\n", optarg);
244 break;
245 case 'k':
246 if ((trackskew = atoi(optarg)) < 0)
247 fatal("%s: bad track skew", optarg);
248 break;
249 case 'l':
250 if ((interleave = atoi(optarg)) <= 0)
251 fatal("%s: bad interleave", optarg);
252 break;
253 case 'm':
254 if ((minfree = atoi(optarg)) < 0 || minfree > 99)
255 fatal("%s: bad free space %%\n", optarg);
256 break;
257 case 'n':
258 if ((nrpos = atoi(optarg)) <= 0)
259 fatal("%s: bad rotational layout count\n",
260 optarg);
261 break;
262 case 'o':
263 if (strcmp(optarg, "space") == 0)
264 opt = FS_OPTSPACE;
265 else if (strcmp(optarg, "time") == 0)
266 opt = FS_OPTTIME;
267 else
268 fatal("%s: bad optimization preference %s",
269 optarg, "(options are `space' or `time')");
270 break;
271 case 'p':
272 if ((trackspares = atoi(optarg)) < 0)
273 fatal("%s: bad spare sectors per track",
274 optarg);
275 break;
276 case 'r':
277 if ((rpm = atoi(optarg)) <= 0)
278 fatal("%s: bad revs/minute\n", optarg);
279 break;
280 case 's':
281 if ((fssize = atoi(optarg)) <= 0)
282 fatal("%s: bad file system size", optarg);
283 break;
284 case 't':
285 if ((ntracks = atoi(optarg)) <= 0)
286 fatal("%s: bad total tracks", optarg);
287 break;
288 case 'u':
289 if ((nsectors = atoi(optarg)) <= 0)
290 fatal("%s: bad sectors/track", optarg);
291 break;
292 case 'x':
293 if ((cylspares = atoi(optarg)) < 0)
294 fatal("%s: bad spare sectors per cylinder",
295 optarg);
296 break;
297 case '?':
298 default:
299 usage();
300 }
301 argc -= optind;
302 argv += optind;
303
304 if (argc != 2 && (mfs || argc != 1))
305 usage();
894fc092 306
a54c0b3f 307 special = argv[0];
1b8b6e44 308 cp = rindex(special, '/');
756884f0
MK
309 if (cp == 0) {
310 /*
311 * No path prefix; try /dev/r%s then /dev/%s.
312 */
313 (void)sprintf(device, "%sr%s", _PATH_DEV, special);
314 if (stat(device, &st) == -1)
315 (void)sprintf(device, "%s%s", _PATH_DEV, special);
316 special = device;
317 }
990775e9
KM
318 if (Nflag) {
319 fso = -1;
320 } else {
8485bb11 321 fso = open(special, O_WRONLY);
fcc01f65
KB
322 if (fso < 0)
323 fatal("%s: %s", special, strerror(errno));
990775e9
KM
324
325 /* Bail if target special is mounted */
326 n = getmntinfo(&mp, MNT_NOWAIT);
327 if (n == 0)
328 fatal("%s: getmntinfo: %s", special, strerror(errno));
329
330 len = sizeof(_PATH_DEV) - 1;
331 s1 = special;
332 if (strncmp(_PATH_DEV, s1, len) == 0)
333 s1 += len;
334
335 while (--n >= 0) {
336 s2 = mp->f_mntfromname;
337 if (strncmp(_PATH_DEV, s2, len) == 0) {
338 s2 += len - 1;
339 *s2 = 'r';
340 }
341 if (strcmp(s1, s2) == 0 || strcmp(s1, &s2[1]) == 0)
342 fatal("%s is mounted on %s",
343 special, mp->f_mntonname);
344 ++mp;
345 }
346 }
8485bb11 347 fsi = open(special, O_RDONLY);
fcc01f65
KB
348 if (fsi < 0)
349 fatal("%s: %s", special, strerror(errno));
350 if (fstat(fsi, &st) < 0)
351 fatal("%s: %s", special, strerror(errno));
ea6170ef
MK
352 if ((st.st_mode & S_IFMT) != S_IFCHR && !mfs)
353 printf("%s: %s: not a character-special device\n",
354 progname, special);
a54c0b3f 355 cp = index(argv[0], '\0') - 1;
8485bb11 356 if (cp == 0 || (*cp < 'a' || *cp > 'h') && !isdigit(*cp))
a54c0b3f 357 fatal("%s: can't figure out file system partition", argv[0]);
f24e4d82 358#ifdef COMPAT
894fc092
KM
359 if (!mfs && disktype == NULL)
360 disktype = argv[1];
f24e4d82 361#endif
894fc092 362 lp = getdisklabel(special, fsi);
8485bb11
KM
363 if (isdigit(*cp))
364 pp = &lp->d_partitions[0];
365 else
366 pp = &lp->d_partitions[*cp - 'a'];
367 if (pp->p_size == 0)
368 fatal("%s: `%c' partition is unavailable", argv[0], *cp);
369 if (fssize == 0)
a54c0b3f 370 fssize = pp->p_size;
822f4068 371 if (fssize > pp->p_size && !mfs)
8485bb11
KM
372 fatal("%s: maximum file system size on the `%c' partition is %d",
373 argv[0], *cp, pp->p_size);
374 if (rpm == 0) {
375 rpm = lp->d_rpm;
376 if (rpm <= 0)
6181c540 377 rpm = 3600;
a54c0b3f
SL
378 }
379 if (ntracks == 0) {
8485bb11
KM
380 ntracks = lp->d_ntracks;
381 if (ntracks <= 0)
6181c540 382 fatal("%s: no default #tracks", argv[0]);
a54c0b3f 383 }
8485bb11
KM
384 if (nsectors == 0) {
385 nsectors = lp->d_nsectors;
386 if (nsectors <= 0)
6181c540 387 fatal("%s: no default #sectors/track", argv[0]);
8485bb11 388 }
a54c0b3f 389 if (sectorsize == 0) {
8485bb11
KM
390 sectorsize = lp->d_secsize;
391 if (sectorsize <= 0)
6181c540 392 fatal("%s: no default sector size", argv[0]);
a54c0b3f 393 }
a20edd44
KM
394 if (trackskew == -1) {
395 trackskew = lp->d_trackskew;
396 if (trackskew < 0)
6181c540 397 trackskew = 0;
a20edd44
KM
398 }
399 if (interleave == 0) {
400 interleave = lp->d_interleave;
401 if (interleave <= 0)
6181c540 402 interleave = 1;
a20edd44 403 }
a54c0b3f
SL
404 if (fsize == 0) {
405 fsize = pp->p_fsize;
8485bb11
KM
406 if (fsize <= 0)
407 fsize = MAX(DFL_FRAGSIZE, lp->d_secsize);
a54c0b3f 408 }
8485bb11
KM
409 if (bsize == 0) {
410 bsize = pp->p_frag * pp->p_fsize;
411 if (bsize <= 0)
412 bsize = MIN(DFL_BLKSIZE, 8 * fsize);
c6003316 413 }
ec7b02f7
KM
414 if (density == 0)
415 density = NFPI * fsize;
75e589fc 416 if (minfree < 10 && opt != FS_OPTSPACE) {
8485bb11
KM
417 fprintf(stderr, "Warning: changing optimization to space ");
418 fprintf(stderr, "because minfree is less than 10%%\n");
75e589fc
KM
419 opt = FS_OPTSPACE;
420 }
a20edd44
KM
421 if (trackspares == -1) {
422 trackspares = lp->d_sparespertrack;
423 if (trackspares < 0)
6181c540 424 trackspares = 0;
a20edd44
KM
425 }
426 nphyssectors = nsectors + trackspares;
427 if (cylspares == -1) {
428 cylspares = lp->d_sparespercyl;
429 if (cylspares < 0)
6181c540 430 cylspares = 0;
a20edd44
KM
431 }
432 secpercyl = nsectors * ntracks - cylspares;
8485bb11 433 if (secpercyl != lp->d_secpercyl)
fcc01f65 434 fprintf(stderr, "%s (%d) %s (%lu)\n",
8485bb11
KM
435 "Warning: calculated sectors per cylinder", secpercyl,
436 "disagrees with disk label", lp->d_secpercyl);
c9b3f9df
KM
437 if (maxbpg == 0)
438 maxbpg = MAXBLKPG(bsize);
a20edd44
KM
439 headswitch = lp->d_headswitch;
440 trackseek = lp->d_trkseek;
e1b3345a
KB
441 /* Reno fix: label may be 0 if faked up by kernel */
442#ifdef notdef
756884f0 443#ifdef notdef /* label may be 0 if faked up by kernel */
c5d3fd78
MK
444 bbsize = lp->d_bbsize;
445 sbsize = lp->d_sbsize;
e1b3345a 446#endif
756884f0 447#endif
8485bb11 448 oldpartition = *pp;
c5d3fd78
MK
449#ifdef tahoe
450 realsectorsize = sectorsize;
187d180d 451 if (sectorsize != DEV_BSIZE) { /* XXX */
c5d3fd78
MK
452 int secperblk = DEV_BSIZE / sectorsize;
453
454 sectorsize = DEV_BSIZE;
455 nsectors /= secperblk;
456 nphyssectors /= secperblk;
457 secpercyl /= secperblk;
458 fssize /= secperblk;
459 pp->p_size /= secperblk;
460 }
461#endif
8485bb11 462 mkfs(pp, special, fsi, fso);
c5d3fd78
MK
463#ifdef tahoe
464 if (realsectorsize != DEV_BSIZE)
465 pp->p_size *= DEV_BSIZE / realsectorsize;
466#endif
8485bb11
KM
467 if (!Nflag && bcmp(pp, &oldpartition, sizeof(oldpartition)))
468 rewritelabel(special, fso, lp);
ec7b02f7
KM
469 if (!Nflag)
470 close(fso);
471 close(fsi);
5358b44e 472#ifdef MFS
822f4068 473 if (mfs) {
5358b44e
KB
474 struct mfs_args args;
475
822f4068 476 sprintf(buf, "mfs:%d", getpid());
ec7b02f7
KM
477 args.name = buf;
478 args.base = membase;
479 args.size = fssize * sectorsize;
fcc01f65
KB
480 if (mount(MOUNT_MFS, argv[1], mntflags, &args) < 0)
481 fatal("%s: %s", argv[1], strerror(errno));
ec7b02f7 482 }
5358b44e 483#endif
a54c0b3f
SL
484 exit(0);
485}
486
f24e4d82 487#ifdef COMPAT
894fc092 488char lmsg[] = "%s: can't read disk label; disk type must be specified";
f24e4d82 489#else
894fc092
KM
490char lmsg[] = "%s: can't read disk label";
491#endif
492
8485bb11
KM
493struct disklabel *
494getdisklabel(s, fd)
495 char *s;
f24e4d82 496 int fd;
a54c0b3f 497{
8485bb11
KM
498 static struct disklabel lab;
499
500 if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
894fc092
KM
501#ifdef COMPAT
502 if (disktype) {
756884f0 503 struct disklabel *lp, *getdiskbyname();
894fc092 504
fcc01f65 505 unlabeled++;
756884f0
MK
506 lp = getdiskbyname(disktype);
507 if (lp == NULL)
508 fatal("%s: unknown disk type", disktype);
509 return (lp);
894fc092
KM
510 }
511#endif
fcc01f65
KB
512 (void)fprintf(stderr,
513 "%s: ioctl (GDINFO): %s\n", progname, strerror(errno));
894fc092 514 fatal(lmsg, s);
8485bb11
KM
515 }
516 return (&lab);
517}
518
519rewritelabel(s, fd, lp)
520 char *s;
a54c0b3f 521 int fd;
8485bb11
KM
522 register struct disklabel *lp;
523{
f24e4d82 524#ifdef COMPAT
fcc01f65 525 if (unlabeled)
f24e4d82
MK
526 return;
527#endif
8485bb11
KM
528 lp->d_checksum = 0;
529 lp->d_checksum = dkcksum(lp);
530 if (ioctl(fd, DIOCWDINFO, (char *)lp) < 0) {
fcc01f65
KB
531 (void)fprintf(stderr,
532 "%s: ioctl (WDINFO): %s\n", progname, strerror(errno));
8485bb11 533 fatal("%s: can't rewrite disk label", s);
a54c0b3f 534 }
bf8f0524
MK
535#if vax
536 if (lp->d_type == DTYPE_SMD && lp->d_flags & D_BADSECT) {
537 register i;
c5d3fd78 538 int cfd;
bf8f0524 539 daddr_t alt;
c5d3fd78
MK
540 char specname[64];
541 char blk[1024];
866736b4 542 char *cp;
c5d3fd78
MK
543
544 /*
545 * Make name for 'c' partition.
546 */
547 strcpy(specname, s);
548 cp = specname + strlen(specname) - 1;
549 if (!isdigit(*cp))
550 *cp = 'c';
551 cfd = open(specname, O_WRONLY);
fcc01f65
KB
552 if (cfd < 0)
553 fatal("%s: %s", specname, strerror(errno));
c5d3fd78
MK
554 bzero(blk, sizeof(blk));
555 *(struct disklabel *)(blk + LABELOFFSET) = *lp;
bf8f0524
MK
556 alt = lp->d_ncylinders * lp->d_secpercyl - lp->d_nsectors;
557 for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) {
756884f0
MK
558 if (lseek(cfd, (off_t)(alt + i) * lp->d_secsize,
559 L_SET) == -1)
fcc01f65
KB
560 fatal("lseek to badsector area: %s",
561 strerror(errno));
562 if (write(cfd, blk, lp->d_secsize) < lp->d_secsize)
563 fprintf(stderr,
564 "%s: alternate label %d write: %s\n",
565 progname, i/2, strerror(errno));
8485bb11 566 }
ec7b02f7 567 close(cfd);
8485bb11 568 }
bf8f0524 569#endif
a54c0b3f
SL
570}
571
572/*VARARGS*/
e99c53de
CT
573void
574#if __STDC__
575fatal(const char *fmt, ...)
576#else
577fatal(fmt, va_alist)
a54c0b3f 578 char *fmt;
e99c53de
CT
579 va_dcl
580#endif
a54c0b3f 581{
fcc01f65 582 va_list ap;
a54c0b3f 583
e99c53de 584#if __STDC__
fcc01f65 585 va_start(ap, fmt);
e99c53de
CT
586#else
587 va_start(ap);
588#endif
589 fprintf(stderr, "%s: ", progname);
fcc01f65
KB
590 (void)vfprintf(stderr, fmt, ap);
591 va_end(ap);
a54c0b3f 592 putc('\n', stderr);
fcc01f65
KB
593 exit(1);
594}
595
596usage()
597{
598 if (mfs) {
599 fprintf(stderr,
990775e9
KM
600 "usage: %s [ -fsoptions ] special-device mount-point\n",
601 progname);
fcc01f65
KB
602 } else
603 fprintf(stderr,
990775e9
KM
604 "usage: %s [ -fsoptions ] special-device%s\n",
605 progname,
fcc01f65
KB
606#ifdef COMPAT
607 " [device-type]");
608#else
609 "");
610#endif
611 fprintf(stderr, "where fsoptions are:\n");
612 fprintf(stderr,
613 "\t-N do not create file system, just print out parameters\n");
614 fprintf(stderr, "\t-S sector size\n");
615#ifdef COMPAT
616 fprintf(stderr, "\t-T disktype\n");
617#endif
618 fprintf(stderr, "\t-a maximum contiguous blocks\n");
619 fprintf(stderr, "\t-b block size\n");
620 fprintf(stderr, "\t-c cylinders/group\n");
621 fprintf(stderr, "\t-d rotational delay between contiguous blocks\n");
622 fprintf(stderr, "\t-e maximum blocks per file in a cylinder group\n");
623 fprintf(stderr, "\t-f frag size\n");
624 fprintf(stderr, "\t-i number of bytes per inode\n");
625 fprintf(stderr, "\t-k sector 0 skew, per track\n");
626 fprintf(stderr, "\t-l hardware sector interleave\n");
627 fprintf(stderr, "\t-m minimum free space %%\n");
628 fprintf(stderr, "\t-n number of distinguished rotational positions\n");
629 fprintf(stderr, "\t-o optimization preference (`space' or `time')\n");
630 fprintf(stderr, "\t-p spare sectors per track\n");
631 fprintf(stderr, "\t-s file system size (sectors)\n");
632 fprintf(stderr, "\t-r revolutions/minute\n");
633 fprintf(stderr, "\t-t tracks/cylinder\n");
634 fprintf(stderr, "\t-u sectors/track\n");
635 fprintf(stderr, "\t-x spare sectors per cylinder\n");
636 exit(1);
a54c0b3f 637}