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