386BSD 0.1 development
authorWilliam F. Jolitz <wjolitz@soda.berkeley.edu>
Wed, 17 Apr 1991 00:35:04 +0000 (16:35 -0800)
committerWilliam F. Jolitz <wjolitz@soda.berkeley.edu>
Wed, 17 Apr 1991 00:35:04 +0000 (16:35 -0800)
Work on file usr/src/sbin/swapon/swapon.c
Work on file usr/src/sbin/swapon/swapon.8
Work on file usr/src/sbin/tunefs/tunefs.c
Work on file usr/src/sbin/tunefs/tunefs.8

Co-Authored-By: Lynne Greer Jolitz <ljolitz@cardio.ucsf.edu>
Synthesized-from: 386BSD-0.1

usr/src/sbin/swapon/swapon.8 [new file with mode: 0644]
usr/src/sbin/swapon/swapon.c [new file with mode: 0644]
usr/src/sbin/tunefs/tunefs.8 [new file with mode: 0644]
usr/src/sbin/tunefs/tunefs.c [new file with mode: 0644]

diff --git a/usr/src/sbin/swapon/swapon.8 b/usr/src/sbin/swapon/swapon.8
new file mode 100644 (file)
index 0000000..596a7e5
--- /dev/null
@@ -0,0 +1,90 @@
+.\" Copyright (c) 1980, 1991 Regents of the University of California.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"     @(#)swapon.8   6.3 (Berkeley) 3/16/91
+.\"
+.Dd March 16, 1991
+.Dt SWAPON 8
+.Os BSD 4
+.Sh NAME
+.Nm swapon
+.Nd "specify additional device for paging and swapping"
+.Sh SYNOPSIS
+.Nm swapon
+.Fl a
+.Nm swapon
+.Ar special_file ...
+.Sh DESCRIPTION
+.Nm Swapon
+is used to specify additional devices on which paging and swapping
+are to take place.
+The system begins by swapping and paging on only a single device
+so that only one disk is required at bootstrap time.
+Calls to
+.Nm swapon
+normally occur in the system multi-user initialization file
+.Pa /etc/rc
+making all swap devices available, so that the paging and swapping
+activity is interleaved across several devices.
+.Pp
+Normally, the first form is used:
+.Bl -tag -width Ds
+.It Fl a
+All devices marked as ``sw''
+swap devices in
+.Pa /etc/fstab
+are made available.
+.El
+.Pp
+The second form gives individual block devices as given
+in the system swap configuration table.  The call makes only this space
+available to the system for swap allocation.
+.Sh SEE ALSO
+.Xr swapon 2 ,
+.Xr fstab 8
+.Xr init 8
+.Xr rc 8
+.Sh FILES
+.Bl -tag -width /dev/[ru][pk]?b -compact
+.It Pa /dev/[ru][pk]?b
+standard paging devices
+.It Pa /etc/fstab
+ascii filesystem description table
+.El
+.Sh BUGS
+There is no way to stop paging and swapping on a device.
+It is therefore not possible to make use of devices which may be
+dismounted during system operation.
+.Sh HISTORY
+The
+.Nm
+command appeared in
+.Bx 4.0 .
diff --git a/usr/src/sbin/swapon/swapon.c b/usr/src/sbin/swapon/swapon.c
new file mode 100644 (file)
index 0000000..e70f881
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)swapon.c   5.5 (Berkeley) 2/27/91";
+#endif /* not lint */
+
+#include <fstab.h>
+#include <errno.h>
+#include <stdio.h>
+
+main(argc, argv)
+       int argc;
+       char **argv;
+{
+       extern char *optarg;
+       extern int optind;
+       register struct fstab *fsp;
+       register int stat;
+       int ch, doall;
+
+       doall = 0;
+       while ((ch = getopt(argc, argv, "a")) != EOF)
+               switch((char)ch) {
+               case 'a':
+                       doall = 1;
+                       break;
+               case '?':
+               default:
+                       usage();
+               }
+       argv += optind;
+
+       stat = 0;
+       if (doall)
+               while (fsp = getfsent()) {
+                       if (strcmp(fsp->fs_type, FSTAB_SW))
+                               continue;
+                       if (add(fsp->fs_spec, 1))
+                               stat = 1;
+                       else
+                               printf("swapon: adding %s as swap device\n",
+                                   fsp->fs_spec);
+               }
+       else if (!*argv)
+               usage();
+       for (; *argv; ++argv)
+               stat |= add(*argv, 0);
+       exit(stat);
+}
+
+add(name, ignoreebusy)
+       char *name;
+       int ignoreebusy;
+{
+       extern int errno;
+
+       if (swapon(name) == -1) {
+               switch (errno) {
+               case EINVAL:
+                       fprintf(stderr, "swapon: %s: device not configured\n",
+                           name);
+                       break;
+               case EBUSY:
+                       if (!ignoreebusy)
+                               fprintf(stderr,
+                                   "swapon: %s: device already in use\n",
+                                    name);
+                       break;
+               default:
+                       fprintf(stderr, "swapon: %s: ", name);
+                       perror((char *)NULL);
+                       break;
+               }
+               return(1);
+       }
+       return(0);
+}
+
+usage()
+{
+       fprintf(stderr, "usage: swapon [-a] [special_file ...]\n");
+       exit(1);
+}
diff --git a/usr/src/sbin/tunefs/tunefs.8 b/usr/src/sbin/tunefs/tunefs.8
new file mode 100644 (file)
index 0000000..da293fb
--- /dev/null
@@ -0,0 +1,137 @@
+.\" Copyright (c) 1983, 1991 Regents of the University of California.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"     @(#)tunefs.8   6.6 (Berkeley) 3/16/91
+.\"
+.Dd March 16, 1991
+.Dt TUNEFS 8
+.Os BSD 4.2
+.Sh NAME
+.Nm tunefs
+.Nd tune up an existing file system
+.Sh SYNOPSIS
+.Nm tunefs
+.Op Fl a Ar maxcontig
+.Op Fl d Ar rotdelay
+.Op Fl e Ar maxbpg
+.Op Fl m Ar minfree
+.Bk -words
+.Op Fl o Ar optimize_preference
+.Ek
+.Op Ar special | Ar filesys
+.Sh DESCRIPTION
+.Nm Tunefs
+is designed to change the dynamic parameters of a file system
+which affect the layout policies.
+The parameters which are to be changed are indicated by the flags
+given below:
+.Bl -tag -width Ds
+.It Fl a Ar maxcontig
+This specifies the maximum number of contiguous blocks that will
+be laid out before forcing a rotational delay (see
+.Fl d
+below).
+The default value is one, since most device drivers require
+an interrupt per disk transfer.
+Device drivers that can chain several buffers together in a single
+transfer should set this to the maximum chain length.
+.It Fl d Ar rotdelay
+This specifies the expected time (in milliseconds)
+to service a transfer completion
+interrupt and initiate a new transfer on the same disk.
+It is used to decide how much rotational spacing to place between
+successive blocks in a file.
+.It Fl e Ar maxbpg
+This indicates the maximum number of blocks any single file can
+allocate out of a cylinder group before it is forced to begin
+allocating blocks from another cylinder group.
+Typically this value is set to about one quarter of the total blocks
+in a cylinder group.
+The intent is to prevent any single file from using up all the
+blocks in a single cylinder group,
+thus degrading access times for all files subsequently allocated
+in that cylinder group.
+The effect of this limit is to cause big files to do long seeks
+more frequently than if they were allowed to allocate all the blocks
+in a cylinder group before seeking elsewhere.
+For file systems with exclusively large files,
+this parameter should be set higher.
+.It Fl m Ar minfree
+This value specifies the percentage of space held back
+from normal users; the minimum free space threshold.
+The default value used is 10%.
+This value can be set to zero, however up to a factor of three
+in throughput will be lost over the performance obtained at a 10%
+threshold.
+Note that if the value is raised above the current usage level,
+users will be unable to allocate files until enough files have
+been deleted to get under the higher threshold.
+.It Fl o Ar optimize_preference
+The file system can either try to minimize the time spent
+allocating blocks, or it can attempt minimize the space
+fragmentation on the disk.
+If the value of minfree (see above) is less than 10%,
+then the file system should optimize for space to avoid
+running out of full sized blocks.
+For values of minfree greater than or equal to 10%,
+fragmentation is unlikely to be problematical, and
+the file system can be optimized for time.
+.El
+.Sh SEE ALSO
+.Xr fs 5 ,
+.Xr newfs 8 ,
+.Xr mkfs 8
+.Rs
+.%A M. McKusick
+.%A W. Joy
+.%A S. Leffler
+.%A R. Fabry
+.%T "A Fast File System for UNIX"
+.%J "ACM Transactions on Computer Systems 2"
+.%N 3
+.%P pp 181-197
+.%D August 1984
+.%O "(reprinted in the BSD System Manager's Manual, SMM:14)"
+.Re
+.Sh BUGS
+This program should work on mounted and active file systems.
+Because the super-block is not kept in the buffer cache,
+the changes will only take effect if the program
+is run on dismounted file systems.
+To change the root file system, the system must be rebooted
+after the file system is tuned.
+.Pp
+You can tune a file system, but you can't tune a fish.
+.Sh HISTORY
+The
+.Nm
+command appeared in
+.Bx 4.2 .
diff --git a/usr/src/sbin/tunefs/tunefs.c b/usr/src/sbin/tunefs/tunefs.c
new file mode 100644 (file)
index 0000000..fb98bac
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1983 The Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)tunefs.c   5.11 (Berkeley) 6/1/90";
+#endif /* not lint */
+
+/*
+ * tunefs: change layout parameters to an existing file system.
+ */
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <ufs/fs.h>
+#include <fstab.h>
+#include <stdio.h>
+#include <paths.h>
+
+union {
+       struct  fs sb;
+       char pad[MAXBSIZE];
+} sbun;
+#define        sblock sbun.sb
+
+int fi;
+long dev_bsize = 1;
+
+main(argc, argv)
+       int argc;
+       char *argv[];
+{
+       char *cp, *special, *name;
+       struct stat st;
+       int i;
+       int Aflag = 0;
+       struct fstab *fs;
+       char *chg[2], device[MAXPATHLEN];
+
+       argc--, argv++; 
+       if (argc < 2)
+               goto usage;
+       special = argv[argc - 1];
+       fs = getfsfile(special);
+       if (fs)
+               special = fs->fs_spec;
+again:
+       if (stat(special, &st) < 0) {
+               if (*special != '/') {
+                       if (*special == 'r')
+                               special++;
+                       (void)sprintf(device, "%s/%s", _PATH_DEV, special);
+                       special = device;
+                       goto again;
+               }
+               fprintf(stderr, "tunefs: "); perror(special);
+               exit(1);
+       }
+       if ((st.st_mode & S_IFMT) != S_IFBLK &&
+           (st.st_mode & S_IFMT) != S_IFCHR)
+               fatal("%s: not a block or character device", special);
+       getsb(&sblock, special);
+       for (; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
+               for (cp = &argv[0][1]; *cp; cp++)
+                       switch (*cp) {
+
+                       case 'A':
+                               Aflag++;
+                               continue;
+
+                       case 'a':
+                               name = "maximum contiguous block count";
+                               if (argc < 1)
+                                       fatal("-a: missing %s", name);
+                               argc--, argv++;
+                               i = atoi(*argv);
+                               if (i < 1)
+                                       fatal("%s: %s must be >= 1",
+                                               *argv, name);
+                               fprintf(stdout, "%s changes from %d to %d\n",
+                                       name, sblock.fs_maxcontig, i);
+                               sblock.fs_maxcontig = i;
+                               continue;
+
+                       case 'd':
+                               name =
+                                  "rotational delay between contiguous blocks";
+                               if (argc < 1)
+                                       fatal("-d: missing %s", name);
+                               argc--, argv++;
+                               i = atoi(*argv);
+                               fprintf(stdout,
+                                       "%s changes from %dms to %dms\n",
+                                       name, sblock.fs_rotdelay, i);
+                               sblock.fs_rotdelay = i;
+                               continue;
+
+                       case 'e':
+                               name =
+                                 "maximum blocks per file in a cylinder group";
+                               if (argc < 1)
+                                       fatal("-e: missing %s", name);
+                               argc--, argv++;
+                               i = atoi(*argv);
+                               if (i < 1)
+                                       fatal("%s: %s must be >= 1",
+                                               *argv, name);
+                               fprintf(stdout, "%s changes from %d to %d\n",
+                                       name, sblock.fs_maxbpg, i);
+                               sblock.fs_maxbpg = i;
+                               continue;
+
+                       case 'm':
+                               name = "minimum percentage of free space";
+                               if (argc < 1)
+                                       fatal("-m: missing %s", name);
+                               argc--, argv++;
+                               i = atoi(*argv);
+                               if (i < 0 || i > 99)
+                                       fatal("%s: bad %s", *argv, name);
+                               fprintf(stdout,
+                                       "%s changes from %d%% to %d%%\n",
+                                       name, sblock.fs_minfree, i);
+                               sblock.fs_minfree = i;
+                               if (i >= 10 && sblock.fs_optim == FS_OPTSPACE)
+                                       fprintf(stdout, "should optimize %s",
+                                           "for time with minfree >= 10%\n");
+                               if (i < 10 && sblock.fs_optim == FS_OPTTIME)
+                                       fprintf(stdout, "should optimize %s",
+                                           "for space with minfree < 10%\n");
+                               continue;
+
+                       case 'o':
+                               name = "optimization preference";
+                               if (argc < 1)
+                                       fatal("-o: missing %s", name);
+                               argc--, argv++;
+                               chg[FS_OPTSPACE] = "space";
+                               chg[FS_OPTTIME] = "time";
+                               if (strcmp(*argv, chg[FS_OPTSPACE]) == 0)
+                                       i = FS_OPTSPACE;
+                               else if (strcmp(*argv, chg[FS_OPTTIME]) == 0)
+                                       i = FS_OPTTIME;
+                               else
+                                       fatal("%s: bad %s (options are `space' or `time')",
+                                               *argv, name);
+                               if (sblock.fs_optim == i) {
+                                       fprintf(stdout,
+                                               "%s remains unchanged as %s\n",
+                                               name, chg[i]);
+                                       continue;
+                               }
+                               fprintf(stdout,
+                                       "%s changes from %s to %s\n",
+                                       name, chg[sblock.fs_optim], chg[i]);
+                               sblock.fs_optim = i;
+                               if (sblock.fs_minfree >= 10 && i == FS_OPTSPACE)
+                                       fprintf(stdout, "should optimize %s",
+                                           "for time with minfree >= 10%\n");
+                               if (sblock.fs_minfree < 10 && i == FS_OPTTIME)
+                                       fprintf(stdout, "should optimize %s",
+                                           "for space with minfree < 10%\n");
+                               continue;
+
+                       default:
+                               fatal("-%c: unknown flag", *cp);
+                       }
+       }
+       if (argc != 1)
+               goto usage;
+       bwrite(SBOFF / dev_bsize, (char *)&sblock, SBSIZE);
+       if (Aflag)
+               for (i = 0; i < sblock.fs_ncg; i++)
+                       bwrite(fsbtodb(&sblock, cgsblock(&sblock, i)),
+                           (char *)&sblock, SBSIZE);
+       close(fi);
+       exit(0);
+usage:
+       fprintf(stderr, "Usage: tunefs tuneup-options special-device\n");
+       fprintf(stderr, "where tuneup-options are:\n");
+       fprintf(stderr, "\t-a maximum contiguous blocks\n");
+       fprintf(stderr, "\t-d rotational delay between contiguous blocks\n");
+       fprintf(stderr, "\t-e maximum blocks per file in a cylinder group\n");
+       fprintf(stderr, "\t-m minimum percentage of free space\n");
+       fprintf(stderr, "\t-o optimization preference (`space' or `time')\n");
+       exit(2);
+}
+
+getsb(fs, file)
+       register struct fs *fs;
+       char *file;
+{
+
+       fi = open(file, 2);
+       if (fi < 0) {
+               fprintf(stderr, "cannot open");
+               perror(file);
+               exit(3);
+       }
+       if (bread(SBOFF, (char *)fs, SBSIZE)) {
+               fprintf(stderr, "bad super block");
+               perror(file);
+               exit(4);
+       }
+       if (fs->fs_magic != FS_MAGIC) {
+               fprintf(stderr, "%s: bad magic number\n", file);
+               exit(5);
+       }
+       dev_bsize = fs->fs_fsize / fsbtodb(fs, 1);
+}
+
+bwrite(blk, buf, size)
+       char *buf;
+       daddr_t blk;
+       register size;
+{
+       if (lseek(fi, blk * dev_bsize, 0) < 0) {
+               perror("FS SEEK");
+               exit(6);
+       }
+       if (write(fi, buf, size) != size) {
+               perror("FS WRITE");
+               exit(7);
+       }
+}
+
+bread(bno, buf, cnt)
+       daddr_t bno;
+       char *buf;
+{
+       register i;
+
+       if (lseek(fi, bno * dev_bsize, 0) < 0)
+               return(1);
+       if ((i = read(fi, buf, cnt)) != cnt) {
+               for(i=0; i<sblock.fs_bsize; i++)
+                       buf[i] = 0;
+               return (1);
+       }
+       return (0);
+}
+
+/* VARARGS1 */
+fatal(fmt, arg1, arg2)
+       char *fmt, *arg1, *arg2;
+{
+
+       fprintf(stderr, "tunefs: ");
+       fprintf(stderr, fmt, arg1, arg2);
+       putc('\n', stderr);
+       exit(10);
+}