diff options
| author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1998-07-17 20:13:53 +0000 |
|---|---|---|
| committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1998-07-17 20:13:53 +0000 |
| commit | 4fc19a7cc3c1752f72ea797d9c5eddc40a8c5655 (patch) | |
| tree | 6ecea036e7614657872c63786ebf67f886f7408d | |
| parent | b0e6f7baa8dd6be0594ec598ae0256b44633fde9 (diff) | |
Notes
85 files changed, 1219 insertions, 3872 deletions
diff --git a/sbin/Makefile b/sbin/Makefile index 9a781cafd5918..806c0bcfd28a7 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -3,10 +3,10 @@ # XXX MISSING: icheck ncheck SUBDIR= adjkerntz badsect ccdconfig clri disklabel dmesg dset dump dumpfs \ - dumplfs dumpon fsck fsdb fsirand ifconfig init ipfw md5 mknod modload \ + dumpon fsck fsdb fsirand ifconfig init ipfw md5 mknod modload \ modunload mount mount_cd9660 mount_ext2fs \ - mount_lfs mount_nfs mount_null mount_portal mount_std \ - mount_umap mount_union mountd newfs newlfs nfsd nfsiod \ + mount_nfs mount_null mount_portal mount_std \ + mount_umap mount_union mountd newfs nfsd nfsiod \ nologin ping quotacheck reboot restore route routed savecore scsi \ scsiformat shutdown slattach startslip swapon tunefs umount diff --git a/sbin/adjkerntz/adjkerntz.8 b/sbin/adjkerntz/adjkerntz.8 index e9d93a9b49a4f..beb9a6204486c 100644 --- a/sbin/adjkerntz/adjkerntz.8 +++ b/sbin/adjkerntz/adjkerntz.8 @@ -1,4 +1,4 @@ -.\" Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia. +.\" Copyright (C) 1993-1998 by Andrey A. Chernov, Moscow, Russia. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: adjkerntz.8,v 1.13 1997/02/22 14:32:08 peter Exp $ +.\" $Id: adjkerntz.8,v 1.10.2.1 1997/03/03 07:01:06 mpp Exp $ .\" .Dd April 4, 1996 .Dt ADJKERNTZ 8 @@ -45,7 +45,9 @@ also informs the kernel about machine timezone shifts to maintain proper timestamps for local time file systems such as the MS-DOS file system. The main purpose of this thing is not general fixing of initially broken MS-DOS file timestamp idea but keeping -the same timestamps between FreeBSD MS-DOS file system +the same timestamps between +.Bx Free +MS-DOS file system and MS-DOS operating system installed on the same machine. If the file @@ -61,7 +63,7 @@ kernel variable. Adjustments may be needed at system startup and shutdown, and whenever a time zone change occurs. To handle these different situations, -.Nm adjkerntz +.Nm is invoked in two ways: .Bl -tag -width 4n .It Cm Fl i @@ -73,18 +75,18 @@ on entry to multi-user mode, before any other daemons have been started. .Nm Adjkerntz puts itself into the background. Then, for a local time CMOS clock, -.Nm adjkerntz +.Nm reads the local time from it and sets the kernel clock to the corresponding UTC time. .Nm Adjkerntz also stores the local time zone offset into the .Pa machdep.adjkerntz kernel variable, for use by subsequent invocations of -.Nm "'adjkerntz -a'" +.Em "'adjkerntz -a'" and by local time file systems. .Pp For a local time CMOS clock -.Nm "'adjkerntz -i'" +.Em "'adjkerntz -i'" pauses, and remains inactive as a background daemon until it receives a SIGTERM. The SIGTERM will normally be sent by @@ -92,11 +94,11 @@ The SIGTERM will normally be sent by when the system leaves multi-user mode (usually, because the system is being shut down). After receiving the SIGTERM, -.Nm adjkerntz +.Nm reads the UTC kernel clock and updates the CMOS clock, if necessary, to ensure that it reflects the current local time zone. Then -.Nm adjkerntz +.Nm exits. .It Cm Fl a Op Fl s This form is used to update the local time CMOS clock and kernel @@ -112,24 +114,24 @@ It stores the new offset into the .Pa machdep.adjkerntz kernel variable, and updates the wall CMOS clock to the new local time. If -.Nm "'adjkerntz -a'" +.Em "'adjkerntz -a'" was started at a nonexistent time (during a timezone change), it exits with a warning diagnostic unless the .Fl s option was used, in which case -.Nm adjkerntz +.Nm sleeps 30 minutes and tries again. .Pp This form should be invoked from root's .Xr crontab 5 -every half hour between midnight and 4am, when most modern time +every half hour between midnight and 5am, when most modern time zone changes occur. Warning: don't use the .Fl s option in a .Xr crontab 5 command line, or multiple -.Nm "'adjkerntz -a'" +.Em "'adjkerntz -a'" instances could conflict with each other. .El .Pp @@ -158,6 +160,7 @@ and Empty file. Its presence indicates that the machine's CMOS clock is set to local time, while its absence indicates a UTC CMOS clock. +.El .Sh SEE ALSO .Xr tzset 3 , .Xr crontab 5 , @@ -165,17 +168,18 @@ time, while its absence indicates a UTC CMOS clock. .Xr rc 8 , .Xr sysctl 8 , .Xr tzsetup 8 , -.Xr zic 8 . +.Xr zic 8 .Sh DIAGNOSTICS No diagnostics. If an error occurs, -.Nm adjkerntz +.Nm logs an error message via .Xr syslog 3 and exits with a nonzero return code. -.Sh AUTHOR -Andrey A. Chernov <ache@astral.msk.su> +.Sh AUTHORS +.An Andrey A. Chernov Aq ache@astral.msk.su .Sh HISTORY The -.Nm adjkerntz -command appeared in FreeBSD 1.0.1. +.Nm +command appeared in +.Fx 1.0 . diff --git a/sbin/adjkerntz/adjkerntz.c b/sbin/adjkerntz/adjkerntz.c index 9c31c1f26f76b..7082123975b04 100644 --- a/sbin/adjkerntz/adjkerntz.c +++ b/sbin/adjkerntz/adjkerntz.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia. + * Copyright (C) 1993-1998 by Andrey A. Chernov, Moscow, Russia. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: adjkerntz.c,v 1.21 1998/02/25 09:40:21 ache Exp $ + * $Id: adjkerntz.c,v 1.18.2.3 1998/02/25 09:43:47 ache Exp $ */ #ifndef lint @@ -47,7 +47,6 @@ char copyright[] = #include <stdlib.h> #include <unistd.h> #include <syslog.h> -#include <sys/stat.h> #include <sys/time.h> #include <sys/param.h> #include <machine/cpu.h> @@ -71,14 +70,14 @@ int main(argc, argv) int argc; char **argv; { - struct tm local, utc; + struct tm local; struct timeval tv, *stv; struct timezone tz, *stz; int kern_offset, wall_clock, disrtcset; size_t len; int mib[2]; /* Avoid time_t here, can be unsigned long or worse */ - long offset, utcsec, localsec, diff; + long offset, localsec, diff; time_t initial_sec, final_sec; int ch; int initial_isdst = -1, final_isdst; @@ -106,6 +105,10 @@ int main(argc, argv) } if (init == Unknown) usage(); + + if (access(_PATH_CLOCK, F_OK) != 0) + return 0; + if (init) sleep_mode = True; @@ -161,27 +164,25 @@ recalculate: local = *localtime(&initial_sec); if (diff == 0) initial_isdst = local.tm_isdst; - utc = *gmtime(&initial_sec); - local.tm_isdst = utc.tm_isdst = initial_isdst; + local.tm_isdst = initial_isdst; /* calculate local CMOS diff from GMT */ - utcsec = mktime(&utc); localsec = mktime(&local); - if (utcsec == -1 || localsec == -1) { + if (localsec == -1) { /* * XXX user can only control local time, and it is * unacceptable to fail here for init. 2:30 am in the * middle of the nonexistent hour means 3:30 am. */ - syslog(LOG_WARNING, - "Warning: nonexistent %s time.", - utcsec == -1 && localsec == -1 ? "UTC time and local" : - utcsec == -1 ? "UTC" : "local"); if (!sleep_mode) { + syslog(LOG_WARNING, + "Warning: nonexistent local time, try to run later."); syslog(LOG_WARNING, "Giving up."); return 1; } + syslog(LOG_WARNING, + "Warning: nonexistent local time."); syslog(LOG_WARNING, "Will retry after %d minutes.", REPORT_PERIOD / 60); (void) signal(SIGTERM, SIG_DFL); @@ -189,7 +190,7 @@ recalculate: (void) sleep(REPORT_PERIOD); goto again; } - offset = utcsec - localsec; + offset = -local.tm_gmtoff; #ifdef DEBUG fprintf(stderr, "Initial offset: %ld secs\n", offset); #endif @@ -217,25 +218,23 @@ recalculate: initial_isdst = final_isdst; goto recalculate; } - utc = *gmtime(&final_sec); - local.tm_isdst = utc.tm_isdst = final_isdst; + local.tm_isdst = final_isdst; - utcsec = mktime(&utc); localsec = mktime(&local); - if (utcsec == -1 || localsec == -1) { + if (localsec == -1) { bad_final: /* * XXX as above. The user has even less control, * but perhaps we never get here. */ - syslog(LOG_WARNING, - "Warning: nonexistent final %s time.", - utcsec == -1 && localsec == -1 ? "UTC time and local" : - utcsec == -1 ? "UTC" : "local"); if (!sleep_mode) { + syslog(LOG_WARNING, + "Warning: nonexistent final local time, try to run later."); syslog(LOG_WARNING, "Giving up."); return 1; } + syslog(LOG_WARNING, + "Warning: nonexistent final local time."); syslog(LOG_WARNING, "Will retry after %d minutes.", REPORT_PERIOD / 60); (void) signal(SIGTERM, SIG_DFL); @@ -243,7 +242,7 @@ recalculate: (void) sleep(REPORT_PERIOD); goto again; } - offset = utcsec - localsec; + offset = -local.tm_gmtoff; #ifdef DEBUG fprintf(stderr, "Final offset: %ld secs\n", offset); #endif diff --git a/sbin/badsect/badsect.8 b/sbin/badsect/badsect.8 index 4e63795c33456..0322ff2b3d057 100644 --- a/sbin/badsect/badsect.8 +++ b/sbin/badsect/badsect.8 @@ -10,7 +10,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" 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 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)badsect.8 8.1 (Berkeley) 6/5/93 -.\" $Id: badsect.8,v 1.1.1.1.8.2 1997/06/04 11:05:11 charnier Exp $ +.\" $Id: badsect.8,v 1.1.1.1.8.3 1997/10/15 17:36:09 max Exp $ .\" .Dd June 5, 1993 .Dt BADSECT 8 @@ -39,7 +39,7 @@ .Nm badsect .Nd create files to contain bad sectors .Sh SYNOPSIS -.Nm /sbin/badsect +.Nm badsect .Ar bbdir sector ... .Sh DESCRIPTION .Nm Badsect @@ -54,7 +54,7 @@ makes the pack appear perfect, and such packs can then be copied with .Xr dd 1 . The technique used by this program is also less general than bad block forwarding, as -.Nm badsect +.Nm can't make amends for bad blocks in the i-list of file systems or in swap areas. .Pp @@ -66,7 +66,7 @@ formatter. Thus to deal with a newly bad block or on disks where the drivers do not support the bad-blocking standard -.Nm badsect +.Nm may be used to good effect. .Pp .Nm Badsect @@ -74,8 +74,8 @@ is used on a quiet file system in the following way: First mount the file system, and change to its root directory. Make a directory .Li BAD -there. Run -.Nm badsect +there. Run +.Nm giving as argument the .Ar BAD directory followed by @@ -105,11 +105,11 @@ system call, creating an illegal file whose first block address is the block containing bad sector and whose name is the bad sector number. When it is discovered by -.Xr fsck +.Xr fsck 8 it will ask .Dq Li "HOLD BAD BLOCK ?" A positive response will cause -.Xr fsck +.Xr fsck 8 to convert the inode to a regular file containing the bad block. .Sh SEE ALSO .Xr bad144 8 , @@ -122,7 +122,7 @@ A warning is issued if the block is already in use. .Sh BUGS If more than one sector which comprise a file system fragment are bad, you should specify only one of them to -.Nm badsect , +.Nm Ns , as the blocks in the bad sector files actually cover all the sectors in a file system fragment. .Sh HISTORY diff --git a/sbin/badsect/badsect.c b/sbin/badsect/badsect.c index 4526c1b88648a..704f92c42e8c2 100644 --- a/sbin/badsect/badsect.c +++ b/sbin/badsect/badsect.c @@ -38,7 +38,11 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint +#if 0 static const char sccsid[] = "@(#)badsect.c 8.1 (Berkeley) 6/5/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ /* @@ -57,6 +61,7 @@ static const char sccsid[] = "@(#)badsect.c 8.1 (Berkeley) 6/5/93"; #include <ufs/ffs/fs.h> #include <ufs/ufs/dinode.h> +#include <err.h> #include <dirent.h> #include <fcntl.h> #include <paths.h> @@ -84,6 +89,13 @@ char buf[MAXBSIZE]; void rdfs __P((daddr_t, int, char *)); int chkuse __P((daddr_t, int)); +static void +usage(void) +{ + fprintf(stderr, "usage: badsect bbdir blkno ...\n"); + exit(1); +} + int main(argc, argv) int argc; @@ -97,26 +109,18 @@ main(argc, argv) char name[2 * MAXPATHLEN]; char *name_dir_end; - if (argc < 3) { - fprintf(stderr, "usage: badsect bbdir blkno [ blkno ]\n"); - exit(1); - } - if (chdir(argv[1]) < 0 || stat(".", &stbuf) < 0) { - perror(argv[1]); - exit(2); - } + if (argc < 3) + usage(); + if (chdir(argv[1]) < 0 || stat(".", &stbuf) < 0) + err(2, "%s", argv[1]); strcpy(name, _PATH_DEV); - if ((dirp = opendir(name)) == NULL) { - perror(name); - exit(3); - } + if ((dirp = opendir(name)) == NULL) + err(3, "%s", name); name_dir_end = name + strlen(name); while ((dp = readdir(dirp)) != NULL) { strcpy(name_dir_end, dp->d_name); - if (lstat(name, &devstat) < 0) { - perror(name); - exit(4); - } + if (lstat(name, &devstat) < 0) + err(4, "%s", name); if (stbuf.st_dev == devstat.st_rdev && (devstat.st_mode & IFMT) == IFBLK) break; @@ -124,7 +128,7 @@ main(argc, argv) closedir(dirp); if (dp == NULL) { printf("Cannot find dev 0%lo corresponding to %s\n", - stbuf.st_rdev, argv[1]); + (u_long)stbuf.st_rdev, argv[1]); exit(5); } /* @@ -133,10 +137,8 @@ main(argc, argv) */ memcpy(name_dir_end + 1, name_dir_end, strlen(name_dir_end) + 1); *name_dir_end = 'r'; - if ((fsi = open(name, O_RDONLY)) < 0) { - perror(name); - exit(6); - } + if ((fsi = open(name, O_RDONLY)) < 0) + err(6, "%s", name); fs = &sblock; rdfs(SBOFF, SBSIZE, (char *)fs); dev_bsize = fs->fs_fsize / fsbtodb(fs, 1); @@ -153,11 +155,11 @@ main(argc, argv) diskbn = dbtofsb(fs, number); if ((dev_t)diskbn != diskbn) { printf("sector %ld cannot be represented as a dev_t\n", - number); + (long)number); errs++; } else if (mknod(*argv, IFMT|0600, (dev_t)diskbn) < 0) { - perror(*argv); + warn("%s", *argv); errs++; } } @@ -175,20 +177,20 @@ chkuse(blkno, cnt) fsbn = dbtofsb(fs, blkno); if ((unsigned)(fsbn+cnt) > fs->fs_size) { - printf("block %ld out of range of file system\n", blkno); + printf("block %ld out of range of file system\n", (long)blkno); return (1); } cg = dtog(fs, fsbn); if (fsbn < cgdmin(fs, cg)) { if (cg == 0 || (fsbn+cnt) > cgsblock(fs, cg)) { printf("block %ld in non-data area: cannot attach\n", - blkno); + (long)blkno); return (1); } } else { if ((fsbn+cnt) > cgbase(fs, cg+1)) { printf("block %ld in non-data area: cannot attach\n", - blkno); + (long)blkno); return (1); } } @@ -201,7 +203,7 @@ chkuse(blkno, cnt) } bn = dtogd(fs, fsbn); if (isclr(cg_blksfree(&acg), bn)) - printf("Warning: sector %ld is in use\n", blkno); + printf("Warning: sector %ld is in use\n", (long)blkno); return (0); } @@ -217,14 +219,12 @@ rdfs(bno, size, bf) int n; if (lseek(fsi, (off_t)bno * dev_bsize, SEEK_SET) < 0) { - printf("seek error: %ld\n", bno); - perror("rdfs"); - exit(1); + printf("seek error: %ld\n", (long)bno); + err(1, "rdfs"); } n = read(fsi, bf, size); if (n != size) { - printf("read error: %ld\n", bno); - perror("rdfs"); - exit(1); + printf("read error: %ld\n", (long)bno); + err(1, "rdfs"); } } diff --git a/sbin/ccdconfig/ccdconfig.8 b/sbin/ccdconfig/ccdconfig.8 index 3dfe787e49cc1..16974e3b505c3 100644 --- a/sbin/ccdconfig/ccdconfig.8 +++ b/sbin/ccdconfig/ccdconfig.8 @@ -12,7 +12,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" This product includes software developed for the NetBSD Project .\" by Jason R. Thorpe. .\" 4. The name of the author may not be used to endorse or promote products @@ -30,6 +30,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" +.\" $Id$ +.\" .Dd July 17, 1995 .Dt CCDCONFIG 8 .Os FreeBSD @@ -43,7 +45,7 @@ .Ar ileave .Op Ar flags .Ar dev -.Op Ar ... +.Op Ar .Nm ccdconfig .Fl C .Op Fl v @@ -52,7 +54,7 @@ .Fl u .Op Fl v .Ar ccd -.Op Ar ... +.Op Ar .Nm ccdconfig .Fl U .Op Fl v @@ -75,7 +77,7 @@ The options are as follows: .Bl -tag -width indent .It Fl c Configure a ccd. This is the default behavior of -.Nm ccdconfig . +.Nm Ns . .It Fl C Configure all ccd devices listed in the ccd configuration file. .It Fl f Ar config_file @@ -102,8 +104,8 @@ Unconfigure a ccd. .It Fl U Unconfigure all ccd devices listed the ccd configuration file. .It Fl v -Causes -.Nm ccdconfig +Cause +.Nm to be verbose. .El .Pp @@ -145,12 +147,15 @@ interleave factor of 32 blocks. .Ed .Pp .Sh FILES -/etc/ccd.conf - default ccd configuration file. +.Bl -tag -width /etc/ccd.conf -compact +.It Pa /etc/ccd.conf +default ccd configuration file +.El .Sh SEE ALSO .Xr ccd 4 , -.Xr rc 8 . +.Xr rc 8 .Sh HISTORY The -.Nm ccdconfig +.Nm command first appeared in .Nx 1.0a . diff --git a/sbin/clri/clri.8 b/sbin/clri/clri.8 index 7ac225daa57be..937ed35f8378f 100644 --- a/sbin/clri/clri.8 +++ b/sbin/clri/clri.8 @@ -10,7 +10,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" 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 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)clri.8 8.2 (Berkeley) 4/19/94 -.\" $Id: clri.8,v 1.5 1997/02/22 14:32:11 peter Exp $ +.\" $Id: clri.8,v 1.2.2.1 1997/03/03 07:01:14 mpp Exp $ .\" .Dd April 19, 1994 .Dt CLRI 8 @@ -55,8 +55,8 @@ on the filesystem residing on the given The .Xr fsck 8 utility is usually run after -.Nm clri -to reclaim the zero'ed inode(s) and the +.Nm +to reclaim the zeroed inode(s) and the blocks previously claimed by those inode(s). Both read and write permission are required on the specified .Ar special_device . @@ -69,10 +69,10 @@ Once removed, it is anticipated that .Xr fsck 8 will be able to clean up the resulting mess. -.Sh "SEE ALSO" +.Sh SEE ALSO .Xr fsck 8 , .Xr fsdb 8 .Sh BUGS If the file is open, the work of -.Nm clri +.Nm will be lost when the inode is written back to disk from the inode cache. diff --git a/sbin/clri/clri.c b/sbin/clri/clri.c index 97505871e616e..87622b0251a0e 100644 --- a/sbin/clri/clri.c +++ b/sbin/clri/clri.c @@ -35,29 +35,39 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1990, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)clri.c 8.2 (Berkeley) 9/23/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include <sys/param.h> -#include <sys/time.h> +#include <sys/time.h> #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> #include <err.h> -#include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <unistd.h> +static void +usage(void) +{ + (void)fprintf(stderr, "usage: clri filesystem inode ...\n"); + exit(1); +} + int main(argc, argv) int argc; @@ -72,10 +82,8 @@ main(argc, argv) int inonum; char *fs, sblock[SBSIZE]; - if (argc < 3) { - (void)fprintf(stderr, "usage: clri filesystem inode ...\n"); - exit(1); - } + if (argc < 3) + usage(); fs = *++argv; @@ -89,7 +97,7 @@ main(argc, argv) sbp = (struct fs *)sblock; if (sbp->fs_magic != FS_MAGIC) - errx(1, "%s: superblock magic number 0x%x, not 0x%x.", + errx(1, "%s: superblock magic number 0x%x, not 0x%x", fs, sbp->fs_magic, FS_MAGIC); bsize = sbp->fs_bsize; @@ -97,7 +105,7 @@ main(argc, argv) while (*++argv) { /* get the inode number. */ if ((inonum = atoi(*argv)) <= 0) - errx(1, "%s is not a valid inode number.", *argv); + errx(1, "%s is not a valid inode number", *argv); (void)printf("clearing %d\n", inonum); /* read in the appropriate block. */ diff --git a/sbin/disklabel/disklabel.5 b/sbin/disklabel/disklabel.5 index 3cb5b50a33b94..8090bdc5d53d1 100644 --- a/sbin/disklabel/disklabel.5 +++ b/sbin/disklabel/disklabel.5 @@ -13,7 +13,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" 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 @@ -33,6 +33,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)disklabel.5.5 8.1 (Berkeley) 6/5/93 +.\" $Id$ .\" .Dd June 5, 1993 .Dt DISKLABEL 5 @@ -75,7 +76,7 @@ the .Dv DIOCWLABEL .Xr ioctl 2 , which is done as needed by the -.Xr disklabel +.Xr disklabel 8 program. .Pp A copy of the in-core label for a disk can be obtained with the @@ -99,7 +100,7 @@ there must be an existing label on the disk for this operation to succeed. Thus, the initial label for a disk or disk pack must be installed by writing to the raw disk. All of these operations are normally done using -.Xr disklabel . +.Xr disklabel 8 . .Pp The format of the disk label, as specified in .Pa <sys/disklabel.h> , diff --git a/sbin/disklabel/disklabel.8 b/sbin/disklabel/disklabel.8 index 4f35e2f6c3331..1a6fe7655740a 100644 --- a/sbin/disklabel/disklabel.8 +++ b/sbin/disklabel/disklabel.8 @@ -13,7 +13,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" 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 @@ -33,7 +33,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 -.\" $Id: disklabel.8,v 1.3.2.1 1997/03/03 07:01:16 mpp Exp $ +.\" $Id: disklabel.8,v 1.3.2.2 1997/08/25 21:28:37 jkh Exp $ .\" .Dd April 19, 1994 .Dt DISKLABEL 8 @@ -96,7 +96,7 @@ to change the drive identification, the disk partitions on the drive, or to replace a damaged label. On some systems, -.Nm disklabel +.Nm can be used to install bootstrap code as well. There are several forms of the command that read (display), install or edit the label on a disk. @@ -134,8 +134,8 @@ The second form of the command, with the .Fl w flag, is used to write a standard label on the designated drive. The required arguments to -.Nm disklabel -are the drive to be labelled (e.g. sd0), and +.Nm +are the drive to be labeled (e.g. sd0), and the drive type as described in the .Xr disktab 5 file. @@ -199,7 +199,7 @@ was specified. With the .Fl R flag, -.Nm disklabel +.Nm is capable of restoring a disk label that was formatted in a prior operation and saved in an ascii file. The prototype file used to create the label should be in the same format @@ -216,13 +216,13 @@ is specified and will be unaffected otherwise. The .Fl NW flags for -.Nm disklabel +.Nm explicitly disallow and allow, respectively, writing of the pack label area on the selected disk. .Pp The final three forms of -.Nm disklabel -are used to install boostrap code on machines where the bootstrap is part +.Nm +are used to install bootstrap code on machines where the bootstrap is part of the label. The bootstrap code is comprised of one or two boot programs depending on the machine. @@ -349,7 +349,7 @@ allocated for it by some filesystems. As a result, it may not be possible to have filesystems on some partitions of a ``bootable'' disk. When installing bootstrap code, -.Nm disklabel +.Nm checks for these cases. If the installed boot code would overlap a partition of type FS_UNUSED it is marked as type FS_BOOT. @@ -357,11 +357,11 @@ The .Xr newfs 8 utility will disallow creation of filesystems on FS_BOOT partitions. Conversely, if a partition has a type other than FS_UNUSED or FS_BOOT, -.Nm disklabel +.Nm will not install bootstrap code that overlaps it. .Sh BUGS When a disk name is given without a full pathname, -the constructed device name uses the ``a'' partition on the tahoe, +the constructed device name uses the ``a'' partition on the Tahoe, the ``c'' partition on all others. .Pp For the i386 architecture, the primary bootstrap sector contains diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index ce42dfddd312b..4f5dfabf68473 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: disklabel.c,v 1.9.2.2 1997/06/11 07:02:16 charnier Exp $ + * $Id: disklabel.c,v 1.9.2.3 1997/08/25 21:28:37 jkh Exp $ */ #ifndef lint @@ -121,7 +121,6 @@ char *dkname; char *specname; char tmpfil[] = _PATH_TMP; -extern int errno; char namebuf[BBSIZE], *np = namebuf; struct disklabel lab; struct disklabel *readlabel(), *makebootarea(); @@ -155,8 +154,6 @@ main(argc, argv) int argc; char *argv[]; { - extern char *optarg; - extern int optind; register struct disklabel *lp; FILE *t; int ch, f, flag, error = 0; @@ -344,10 +341,8 @@ makelabel(type, name, lp) dp = getvirginlabel(); else dp = getdiskbyname(type); - if (dp == NULL) { - fprintf(stderr, "%s: unknown disk type\n", type); - exit(1); - } + if (dp == NULL) + errx(1, "%s: unknown disk type", type); *lp = *dp; #if NUMBOOT > 0 /* @@ -419,9 +414,9 @@ writelabel(f, boot, lp) */ flag = 1; if (ioctl(f, DIOCWLABEL, &flag) < 0) - perror("ioctl DIOCWLABEL"); + warn("ioctl DIOCWLABEL"); if (write(f, boot, lp->d_bbsize) != lp->d_bbsize) { - perror("write"); + warn("write"); return (1); } #if NUMBOOT > 0 @@ -429,7 +424,7 @@ writelabel(f, boot, lp) * Output the remainder of the disklabel */ if (bootbuf && write(f, bootbuf, bootsize) != bootsize) { - perror("write"); + warn("write"); return(1); } #endif @@ -447,12 +442,8 @@ writelabel(f, boot, lp) for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) { (void)lseek(f, (off_t)((alt + i) * lp->d_secsize), SEEK_SET); - if (write(f, boot, lp->d_secsize) < lp->d_secsize) { - int oerrno = errno; - fprintf(stderr, "alternate label %d ", i/2); - errno = oerrno; - perror("write"); - } + if (write(f, boot, lp->d_secsize) < lp->d_secsize) + warn("alternate label %d write", i/2); } } #endif @@ -463,35 +454,30 @@ void l_perror(s) char *s; { - int saverrno = errno; - - fprintf(stderr, "disklabel: %s: ", s); - - switch (saverrno) { + switch (errno) { case ESRCH: - fprintf(stderr, "No disk label on disk;\n"); + warnx("%s: no disk label on disk;", s); fprintf(stderr, - "use \"disklabel -r\" to install initial label\n"); + "use \"disklabel -r\" to install initial label\n"); break; case EINVAL: - fprintf(stderr, "Label magic number or checksum is wrong!\n"); + warnx("%s: label magic number or checksum is wrong!", s); fprintf(stderr, "(disklabel or kernel is out of date?)\n"); break; case EBUSY: - fprintf(stderr, "Open partition would move or shrink\n"); + warnx("%s: open partition would move or shrink", s); break; case EXDEV: - fprintf(stderr, - "Labeled partition or 'a' partition must start at beginning of disk\n"); + warnx( + "%s: labeled partition or 'a' partition must start at beginning of disk", s); break; default: - errno = saverrno; - perror((char *)NULL); + warn((char *)NULL); break; } } @@ -517,12 +503,9 @@ readlabel(f) break; if (lp > (struct disklabel *)(bootarea+BBSIZE-sizeof(*lp)) || lp->d_magic != DISKMAGIC || lp->d_magic2 != DISKMAGIC || - dkcksum(lp) != 0) { - fprintf(stderr, - "Bad pack magic number (label is damaged, or pack is unlabeled)\n"); - /* lp = (struct disklabel *)(bootarea + LABELOFFSET); */ - exit (1); - } + dkcksum(lp) != 0) + errx(1, + "bad pack magic number (label is damaged, or pack is unlabeled)"); } else { lp = &lab; if (ioctl(f, DIOCGDINFO, lp) < 0) @@ -690,11 +673,8 @@ makebootarea(boot, dp, f) * reserved for the label. */ for (p = (char *)lp; p < (char *)lp + sizeof(struct disklabel); p++) - if (*p) { - fprintf(stderr, - "Bootstrap doesn't leave room for disk label\n"); - exit(2); - } + if (*p) + errx(2, "bootstrap doesn't leave room for disk label"); return (lp); } @@ -710,7 +690,7 @@ display(f, lp) if ((unsigned) lp->d_type < DKMAXTYPES) fprintf(f, "type: %s\n", dktypenames[lp->d_type]); else - fprintf(f, "type: %d\n", lp->d_type); + fprintf(f, "type: %u\n", lp->d_type); fprintf(f, "disk: %.*s\n", (int)sizeof(lp->d_typename), lp->d_typename); fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname), @@ -723,19 +703,20 @@ display(f, lp) if (lp->d_flags & D_BADSECT) fprintf(f, " badsect"); fprintf(f, "\n"); - fprintf(f, "bytes/sector: %ld\n", lp->d_secsize); - fprintf(f, "sectors/track: %ld\n", lp->d_nsectors); - fprintf(f, "tracks/cylinder: %ld\n", lp->d_ntracks); - fprintf(f, "sectors/cylinder: %ld\n", lp->d_secpercyl); - fprintf(f, "cylinders: %ld\n", lp->d_ncylinders); - fprintf(f, "sectors/unit: %ld\n", lp->d_secperunit); - fprintf(f, "rpm: %d\n", lp->d_rpm); - fprintf(f, "interleave: %d\n", lp->d_interleave); - fprintf(f, "trackskew: %d\n", lp->d_trackskew); - fprintf(f, "cylinderskew: %d\n", lp->d_cylskew); - fprintf(f, "headswitch: %ld\t\t# milliseconds\n", lp->d_headswitch); + fprintf(f, "bytes/sector: %lu\n", (u_long)lp->d_secsize); + fprintf(f, "sectors/track: %lu\n", (u_long)lp->d_nsectors); + fprintf(f, "tracks/cylinder: %lu\n", (u_long)lp->d_ntracks); + fprintf(f, "sectors/cylinder: %lu\n", (u_long)lp->d_secpercyl); + fprintf(f, "cylinders: %lu\n", (u_long)lp->d_ncylinders); + fprintf(f, "sectors/unit: %lu\n", (u_long)lp->d_secperunit); + fprintf(f, "rpm: %u\n", lp->d_rpm); + fprintf(f, "interleave: %u\n", lp->d_interleave); + fprintf(f, "trackskew: %u\n", lp->d_trackskew); + fprintf(f, "cylinderskew: %u\n", lp->d_cylskew); + fprintf(f, "headswitch: %lu\t\t# milliseconds\n", + (u_long)lp->d_headswitch); fprintf(f, "track-to-track seek: %ld\t# milliseconds\n", - lp->d_trkseek); + (u_long)lp->d_trkseek); fprintf(f, "drivedata: "); for (i = NDDATA - 1; i >= 0; i--) if (lp->d_drivedata[i]) @@ -743,15 +724,15 @@ display(f, lp) if (i < 0) i = 0; for (j = 0; j <= i; j++) - fprintf(f, "%ld ", lp->d_drivedata[j]); - fprintf(f, "\n\n%d partitions:\n", lp->d_npartitions); + fprintf(f, "%lu ", (u_long)lp->d_drivedata[j]); + fprintf(f, "\n\n%u partitions:\n", lp->d_npartitions); fprintf(f, "# size offset fstype [fsize bsize bps/cpg]\n"); pp = lp->d_partitions; for (i = 0; i < lp->d_npartitions; i++, pp++) { if (pp->p_size) { - fprintf(f, " %c: %8ld %8ld ", 'a' + i, - pp->p_size, pp->p_offset); + fprintf(f, " %c: %8lu %8lu ", 'a' + i, + (u_long)pp->p_size, (u_long)pp->p_offset); if ((unsigned) pp->p_fstype < FSMAXTYPES) fprintf(f, "%8.8s", fstypenames[pp->p_fstype]); else @@ -759,19 +740,22 @@ display(f, lp) switch (pp->p_fstype) { case FS_UNUSED: /* XXX */ - fprintf(f, " %5ld %5ld %5.5s ", - pp->p_fsize, pp->p_fsize * pp->p_frag, ""); + fprintf(f, " %5lu %5lu %5.5s ", + (u_long)pp->p_fsize, + (u_long)(pp->p_fsize * pp->p_frag), ""); break; case FS_BSDFFS: - fprintf(f, " %5ld %5ld %5d ", - pp->p_fsize, pp->p_fsize * pp->p_frag, + fprintf(f, " %5lu %5lu %5u ", + (u_long)pp->p_fsize, + (u_long)(pp->p_fsize * pp->p_frag), pp->p_cpg); break; case FS_BSDLFS: - fprintf(f, " %5ld %5ld %5d", - pp->p_fsize, pp->p_fsize * pp->p_frag, + fprintf(f, " %5lu %5lu %5d", + (u_long)pp->p_fsize, + (u_long)(pp->p_fsize * pp->p_frag), pp->p_cpg); break; @@ -779,16 +763,16 @@ display(f, lp) fprintf(f, "%20.20s", ""); break; } - fprintf(f, "\t# (Cyl. %4ld", - pp->p_offset / lp->d_secpercyl); + fprintf(f, "\t# (Cyl. %4lu", + (u_long)(pp->p_offset / lp->d_secpercyl)); if (pp->p_offset % lp->d_secpercyl) putc('*', f); else putc(' ', f); - fprintf(f, "- %ld", - (pp->p_offset + - pp->p_size + lp->d_secpercyl - 1) / - lp->d_secpercyl - 1); + fprintf(f, "- %lu", + (u_long)((pp->p_offset + pp->p_size + + lp->d_secpercyl - 1) / + lp->d_secpercyl - 1)); if (pp->p_size % lp->d_secpercyl) putc('*', f); fprintf(f, ")\n"); @@ -808,7 +792,7 @@ edit(lp, f) if ((fd = mkstemp(tmpfil)) == -1 || (fp = fdopen(fd, "w")) == NULL) { - fprintf(stderr, "%s: Can't create\n", tmpfil); + warnx("can't create %s", tmpfil); return (1); } display(fp, lp); @@ -818,8 +802,7 @@ edit(lp, f) break; fp = fopen(tmpfil, "r"); if (fp == NULL) { - fprintf(stderr, "%s: Can't reopen for reading\n", - tmpfil); + warnx("can't reopen %s for reading", tmpfil); break; } bzero((char *)&label, sizeof(label)); @@ -856,11 +839,11 @@ editit() extern int errno; if (errno == EPROCLIM) { - fprintf(stderr, "You have too many processes\n"); + warnx("you have too many processes"); return(0); } if (errno != EAGAIN) { - perror("fork"); + warn("fork"); return(0); } sleep(1); @@ -874,8 +857,7 @@ editit() if ((ed = getenv("EDITOR")) == (char *)0) ed = DEFEDITOR; execlp(ed, ed, tmpfil, 0); - perror(ed); - exit(1); + err(1, "%s", ed); } while ((xpid = wait(&stat)) >= 0) if (xpid == pid) @@ -1242,46 +1224,46 @@ checklabel(lp) char part; if (lp->d_secsize == 0) { - fprintf(stderr, "sector size %ld\n", lp->d_secsize); + fprintf(stderr, "sector size 0\n"); return (1); } if (lp->d_nsectors == 0) { - fprintf(stderr, "sectors/track %ld\n", lp->d_nsectors); + fprintf(stderr, "sectors/track 0\n"); return (1); } if (lp->d_ntracks == 0) { - fprintf(stderr, "tracks/cylinder %ld\n", lp->d_ntracks); + fprintf(stderr, "tracks/cylinder 0\n"); return (1); } if (lp->d_ncylinders == 0) { - fprintf(stderr, "cylinders/unit %ld\n", lp->d_ncylinders); + fprintf(stderr, "cylinders/unit 0\n"); errors++; } if (lp->d_rpm == 0) - Warning("revolutions/minute %d", lp->d_rpm); + Warning("revolutions/minute 0"); if (lp->d_secpercyl == 0) lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks; if (lp->d_secperunit == 0) lp->d_secperunit = lp->d_secpercyl * lp->d_ncylinders; if (lp->d_bbsize == 0) { - fprintf(stderr, "boot block size %ld\n", lp->d_bbsize); + fprintf(stderr, "boot block size 0\n"); errors++; } else if (lp->d_bbsize % lp->d_secsize) Warning("boot block size %% sector-size != 0"); if (lp->d_sbsize == 0) { - fprintf(stderr, "super block size %ld\n", lp->d_sbsize); + fprintf(stderr, "super block size 0\n"); errors++; } else if (lp->d_sbsize % lp->d_secsize) Warning("super block size %% sector-size != 0"); if (lp->d_npartitions > MAXPARTITIONS) - Warning("number of partitions (%d) > MAXPARTITIONS (%d)", - lp->d_npartitions, MAXPARTITIONS); + Warning("number of partitions (%lu) > MAXPARTITIONS (%d)", + (u_long)lp->d_npartitions, MAXPARTITIONS); for (i = 0; i < lp->d_npartitions; i++) { part = 'a' + i; pp = &lp->d_partitions[i]; if (pp->p_size == 0 && pp->p_offset != 0) - Warning("partition %c: size 0, but offset %d", - part, pp->p_offset); + Warning("partition %c: size 0, but offset %lu", + part, (u_long)pp->p_offset); #ifdef notdef if (pp->p_size % lp->d_secpercyl) Warning("partition %c: size %% cylinder-size != 0", @@ -1306,8 +1288,8 @@ checklabel(lp) part = 'a' + i; pp = &lp->d_partitions[i]; if (pp->p_size || pp->p_offset) - Warning("unused partition %c: size %d offset %d", - 'a' + i, pp->p_size, pp->p_offset); + Warning("unused partition %c: size %d offset %lu", + 'a' + i, pp->p_size, (u_long)pp->p_offset); } return (errors); } @@ -1387,10 +1369,8 @@ setbootflag(lp) } } } - if (errors) { - fprintf(stderr, "Cannot install boot program\n"); - exit(4); - } + if (errors) + errx(4, "cannot install boot program"); } /*VARARGS1*/ diff --git a/sbin/dmesg/dmesg.8 b/sbin/dmesg/dmesg.8 index b3648fcb8ba62..af9da83288676 100644 --- a/sbin/dmesg/dmesg.8 +++ b/sbin/dmesg/dmesg.8 @@ -10,7 +10,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" 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 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)dmesg.8 8.1 (Berkeley) 6/5/93 +.\" $Id$ .\" .Dd June 5, 1993 .Dt DMESG 8 @@ -46,21 +47,24 @@ displays the contents of the system message buffer. .Pp The options are as follows: -.Bl -tag -width Ds +.Bl -tag -width indent .It Fl M Extract values associated with the name list from the specified core -instead of the default ``/dev/kmem''. +instead of the default +.Pa /dev/kmem . .It Fl N Extract the name list from the specified system instead of the default -``/kernel''. +.Pa /kernel . .El .Sh SEE ALSO .Xr syslogd 8 .Sh FILES -/dev/mem -/dev/kmem -/dev/drum -/kernel +.Bl -tag -width /etc/kmem -compact +.It Pa /dev/mem +.It Pa /dev/kmem +.It Pa /dev/drum +.It Pa /kernel +.El .Sh HISTORY The .Nm diff --git a/sbin/dset/dset.c b/sbin/dset/dset.c index 2428289bcc186..f3eecbd3b7838 100644 --- a/sbin/dset/dset.c +++ b/sbin/dset/dset.c @@ -13,21 +13,23 @@ * Device configuration to kernel image saving utility. */ -#include <stdio.h> -#include <nlist.h> -#include <paths.h> -#include <unistd.h> +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ + +#include <err.h> #include <fcntl.h> -#include <a.out.h> #include <kvm.h> +#include <a.out.h> #include <limits.h> +#include <paths.h> +#include <stdio.h> +#include <string.h> #include <unistd.h> -#include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> -#include <sys/uio.h> #include <sys/param.h> -#include <machine/param.h> #include "i386/isa/isa_device.h" #include "i386/isa/pnp.h" @@ -37,8 +39,6 @@ struct pnp_cinfo old_ov[MAX_PNP_LDN]; #define TRUE 1 #define FALSE 0 -extern int errno; - struct nlist nl[] = { #define N_TABTTY 0 {"_isa_devtab_tty"}, @@ -48,13 +48,13 @@ struct nlist nl[] = { {"_isa_devtab_net"}, #define N_TABNULL 3 {"_isa_devtab_null"}, - "", + {""}, }; #define N_TABLAST N_TABNULL struct nlist nlk[] = { {"_isa_devlist"}, - "", + {""}, }; struct nlist nlaux[] = { @@ -81,10 +81,9 @@ fatal(name, str) if (quiet) exit(1); if (str) - fprintf(stderr, "%s : %s\n", name, str); + errx(1, "%s: %s", name, str); else - perror(name); - exit(1); + errx(1, "%s", name); } void @@ -94,17 +93,19 @@ error(name, str) if (quiet) return; if (str) - fprintf(stderr, "%s : %s\n", name, str); + warnx("%s: %s", name, str); else - perror(name); + warnx("%s", name); } void -usage(char *title) +usage() { - fprintf(stderr, "usage: %s [-qtv]\n", title); + fprintf(stderr, "usage: dset [-qtv]\n"); + exit(1); } +int main(ac, av) int ac; char **av; @@ -123,7 +124,6 @@ main(ac, av) static char errb[_POSIX2_LINE_MAX]; const char *kernel = NULL; - extern char *optarg; char ch; int testonly = FALSE; int verbose = FALSE; @@ -143,8 +143,7 @@ main(ac, av) case '?': default: - usage(av[0]); - exit(1); + usage(); } @@ -243,14 +242,14 @@ main(ac, av) if (buf1.id_id != 0) if (verbose) printf( - "kernel: id=%u io=%X irq=%d drq=%d maddr=%X msize=%d flags=%X enabled=%X \n", + "kernel: id=%u io=%X irq=%d drq=%d maddr=%p msize=%d flags=%X enabled=%X \n", buf1.id_id, buf1.id_iobase, buf1.id_irq, buf1.id_drq, buf1.id_maddr, buf1.id_msize, buf1.id_flags, buf1.id_enabled); if (buf.id_id != 0) if (verbose) printf( - "file: id=%u io=%X irq=%d drq=%d maddr=%X msize=%d flags=%X enabled=%X \n", + "file: id=%u io=%X irq=%d drq=%d maddr=%p msize=%d flags=%X enabled=%X \n", buf.id_id, buf.id_iobase, buf.id_irq, buf.id_drq, buf.id_maddr, buf.id_msize, buf.id_flags, buf.id_enabled); @@ -398,7 +397,7 @@ main(ac, av) if (new_ov[i].vendor_id > 0) printf(" 0x%08x", new_ov[i].vendor_id); if (new_ov[i].flags > 0) - printf(" flags 0x%08x", new_ov[i].flags); + printf(" flags 0x%08lx", new_ov[i].flags); if (maxp >=0) { int j; printf(" port 0x%x", new_ov[i].port[0]); @@ -407,9 +406,9 @@ main(ac, av) } if (maxm >=0) { int j; - printf(" mem 0x%x", new_ov[i].mem[0].base); + printf(" mem 0x%lx", new_ov[i].mem[0].base); for(j=1;j<=maxm;j++) - printf(" 0x%x", new_ov[i].mem[j].base); + printf(" 0x%lx", new_ov[i].mem[j].base); } printf("\n"); } @@ -428,4 +427,5 @@ main(ac, av) kvm_close(kd); close(f); + return(0); } diff --git a/sbin/dump/dump.8 b/sbin/dump/dump.8 index 209dc81462f94..b048ce18845de 100644 --- a/sbin/dump/dump.8 +++ b/sbin/dump/dump.8 @@ -11,7 +11,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" 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 @@ -31,7 +31,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)dump.8 8.1 (Berkeley) 6/16/93 -.\" $Id: dump.8,v 1.5.2.7 1998/01/03 20:28:13 steve Exp $ +.\" $Id: dump.8,v 1.5.2.8 1998/05/10 16:36:47 steve Exp $ .\" .Dd June 16, 1993 .Dt DUMP 8 @@ -85,7 +85,7 @@ By default, the same output file name is used for each volume after prompting the operator to change media. .Pp The following options are supported by -.Nm dump : +.Nm Ns : .Bl -tag -width Ds .It Fl 0\-9 Dump levels. @@ -154,7 +154,7 @@ If the name of the file is of the form .Dq host:file , or .Dq user@host:file , -.Nm dump +.Nm writes to the named file on the remote host using .Xr rmt 8 . The default path name of the remote @@ -167,11 +167,11 @@ this can be overridden by the environment variable .It Fl k Use Kerberos authentication to talk to remote tape servers. (Only available if this option was enabled when -.Nm dump +.Nm was compiled.) .It Fl n Whenever -.Nm dump +.Nm requires operator attention, notify all operators in the group .Dq operator @@ -181,7 +181,7 @@ by means similar to a Attempt to calculate the amount of tape needed at a particular density. If this amount is exceeded, -.Nm dump +.Nm prompts for a new tape. It is recommended to be a bit conservative on this option. The default tape length is 2300 feet. @@ -227,7 +227,7 @@ and The .Fl W option causes -.Nm dump +.Nm to print out, for each file system in .Pa /etc/dumpdates the most recent dump date and level, @@ -235,7 +235,7 @@ and highlights those file systems that should be dumped. If the .Fl W option is set, all other options are ignored, and -.Nm dump +.Nm exits immediately. .It Fl w Is like W, but prints only those filesystems which need to be dumped. @@ -251,15 +251,15 @@ disk read error (if there are more than a threshold of 32). In addition to alerting all operators implied by the .Fl n key, -.Nm dump +.Nm interacts with the operator on .Em dump's control terminal at times when -.Nm dump +.Nm can no longer proceed, or if something is grossly wrong. All questions -.Nm dump +.Nm poses .Em must be answered by typing @@ -269,10 +269,10 @@ or appropriately. .Pp Since making a dump involves a lot of time and effort for full dumps, -.Nm dump +.Nm checkpoints itself at the start of each tape volume. If writing that volume fails for some reason, -.Nm dump +.Nm will, with operator permission, restart itself from the checkpoint @@ -287,7 +287,7 @@ the time to the tape change. The output is verbose, so that others know that the terminal controlling -.Nm dump +.Nm is busy, and will be for some time. .Pp @@ -364,7 +364,7 @@ Currently, .Xr physio 9 slices all requests into chunks of 64 KB. Therefore, it is impossible to use a larger tape blocksize, so -.Nm dump +.Nm will prevent this from happening. .Pp .Nm Dump @@ -379,7 +379,7 @@ even if listed in .Pa /etc/fstab . .Pp It would be nice if -.Nm dump +.Nm knew about the dump sequence, kept track of the tapes scribbled on, told the operator which tape to mount when, @@ -387,13 +387,14 @@ and provided more assistance for the operator running .Xr restore . .Pp -.Nm dump +.Nm Dump cannot do remote backups without being run as root, due to its -security history. This will be fixed in a later version of FreeBSD. +security history. This will be fixed in a later version of +.Bx Free . Presently, it works if you set it setuid (like it used to be), but this might constitute a security risk. .Sh HISTORY A -.Nm dump +.Nm command appeared in .At v6 . diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h index 6053198f57e70..2c907a9573892 100644 --- a/sbin/dump/dump.h +++ b/sbin/dump/dump.h @@ -144,6 +144,7 @@ void interrupt __P((int signo)); /* in case operator bangs on console */ * Exit status codes */ #define X_FINOK 0 /* normal exit */ +#define X_STARTUP 1 /* startup error */ #define X_REWRITE 2 /* restart writing from the check point */ #define X_ABORT 3 /* abort dump; don't attempt checkpointing */ diff --git a/sbin/dump/dumprmt.c b/sbin/dump/dumprmt.c index 6420eaad260e3..d2cffe2fe5054 100644 --- a/sbin/dump/dumprmt.c +++ b/sbin/dump/dumprmt.c @@ -32,12 +32,15 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)dumprmt.c 8.3 (Berkeley) 4/28/95"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include <sys/param.h> #include <sys/mtio.h> -#include <sys/ioctl.h> #include <sys/socket.h> #include <sys/time.h> #ifdef sunos @@ -56,10 +59,8 @@ static char sccsid[] = "@(#)dumprmt.c 8.3 (Berkeley) 4/28/95"; #include <protocols/dumprestore.h> #include <ctype.h> -#include <err.h> #include <netdb.h> #include <pwd.h> -#include <signal.h> #include <stdio.h> #ifdef __STDC__ #include <stdlib.h> @@ -153,19 +154,19 @@ rmtgetconn() if (sp == NULL) { msg("%s/tcp: unknown service\n", dokerberos ? "kshell" : "shell"); - exit(X_ABORT); + exit(X_STARTUP); } pwd = getpwuid(getuid()); if (pwd == NULL) { msg("who are you?\n"); - exit(X_ABORT); + exit(X_STARTUP); } } if ((cp = strchr(rmtpeer, '@')) != NULL) { tuser = rmtpeer; *cp = '\0'; if (!okname(tuser)) - exit(X_ABORT); + exit(X_STARTUP); rmtpeer = ++cp; } else tuser = pwd->pw_name; diff --git a/sbin/dump/itime.c b/sbin/dump/itime.c index 94656ac649e3e..483533eb7f824 100644 --- a/sbin/dump/itime.c +++ b/sbin/dump/itime.c @@ -32,7 +32,11 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)itime.c 8.1 (Berkeley) 6/5/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include <sys/param.h> @@ -55,7 +59,6 @@ static char sccsid[] = "@(#)itime.c 8.1 (Berkeley) 6/5/93"; #ifdef __STDC__ #include <stdlib.h> #include <string.h> -#include <unistd.h> #endif #include "dump.h" diff --git a/sbin/dump/main.c b/sbin/dump/main.c index d838160952ab5..b85b383c97f76 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: main.c,v 1.7.2.6 1997/10/15 18:30:35 markm Exp $ */ #ifndef lint @@ -59,7 +59,6 @@ static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95"; #include <ctype.h> #include <err.h> -#include <errno.h> #include <fcntl.h> #include <fstab.h> #include <signal.h> @@ -158,7 +157,7 @@ main(argc, argv) */ if ( ntrec > 64 ) { msg("please choose a blocksize <= 64\n"); - exit(X_ABORT); + exit(X_STARTUP); } break; @@ -199,7 +198,7 @@ main(argc, argv) if (spcl.c_ddate < 0) { (void)fprintf(stderr, "bad time \"%s\"\n", optarg); - exit(X_ABORT); + exit(X_STARTUP); } Tflag = 1; lastlevel = '?'; @@ -214,7 +213,7 @@ main(argc, argv) case 'W': /* what to do */ case 'w': lastdump(ch); - exit(0); /* do nothing else */ + exit(X_FINOK); /* do nothing else */ default: usage(); @@ -224,7 +223,7 @@ main(argc, argv) if (argc < 1) { (void)fprintf(stderr, "Must specify disk or filesystem\n"); - exit(X_ABORT); + exit(X_STARTUP); } disk = *argv++; argc--; @@ -233,12 +232,12 @@ main(argc, argv) while (argc--) (void)fprintf(stderr, " %s", *argv++); (void)fprintf(stderr, "\n"); - exit(X_ABORT); + exit(X_STARTUP); } if (Tflag && uflag) { (void)fprintf(stderr, "You cannot use the T and u flags together.\n"); - exit(X_ABORT); + exit(X_STARTUP); } if (strcmp(tape, "-") == 0) { pipeout++; @@ -271,13 +270,13 @@ main(argc, argv) #ifdef RDUMP if (index(tape, '\n')) { (void)fprintf(stderr, "invalid characters in tape\n"); - exit(X_ABORT); + exit(X_STARTUP); } if (rmthost(host) == 0) - exit(X_ABORT); + exit(X_STARTUP); #else (void)fprintf(stderr, "remote dump not enabled\n"); - exit(X_ABORT); + exit(X_STARTUP); #endif } (void)setuid(getuid()); /* rmthost() is the only reason to be setuid */ @@ -338,7 +337,7 @@ main(argc, argv) if ((diskfd = open(disk, O_RDONLY)) < 0) { msg("Cannot open %s\n", disk); - exit(X_ABORT); + exit(X_STARTUP); } sync(); sblock = (struct fs *)sblock_buf; @@ -423,7 +422,8 @@ main(argc, argv) * Allocate tape buffer. */ if (!alloctape()) - quit("can't allocate tape buffers - try a smaller blocking factor.\n"); + quit( + "can't allocate tape buffers - try a smaller blocking factor.\n"); startnewtape(1); (void)time((time_t *)&(tstart_writing)); @@ -504,7 +504,7 @@ usage() "nu] [-B records] [-b blocksize] [-d density] [-f file]\n" " [-h level] [-s feet] [-T date] filesystem\n" " dump [-W | -w]\n"); - exit(1); + exit(X_STARTUP); } /* @@ -640,7 +640,7 @@ obsolete(argcp, argvp) } /* Copy remaining arguments. */ - while (*nargv++ = *argv++); + while ((*nargv++ = *argv++)); /* Update argument count. */ *argcp = nargv - *argvp - 1; diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c index 28faacfb29294..3aaea24deda31 100644 --- a/sbin/dumpfs/dumpfs.c +++ b/sbin/dumpfs/dumpfs.c @@ -32,28 +32,29 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1983, 1992, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)dumpfs.c 8.5 (Berkeley) 4/29/95"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include <sys/param.h> #include <sys/time.h> -#include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> #include <err.h> -#include <errno.h> #include <fcntl.h> #include <fstab.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> #include <unistd.h> union { @@ -107,15 +108,22 @@ int dumpfs(name) char *name; { + ssize_t n; int fd, c, i, j, k, size; if ((fd = open(name, O_RDONLY, 0)) < 0) goto err; if (lseek(fd, (off_t)SBOFF, SEEK_SET) == (off_t)-1) goto err; - if (read(fd, &afs, SBSIZE) != SBSIZE) + if ((n = read(fd, &afs, SBSIZE)) == -1) goto err; + if (n != SBSIZE) { + warnx("%s: non-existent or truncated superblock, skipped", + name); + (void)close(fd); + return (1); + } if (afs.fs_magic != FS_MAGIC) { warnx("%s: superblock has bad magic number, skipped", name); (void)close(fd); diff --git a/sbin/dumplfs/Makefile b/sbin/dumplfs/Makefile deleted file mode 100644 index 38aa1055daea6..0000000000000 --- a/sbin/dumplfs/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/18/93 -# $Id$ - -PROG= dumplfs -CFLAGS+=-I${.CURDIR}/../../sys/ufs/lfs -SRCS= dumplfs.c lfs_cksum.c misc.c -.PATH: ${.CURDIR}/../../sys/ufs/lfs -MAN8= dumplfs.8 - -.include <bsd.prog.mk> diff --git a/sbin/dumplfs/dumplfs.8 b/sbin/dumplfs/dumplfs.8 deleted file mode 100644 index 713f7234b2b69..0000000000000 --- a/sbin/dumplfs/dumplfs.8 +++ /dev/null @@ -1,60 +0,0 @@ -.\" Copyright (c) 1993 -.\" 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. -.\" -.\" @(#)dumplfs.8 8.1 (Berkeley) 6/18/93 -.\" $Id: dumplfs.8,v 1.2 1996/12/23 23:09:45 wosch Exp $ -.\" -.Dd June 18, 1993 -.Dt DUMPLFS 8 -.Os BSD 4.4 -.Sh NAME -.Nm dumplfs -.Nd dump file system information -.Sh SYNOPSIS -.Nm dumplfs -.Op Ar filesys No \&| Ar device -.Sh DESCRIPTION -.Nm Dumplfs -prints out the file system layout information for the -LFS file system or special device specified. -The listing is very long and detailed. -This command is useful mostly for finding out certain file system -information such as the file system block size. -.Sh SEE ALSO -.Xr disktab 5 , -.Xr fs 5 , -.Xr disklabel 8 , -.Xr newlfs 8 -.Sh HISTORY -The -.Nm dumplfs -command appeared in -.Bx 4.4 . diff --git a/sbin/dumplfs/dumplfs.c b/sbin/dumplfs/dumplfs.c deleted file mode 100644 index 2016ce45c4cfa..0000000000000 --- a/sbin/dumplfs/dumplfs.c +++ /dev/null @@ -1,612 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * 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 -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)dumplfs.c 8.1 (Berkeley) 6/5/93"; -#endif /* not lint */ - -#include <sys/param.h> -#include <sys/ucred.h> -#include <sys/mount.h> -#include <sys/time.h> - -#include <ufs/ufs/dinode.h> -#include <ufs/lfs/lfs.h> - -#include <fcntl.h> -#include <fstab.h> -#include <errno.h> -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include "extern.h" - -static void addseg __P((char *)); -static void dump_cleaner_info __P((struct lfs *, void *)); -static void dump_dinode __P((struct dinode *)); -static void dump_ifile __P((int, struct lfs *, int)); -static int dump_ipage_ifile __P((int, IFILE *, int)); -static int dump_ipage_segusage __P((struct lfs *, int, IFILE *, int)); -static void dump_segment __P((int, int, daddr_t, struct lfs *, int)); -static int dump_sum __P((int, struct lfs *, SEGSUM *, int, daddr_t)); -static void dump_super __P((struct lfs *)); -static void usage __P((void)); - -typedef struct seglist SEGLIST; -struct seglist { - SEGLIST *next; - int num; -}; -SEGLIST *seglist; - -int daddr_shift; -char *special; - -/* Segment Usage formats */ -#define print_suheader \ - (void)printf("segnum\tflags\tnbytes\tninos\tnsums\tlastmod\n") - -#define print_suentry(i, sp) \ - (void)printf("%d\t%c%c%c\t%d\t%d\t%d\t%s", i, \ - (((sp)->su_flags & SEGUSE_ACTIVE) ? 'A' : ' '), \ - (((sp)->su_flags & SEGUSE_DIRTY) ? 'D' : 'C'), \ - (((sp)->su_flags & SEGUSE_SUPERBLOCK) ? 'S' : ' '), \ - (sp)->su_nbytes, (sp)->su_ninos, (sp)->su_nsums, \ - ctime((time_t *)&(sp)->su_lastmod)) - -/* Ifile formats */ -#define print_iheader \ - (void)printf("inum\tstatus\tversion\tdaddr\t\tfreeptr\n") -#define print_ientry(i, ip) \ - if (ip->if_daddr == LFS_UNUSED_DADDR) \ - (void)printf("%d\tFREE\t%d\t \t\t%d\n", \ - i, ip->if_version, ip->if_nextfree); \ - else \ - (void)printf("%d\tINUSE\t%d\t%8X \n", \ - i, ip->if_version, ip->if_daddr) -int -main(argc, argv) - int argc; - char *argv[]; -{ - struct lfs lfs_sb1, lfs_sb2, *lfs_master; - daddr_t seg_addr; - int ch, do_allsb, do_ientries, fd, segnum; - - do_allsb = 0; - do_ientries = 0; - while ((ch = getopt(argc, argv, "ais:")) != -1) - switch(ch) { - case 'a': /* Dump all superblocks */ - do_allsb = 1; - break; - case 'i': /* Dump ifile entries */ - do_ientries = 1; - break; - case 's': /* Dump out these segments */ - addseg(optarg); - break; - default: - usage(); - } - argc -= optind; - argv += optind; - - if (argc != 1) - usage(); - - special = argv[0]; - if ((fd = open(special, O_RDONLY, 0)) < 0) - err("%s: %s", special, strerror(errno)); - - /* Read the first superblock */ - get(fd, LFS_LABELPAD, &lfs_sb1, sizeof(struct lfs)); - daddr_shift = lfs_sb1.lfs_bshift - lfs_sb1.lfs_fsbtodb; - - /* - * Read the second superblock and figure out which check point is - * most up to date. - */ - get(fd, - lfs_sb1.lfs_sboffs[1] << daddr_shift, &lfs_sb2, sizeof(struct lfs)); - - lfs_master = &lfs_sb1; - if (lfs_sb1.lfs_tstamp < lfs_sb2.lfs_tstamp) - lfs_master = &lfs_sb2; - - (void)printf("Master Superblock:\n"); - dump_super(lfs_master); - - dump_ifile(fd, lfs_master, do_ientries); - - if (seglist != NULL) - for (; seglist != NULL; seglist = seglist->next) { - seg_addr = lfs_master->lfs_sboffs[0] + seglist->num * - (lfs_master->lfs_ssize << lfs_master->lfs_fsbtodb); - dump_segment(fd, - seglist->num, seg_addr, lfs_master, do_allsb); - } - else - for (segnum = 0, seg_addr = lfs_master->lfs_sboffs[0]; - segnum < lfs_master->lfs_nseg; segnum++, seg_addr += - lfs_master->lfs_ssize << lfs_master->lfs_fsbtodb) - dump_segment(fd, - segnum, seg_addr, lfs_master, do_allsb); - - (void)close(fd); - exit(0); -} - -/* - * We are reading all the blocks of an inode and dumping out the ifile table. - * This code could be tighter, but this is a first pass at getting the stuff - * printed out rather than making this code incredibly efficient. - */ -static void -dump_ifile(fd, lfsp, do_ientries) - int fd; - struct lfs *lfsp; - int do_ientries; -{ - IFILE *ipage; - struct dinode *dip, *dpage; - daddr_t addr, *addrp, *dindir, *iaddrp, *indir; - int block_limit, i, inum, j, nblocks, nsupb, psize; - - psize = lfsp->lfs_bsize; - addr = lfsp->lfs_idaddr; - - if (!(dpage = malloc(psize))) - err("%s", strerror(errno)); - get(fd, addr << daddr_shift, dpage, psize); - - for (dip = dpage + INOPB(lfsp) - 1; dip >= dpage; --dip) - if (dip->di_inumber == LFS_IFILE_INUM) - break; - - if (dip < dpage) - err("unable to locate ifile inode"); - - (void)printf("\nIFILE inode\n"); - dump_dinode(dip); - - (void)printf("\nIFILE contents\n"); - nblocks = dip->di_size >> lfsp->lfs_bshift; - block_limit = MIN(nblocks, NDADDR); - - /* Get the direct block */ - if ((ipage = malloc(psize)) == NULL) - err("%s", strerror(errno)); - for (inum = 0, addrp = dip->di_db, i = 0; i < block_limit; - i++, addrp++) { - get(fd, *addrp << daddr_shift, ipage, psize); - if (i < lfsp->lfs_cleansz) { - dump_cleaner_info(lfsp, ipage); - print_suheader; - continue; - } - - if (i < (lfsp->lfs_segtabsz + lfsp->lfs_cleansz)) { - inum = dump_ipage_segusage(lfsp, inum, ipage, - lfsp->lfs_sepb); - if (!inum) - if(!do_ientries) - goto e0; - else - print_iheader; - } else - inum = dump_ipage_ifile(inum, ipage, lfsp->lfs_ifpb); - - } - - if (nblocks <= NDADDR) - goto e0; - - /* Dump out blocks off of single indirect block */ - if (!(indir = malloc(psize))) - err("%s", strerror(errno)); - get(fd, dip->di_ib[0] << daddr_shift, indir, psize); - block_limit = MIN(i + lfsp->lfs_nindir, nblocks); - for (addrp = indir; i < block_limit; i++, addrp++) { - if (*addrp == LFS_UNUSED_DADDR) - break; - get(fd, *addrp << daddr_shift,ipage, psize); - if (i < lfsp->lfs_cleansz) { - dump_cleaner_info(lfsp, ipage); - continue; - } else - i -= lfsp->lfs_cleansz; - - if (i < lfsp->lfs_segtabsz) { - inum = dump_ipage_segusage(lfsp, inum, ipage, - lfsp->lfs_sepb); - if (!inum) - if(!do_ientries) - goto e1; - else - print_iheader; - } else - inum = dump_ipage_ifile(inum, ipage, lfsp->lfs_ifpb); - } - - if (nblocks <= lfsp->lfs_nindir * lfsp->lfs_ifpb) - goto e1; - - /* Get the double indirect block */ - if (!(dindir = malloc(psize))) - err("%s", strerror(errno)); - get(fd, dip->di_ib[1] << daddr_shift, dindir, psize); - for (iaddrp = dindir, j = 0; j < lfsp->lfs_nindir; j++, iaddrp++) { - if (*iaddrp == LFS_UNUSED_DADDR) - break; - get(fd, *iaddrp << daddr_shift, indir, psize); - block_limit = MIN(i + lfsp->lfs_nindir, nblocks); - for (addrp = indir; i < block_limit; i++, addrp++) { - if (*addrp == LFS_UNUSED_DADDR) - break; - get(fd, *addrp << daddr_shift, ipage, psize); - if (i < lfsp->lfs_cleansz) { - dump_cleaner_info(lfsp, ipage); - continue; - } else - i -= lfsp->lfs_cleansz; - - if (i < lfsp->lfs_segtabsz) { - inum = dump_ipage_segusage(lfsp, - inum, ipage, lfsp->lfs_sepb); - if (!inum) - if(!do_ientries) - goto e2; - else - print_iheader; - } else - inum = dump_ipage_ifile(inum, - ipage, lfsp->lfs_ifpb); - } - } -e2: free(dindir); -e1: free(indir); -e0: free(dpage); - free(ipage); -} - -static int -dump_ipage_ifile(i, pp, tot) - int i; - IFILE *pp; - int tot; -{ - IFILE *ip; - int cnt, max; - - max = i + tot; - - for (ip = pp, cnt = i; cnt < max; cnt++, ip++) - print_ientry(cnt, ip); - return (max); -} - -static int -dump_ipage_segusage(lfsp, i, pp, tot) - struct lfs *lfsp; - int i; - IFILE *pp; - int tot; -{ - SEGUSE *sp; - int cnt, max; - - max = i + tot; - for (sp = (SEGUSE *)pp, cnt = i; - cnt < lfsp->lfs_nseg && cnt < max; cnt++, sp++) - print_suentry(cnt, sp); - if (max >= lfsp->lfs_nseg) - return (0); - else - return (max); -} - -static void -dump_dinode(dip) - struct dinode *dip; -{ - int i; - - (void)printf("%s%d\t%s%d\t%s%d\t%s%d\t%s%d\n", - "mode ", dip->di_mode, - "nlink ", dip->di_nlink, - "uid ", dip->di_uid, - "gid ", dip->di_gid, - "size ", dip->di_size); - (void)printf("%s%s%s%s%s%s", - "atime ", ctime(&dip->di_atime.tv_sec), - "mtime ", ctime(&dip->di_mtime.tv_sec), - "ctime ", ctime(&dip->di_ctime.tv_sec)); - (void)printf("inum %d\n", dip->di_inumber); - (void)printf("Direct Addresses\n"); - for (i = 0; i < NDADDR; i++) { - (void)printf("\t0x%X", dip->di_db[i]); - if ((i % 6) == 5) - (void)printf("\n"); - } - for (i = 0; i < NIADDR; i++) - (void)printf("\t0x%X", dip->di_ib[i]); - (void)printf("\n"); -} - -static int -dump_sum(fd, lfsp, sp, segnum, addr) - struct lfs *lfsp; - SEGSUM *sp; - int fd, segnum; - daddr_t addr; -{ - FINFO *fp; - daddr_t *dp; - int i, j; - int ck; - int numblocks; - struct dinode *inop; - - if (sp->ss_sumsum != (ck = cksum(&sp->ss_datasum, - LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum)))) { - (void)printf("dumplfs: %s %d address 0x%lx\n", - "corrupt summary block; segment", segnum, addr); - return(0); - } - - (void)printf("Segment Summary Info at 0x%lx\n", addr); - (void)printf(" %s0x%X\t%s%d\t%s%d\n %s0x%X\t%s0x%X", - "next ", sp->ss_next, - "nfinfo ", sp->ss_nfinfo, - "ninos ", sp->ss_ninos, - "sumsum ", sp->ss_sumsum, - "datasum ", sp->ss_datasum ); - (void)printf("\tcreate %s", ctime((time_t *)&sp->ss_create)); - - numblocks = (sp->ss_ninos + INOPB(lfsp) - 1) / INOPB(lfsp); - - /* Dump out inode disk addresses */ - dp = (daddr_t *)sp; - dp += LFS_SUMMARY_SIZE / sizeof(daddr_t); - inop = malloc(1 << lfsp->lfs_bshift); - printf(" Inode addresses:"); - for (dp--, i = 0; i < sp->ss_ninos; dp--) { - printf("\t0x%X {", *dp); - get(fd, *dp << (lfsp->lfs_bshift - lfsp->lfs_fsbtodb), inop, - (1 << lfsp->lfs_bshift)); - for (j = 0; i < sp->ss_ninos && j < INOPB(lfsp); j++, i++) { - if (j > 0) - (void)printf(", "); - (void)printf("%d", inop[j].di_inumber); - } - (void)printf("}"); - if (((i/INOPB(lfsp)) % 4) == 3) - (void)printf("\n"); - } - free(inop); - - printf("\n"); - for (fp = (FINFO *)(sp + 1), i = 0; i < sp->ss_nfinfo; i++) { - numblocks += fp->fi_nblocks; - (void)printf(" FINFO for inode: %d version %d nblocks %d\n", - fp->fi_ino, fp->fi_version, fp->fi_nblocks); - dp = &(fp->fi_blocks[0]); - for (j = 0; j < fp->fi_nblocks; j++, dp++) { - (void)printf("\t%d", *dp); - if ((j % 8) == 7) - (void)printf("\n"); - } - if ((j % 8) != 0) - (void)printf("\n"); - fp = (FINFO *)dp; - } - return (numblocks); -} - -static void -dump_segment(fd, segnum, addr, lfsp, dump_sb) - int fd, segnum; - daddr_t addr; - struct lfs *lfsp; - int dump_sb; -{ - struct lfs lfs_sb, *sbp; - SEGSUM *sump; - char sumblock[LFS_SUMMARY_SIZE]; - int did_one, nblocks, sb; - off_t sum_offset, super_off; - - (void)printf("\nSEGMENT %d (Disk Address 0x%X)\n", - addr >> (lfsp->lfs_segshift - daddr_shift), addr); - sum_offset = (addr << (lfsp->lfs_bshift - lfsp->lfs_fsbtodb)); - - sb = 0; - did_one = 0; - do { - get(fd, sum_offset, sumblock, LFS_SUMMARY_SIZE); - sump = (SEGSUM *)sumblock; - if (sump->ss_sumsum != cksum (&sump->ss_datasum, - LFS_SUMMARY_SIZE - sizeof(sump->ss_sumsum))) { - sbp = (struct lfs *)sump; - if (sb = (sbp->lfs_magic == LFS_MAGIC)) { - super_off = sum_offset; - sum_offset += LFS_SBPAD; - } else if (did_one) - break; - else { - printf("Segment at 0x%X corrupt\n", addr); - break; - } - } else { - nblocks = dump_sum(fd, lfsp, sump, segnum, sum_offset >> - (lfsp->lfs_bshift - lfsp->lfs_fsbtodb)); - if (nblocks) - sum_offset += LFS_SUMMARY_SIZE + - (nblocks << lfsp->lfs_bshift); - else - sum_offset = 0; - did_one = 1; - } - } while (sum_offset); - - if (dump_sb && sb) { - get(fd, super_off, &lfs_sb, sizeof(struct lfs)); - dump_super(&lfs_sb); - } - return; -} - -static void -dump_super(lfsp) - struct lfs *lfsp; -{ - int i; - - (void)printf("%s0x%X\t%s0x%X\t%s%d\t%s%d\n", - "magic ", lfsp->lfs_magic, - "version ", lfsp->lfs_version, - "size ", lfsp->lfs_size, - "ssize ", lfsp->lfs_ssize); - (void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n", - "dsize ", lfsp->lfs_dsize, - "bsize ", lfsp->lfs_bsize, - "fsize ", lfsp->lfs_fsize, - "frag ", lfsp->lfs_frag); - - (void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n", - "minfree ", lfsp->lfs_minfree, - "inopb ", lfsp->lfs_inopb, - "ifpb ", lfsp->lfs_ifpb, - "nindir ", lfsp->lfs_nindir); - - (void)printf("%s%d\t\t%s%d\t%s%d\t%s%d\n", - "nseg ", lfsp->lfs_nseg, - "nspf ", lfsp->lfs_nspf, - "cleansz ", lfsp->lfs_cleansz, - "segtabsz ", lfsp->lfs_segtabsz); - - (void)printf("%s0x%X\t%s%d\t%s0x%X\t%s%d\n", - "segmask ", lfsp->lfs_segmask, - "segshift ", lfsp->lfs_segshift, - "bmask ", lfsp->lfs_bmask, - "bshift ", lfsp->lfs_bshift); - - (void)printf("%s0x%X\t\t%s%d\t%s0x%X\t%s%d\n", - "ffmask ", lfsp->lfs_ffmask, - "ffshift ", lfsp->lfs_ffshift, - "fbmask ", lfsp->lfs_fbmask, - "fbshift ", lfsp->lfs_fbshift); - - (void)printf("%s%d\t%s%d\t%s0x%X\t%s0x%qx\n", - "sushift ", lfsp->lfs_sushift, - "fsbtodb ", lfsp->lfs_fsbtodb, - "cksum ", lfsp->lfs_cksum, - "maxfilesize ", lfsp->lfs_maxfilesize); - - (void)printf("Superblock disk addresses:\t"); - for (i = 0; i < LFS_MAXNUMSB; i++) { - (void)printf(" 0x%X", lfsp->lfs_sboffs[i]); - if ( i == (LFS_MAXNUMSB >> 1)) - (void)printf("\n\t\t\t\t"); - } - (void)printf("\n"); - - (void)printf("Checkpoint Info\n"); - (void)printf("%s%d\t%s0x%X\t%s%d\n", - "free ", lfsp->lfs_free, - "idaddr ", lfsp->lfs_idaddr, - "ifile ", lfsp->lfs_ifile); - (void)printf("%s%d\t%s%d\t%s%d\n", - "bfree ", lfsp->lfs_bfree, - "avail ", lfsp->lfs_avail, - "uinodes ", lfsp->lfs_uinodes); - (void)printf("%s%d\t%s0x%X\t%s0x%X\n%s0x%X\t%s0x%X\t", - "nfiles ", lfsp->lfs_nfiles, - "lastseg ", lfsp->lfs_lastseg, - "nextseg ", lfsp->lfs_nextseg, - "curseg ", lfsp->lfs_curseg, - "offset ", lfsp->lfs_offset); - (void)printf("tstamp %s", ctime((time_t *)&lfsp->lfs_tstamp)); - (void)printf("\nIn-Memory Information\n"); - (void)printf("%s%d\t%s0x%X\t%s%d%s%d\t%s%d\n", - "seglock ", lfsp->lfs_seglock, - "iocount ", lfsp->lfs_iocount, - "writer ", lfsp->lfs_writer, - "dirops ", lfsp->lfs_dirops, - "doifile ", lfsp->lfs_doifile); - (void)printf("%s%d\t%s%d\t%s0x%X\t%s%d\n", - "nactive ", lfsp->lfs_nactive, - "fmod ", lfsp->lfs_fmod, - "clean ", lfsp->lfs_clean, - "ronly ", lfsp->lfs_ronly); -} - -static void -addseg(arg) - char *arg; -{ - SEGLIST *p; - - if ((p = malloc(sizeof(SEGLIST))) == NULL) - err("%s", strerror(errno)); - p->next = seglist; - p->num = atoi(arg); - seglist = p; -} - -static void -dump_cleaner_info(lfsp, ipage) - struct lfs *lfsp; - void *ipage; -{ - CLEANERINFO *cip; - - cip = (CLEANERINFO *)ipage; - (void)printf("segments clean\t%d\tsegments dirty\t%d\n\n", - cip->clean, cip->dirty); -} - -static void -usage() -{ - (void)fprintf(stderr, "usage: dumplfs [-ai] [-s segnum] file\n"); - exit(1); -} diff --git a/sbin/dumplfs/extern.h b/sbin/dumplfs/extern.h deleted file mode 100644 index 82e87b24e0a57..0000000000000 --- a/sbin/dumplfs/extern.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * 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. - * - * @(#)extern.h 8.1 (Berkeley) 6/5/93 - */ - -void err __P((const char *, ...)); -void get __P((int, off_t, void *, size_t)); - -extern char *special; diff --git a/sbin/dumplfs/misc.c b/sbin/dumplfs/misc.c deleted file mode 100644 index 861d0fd7f2608..0000000000000 --- a/sbin/dumplfs/misc.c +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * 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 -static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/5/93"; -#endif /* not lint */ - -#include <sys/types.h> -#include <unistd.h> -#include <errno.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include "extern.h" - -void -get(fd, off, p, len) - int fd; - off_t off; - void *p; - size_t len; -{ - int rbytes; - - if (lseek(fd, off, SEEK_SET) < 0) - err("%s: %s", special, strerror(errno)); - if ((rbytes = read(fd, p, len)) < 0) - err("%s: %s", special, strerror(errno)); - if (rbytes != len) - err("%s: short read (%d, not %d)", special, rbytes, len); -} - -#if __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -void -#if __STDC__ -err(const char *fmt, ...) -#else -err(fmt, va_alist) - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "dumplfs: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - exit(1); - /* NOTREACHED */ -} diff --git a/sbin/dumpon/dumpon.8 b/sbin/dumpon/dumpon.8 index 96d4dd2f63771..c35925f31a770 100644 --- a/sbin/dumpon/dumpon.8 +++ b/sbin/dumpon/dumpon.8 @@ -10,7 +10,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" 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 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93 -.\" $Id: dumpon.8,v 1.3.2.1 1998/05/25 12:07:25 danny Exp $ +.\" $Id: dumpon.8,v 1.3.2.2 1998/05/31 05:56:11 thepish Exp $ .\" .Dd May 12, 1995 .Dt DUMPON 8 @@ -116,7 +116,7 @@ boot-time system configuration Because the filesystem layer is already dead by the time a crash dump is taken, it is not possible to send crash dumps directly to a file. .Pp -.Nm +.Nm Dumpon currently allows only devices with minor number 1 to be used as dump devices. .Sh HISTORY diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c index 2295f2ad6fedf..5b4cd5b6543ae 100644 --- a/sbin/dumpon/dumpon.c +++ b/sbin/dumpon/dumpon.c @@ -40,7 +40,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "From: @(#)swapon.c 8.1 (Berkeley) 6/5/93";*/ static const char rcsid[] = - "$Id: dumpon.c,v 1.2 1995/05/30 06:08:58 rgrimes Exp $"; + "$Id: dumpon.c,v 1.2.6.1 1997/08/26 13:15:01 jkh Exp $"; #endif /* not lint */ #include <errno.h> @@ -107,10 +107,10 @@ main(int argc, char **argv) if (verbose) { if (stab.st_rdev == NODEV) { - printf("%s: crash dumps disabled\n", whoami); + printf("dumpon: crash dumps disabled\n"); } else { - printf("%s: crash dumps to %s (%lu, %lu)\n", - whoami, argv[0], + printf("dumpon: crash dumps to %s (%lu, %lu)\n", + argv[0], (unsigned long)major(stab.st_rdev), (unsigned long)minor(stab.st_rdev)); } @@ -123,7 +123,7 @@ void usage() { fprintf(stderr, - "usage: %s [-v] special_file\n" - " %s [-v] off\n", whoami, whoami); + "usage: dumpon [-v] special_file\n" + " dumpon [-v] off\n"); exit(EX_USAGE); } diff --git a/sbin/fsirand/fsirand.8 b/sbin/fsirand/fsirand.8 index 01705d1ea9e5a..51e99a344e945 100644 --- a/sbin/fsirand/fsirand.8 +++ b/sbin/fsirand/fsirand.8 @@ -10,7 +10,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" This product includes software developed by Todd C. Miller. .\" 4. The name of the author may not be used to endorse or promote products .\" derived from this software without specific prior written permission. @@ -27,7 +27,7 @@ .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $OpenBSD: fsirand.8,v 1.6 1997/02/23 03:58:26 millert Exp $ -.\" $Id: fsirand.8,v 1.3.2.2 1997/06/12 07:03:47 charnier Exp $ +.\" $Id: fsirand.8,v 1.3.2.3 1997/06/16 06:57:42 max Exp $ .\" .Dd January 25, 1997 .Dt FSIRAND 8 @@ -44,14 +44,14 @@ .Op Ar "special ..." .Sh DESCRIPTION The -.Nm fsirand +.Nm command installs random generation numbers on all the inodes for each filesystem specified on the command line by .Ar special . This increases the security of NFS-exported filesystems by making it difficult to ``guess'' filehandles. .Pp -.Em Note: +.Em Note Ns : .Xr newfs 8 now does the equivalent of .Nm @@ -93,7 +93,7 @@ of memory for large disks with few cylinder groups. .Sh SEE ALSO .Xr fs 5 , .Xr fsck 8 , -.Xr newfs 8 . +.Xr newfs 8 .Sh HISTORY The .Nm @@ -104,10 +104,8 @@ This version of first appeared in .Ox 2.1 . A -.Tn FreeBSD +.Bx Free version first appeared in .Fx 2.2.5 . -.Sh AUTHOR -.nf -Todd C. Miller <Todd.Miller@courtesan.com> -.fi +.Sh AUTHORS +.An Todd C. Miller Aq Todd.Miller@courtesan.com diff --git a/sbin/fsirand/fsirand.c b/sbin/fsirand/fsirand.c index 4e2ea7e06a42e..ffa2d74b6b432 100644 --- a/sbin/fsirand/fsirand.c +++ b/sbin/fsirand/fsirand.c @@ -30,13 +30,13 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef lint -static char rcsid[] = "$OpenBSD: fsirand.c,v 1.9 1997/02/28 00:46:33 millert Exp $"; -#endif /* not lint */ +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include <sys/types.h> #include <sys/disklabel.h> -#include <sys/ioctl.h> #include <sys/param.h> #include <sys/time.h> #include <sys/resource.h> @@ -50,10 +50,9 @@ static char rcsid[] = "$OpenBSD: fsirand.c,v 1.9 1997/02/28 00:46:33 millert Exp #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <time.h> #include <unistd.h> -static void usage __P((int)); +static void usage __P((void)); int fsirand __P((char *)); int printonly = 0, force = 0, ignorelabel = 0; @@ -78,11 +77,11 @@ main(argc, argv) force++; break; default: - usage(1); + usage(); } } if (argc - optind < 1) - usage(1); + usage(); srandomdev(); @@ -90,9 +89,9 @@ main(argc, argv) if (getrlimit(RLIMIT_DATA, &rl) == 0) { rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_DATA, &rl) < 0) - warn("Can't get resource limit to max data size"); + warn("can't get resource limit to max data size"); } else - warn("Can't get resource limit for data size"); + warn("can't get resource limit for data size"); for (n = optind; n < argc; n++) { if (argc - optind != 1) @@ -121,14 +120,14 @@ fsirand(device) struct disklabel label; if ((devfd = open(device, printonly ? O_RDONLY : O_RDWR)) < 0) { - warn("Can't open %s", device); + warn("can't open %s", device); return (1); } /* Get block size (usually 512) from disklabel if possible */ if (!ignorelabel) { if (ioctl(devfd, DIOCGDINFO, &label) < 0) - warn("Can't read disklabel, using sector size of %d", + warn("can't read disklabel, using sector size of %d", bsize); else bsize = label.d_secsize; @@ -138,11 +137,11 @@ fsirand(device) (void)memset(&sbuf, 0, sizeof(sbuf)); sblock = (struct fs *)&sbuf; if (lseek(devfd, SBOFF, SEEK_SET) == -1) { - warn("Can't seek to superblock (%qd) on %s", SBOFF, device); + warn("can't seek to superblock (%qd) on %s", SBOFF, device); return (1); } if ((n = read(devfd, (void *)sblock, SBSIZE)) != SBSIZE) { - warnx("Can't read superblock on %s: %s", device, + warnx("can't read superblock on %s: %s", device, (n < SBSIZE) ? "short read" : strerror(errno)); return (1); } @@ -150,19 +149,19 @@ fsirand(device) /* Simple sanity checks on the superblock */ if (sblock->fs_magic != FS_MAGIC) { - warnx("Bad magic number in superblock"); + warnx("bad magic number in superblock"); return (1); } if (sblock->fs_sbsize > SBSIZE) { - warnx("Superblock size is preposterous"); + warnx("superblock size is preposterous"); return (1); } if (sblock->fs_postblformat == FS_42POSTBLFMT) { - warnx("Filesystem format is too old, sorry"); + warnx("filesystem format is too old, sorry"); return (1); } if (!force && !printonly && sblock->fs_clean != 1) { - warnx("Filesystem is not clean, fsck %s first.", device); + warnx("filesystem is not clean, fsck %s first", device); return (1); } @@ -171,21 +170,21 @@ fsirand(device) for (cg = 0; cg < sblock->fs_ncg; cg++) { dblk = fsbtodb(sblock, cgsblock(sblock, cg)); if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) { - warn("Can't seek to %qd", (off_t)dblk * bsize); + warn("can't seek to %qd", (off_t)dblk * bsize); return (1); } else if ((n = write(devfd, (void *)sblock, SBSIZE)) != SBSIZE) { - warn("Can't read backup superblock %d on %s: %s", + warn("can't read backup superblock %d on %s: %s", cg + 1, device, (n < SBSIZE) ? "short write" : strerror(errno)); return (1); } if (sblock->fs_magic != FS_MAGIC) { - warnx("Bad magic number in backup superblock %d on %s", + warnx("bad magic number in backup superblock %d on %s", cg + 1, device); return (1); } if (sblock->fs_sbsize > SBSIZE) { - warnx("Size of backup superblock %d on %s is preposterous", + warnx("size of backup superblock %d on %s is preposterous", cg + 1, device); return (1); } @@ -196,7 +195,7 @@ fsirand(device) ibufsize = sizeof(struct dinode) * sblock->fs_ipg; if (oldibufsize < ibufsize) { if ((inodebuf = realloc(inodebuf, ibufsize)) == NULL) - errx(1, "Can't allocate memory for inode buffer"); + errx(1, "can't allocate memory for inode buffer"); oldibufsize = ibufsize; } @@ -215,12 +214,12 @@ fsirand(device) sblock->fs_id[1] = random(); if (lseek(devfd, SBOFF, SEEK_SET) == -1) { - warn("Can't seek to superblock (%qd) on %s", SBOFF, + warn("can't seek to superblock (%qd) on %s", SBOFF, device); return (1); } if ((n = write(devfd, (void *)sblock, SBSIZE)) != SBSIZE) { - warn("Can't read superblock on %s: %s", device, + warn("can't read superblock on %s: %s", device, (n < SBSIZE) ? "short write" : strerror(errno)); return (1); } @@ -232,10 +231,10 @@ fsirand(device) if ((sblock->fs_inodefmt >= FS_44INODEFMT) && !printonly) { dblk = fsbtodb(sblock, cgsblock(sblock, cg)); if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) { - warn("Can't seek to %qd", (off_t)dblk * bsize); + warn("can't seek to %qd", (off_t)dblk * bsize); return (1); } else if ((n = write(devfd, (void *)sblock, SBSIZE)) != SBSIZE) { - warn("Can't read backup superblock %d on %s: %s", + warn("can't read backup superblock %d on %s: %s", cg + 1, device, (n < SBSIZE) ? "short write" : strerror(errno)); return (1); @@ -245,10 +244,10 @@ fsirand(device) /* Read in inodes, then print or randomize generation nums */ dblk = fsbtodb(sblock, ino_to_fsba(sblock, inumber)); if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) { - warn("Can't seek to %qd", (off_t)dblk * bsize); + warn("can't seek to %qd", (off_t)dblk * bsize); return (1); } else if ((n = read(devfd, inodebuf, ibufsize)) != ibufsize) { - warnx("Can't read inodes: %s", + warnx("can't read inodes: %s", (n < ibufsize) ? "short read" : strerror(errno)); return (1); } @@ -266,12 +265,12 @@ fsirand(device) /* Write out modified inodes */ if (!printonly) { if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) { - warn("Can't seek to %qd", + warn("can't seek to %qd", (off_t)dblk * bsize); return (1); } else if ((n = write(devfd, inodebuf, ibufsize)) != ibufsize) { - warnx("Can't write inodes: %s", + warnx("can't write inodes: %s", (n != ibufsize) ? "short write" : strerror(errno)); return (1); @@ -284,10 +283,9 @@ fsirand(device) } static void -usage(ex) - int ex; +usage() { (void)fprintf(stderr, -"usage: fsirand [ -b ] [ -f ] [ -p ] special [special ...]\n"); - exit(ex); + "usage: fsirand [-b] [-f] [-p] special [special ...]\n"); + exit(1); } diff --git a/sbin/i386/comcontrol/comcontrol.8 b/sbin/i386/comcontrol/comcontrol.8 index f73318f3beac1..eeeabcfaab307 100644 --- a/sbin/i386/comcontrol/comcontrol.8 +++ b/sbin/i386/comcontrol/comcontrol.8 @@ -1,4 +1,4 @@ -.\" $Id: comcontrol.8,v 1.12 1997/02/22 14:32:27 peter Exp $ +.\" $Id: comcontrol.8,v 1.8.2.2 1997/03/03 07:01:28 mpp Exp $ .Dd May 15, 1994 .Dt COMCONTROL 8 .Os FreeBSD @@ -19,7 +19,7 @@ This usage requires only read access on the device. Only the superuser can change the settings. .Pp The following options are available: -.Bl -tag -width Fl +.Bl -tag -width indent .It Cm dtrwait Ar number Set the time to wait after dropping DTR to the given number. @@ -27,8 +27,6 @@ The units are hundredths of a second. The default is 300 hundredths, i.e., 3 seconds. This option needed mainly to set proper recover time after modem reset. -.El -.Bl -tag -width Fl .It Cm drainwait Ar number Set the time to wait for output drain to the given number. @@ -39,23 +37,23 @@ to prevent modem hanging. .El .Pp The standard way to use -.Nm comcontrol +.Nm is to put invocations of it in the -.Ar /etc/rc.serial +.Pa /etc/rc.serial startup script. .Sh SEE ALSO .Xr stty 1 , .Xr sio 4 .Sh FILES -.Bl -tag -width Pa +.Bl -tag -width /dev/ttyd? -compact .It Pa /dev/ttyd? dialin devices, hardwired terminals .It Pa /dev/cuaa? -dialout devices. -.Sh AUTHOR -Christopher G. Demetriou +dialout devices +.Sh AUTHORS +.An Christopher G. Demetriou .Sh BUGS -.Nm comcontrol +.Nm Comcontrol should be named .Nm siocontrol . .Sh HISTORY diff --git a/sbin/i386/comcontrol/comcontrol.c b/sbin/i386/comcontrol/comcontrol.c index 17c288274f13e..372f984409e4a 100644 --- a/sbin/i386/comcontrol/comcontrol.c +++ b/sbin/i386/comcontrol/comcontrol.c @@ -26,79 +26,83 @@ * SUCH DAMAGE. */ -/* comcontrol.c */ +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ -#include <sys/types.h> -#include <sys/ioctl.h> -#include <stdio.h> -#include <stdlib.h> #include <ctype.h> +#include <err.h> #include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/ioctl.h> - -void usage(char *progname) +static void +usage() { - fprintf(stderr, "usage: %s <filename> [dtrwait <n>] [drainwait <n>]\n", progname); + fprintf(stderr, + "usage: comcontrol <filename> [dtrwait <n>] [drainwait <n>]\n"); exit(1); } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { int fd; int res = 0; int dtrwait = -1, drainwait = -1; if (argc < 2) - usage(argv[0]); + usage(); fd = open(argv[1], O_RDONLY|O_NONBLOCK, 0); if (fd < 0) { - perror("open"); - fprintf(stderr, "%s: couldn't open file %s\n", argv[0], argv[1]); + warn("couldn't open file %s", argv[1]); return 1; } if (argc == 2) { if (ioctl(fd, TIOCMGDTRWAIT, &dtrwait) < 0) { res = 1; - perror("TIOCMGDTRWAIT"); + warn("TIOCMGDTRWAIT"); } if (ioctl(fd, TIOCGDRAINWAIT, &drainwait) < 0) { res = 1; - perror("TIOCGDRAINWAIT"); + warn("TIOCGDRAINWAIT"); } printf("dtrwait %d drainwait %d\n", dtrwait, drainwait); } else { - char *prg = argv[0]; - while (argv[2] != NULL) { if (!strcmp(argv[2],"dtrwait")) { if (dtrwait >= 0) - usage(prg); + usage(); if (argv[3] == NULL || !isdigit(argv[3][0])) - usage(prg); + usage(); dtrwait = atoi(argv[3]); argv += 2; } else if (!strcmp(argv[2],"drainwait")) { if (drainwait >= 0) - usage(prg); + usage(); if (argv[3] == NULL || !isdigit(argv[3][0])) - usage(prg); + usage(); drainwait = atoi(argv[3]); argv += 2; } else - usage(prg); + usage(); } if (dtrwait >= 0) { if (ioctl(fd, TIOCMSDTRWAIT, &dtrwait) < 0) { res = 1; - perror("TIOCMSDTRWAIT"); + warn("TIOCMSDTRWAIT"); } } if (drainwait >= 0) { if (ioctl(fd, TIOCSDRAINWAIT, &drainwait) < 0) { res = 1; - perror("TIOCSDRAINWAIT"); + warn("TIOCSDRAINWAIT"); } } } diff --git a/sbin/i386/cxconfig/cxconfig.8 b/sbin/i386/cxconfig/cxconfig.8 index e25048334dda0..e502e38edfacb 100644 --- a/sbin/i386/cxconfig/cxconfig.8 +++ b/sbin/i386/cxconfig/cxconfig.8 @@ -1,11 +1,15 @@ -.Dd "December 2, 1994" +.\" $Id$ +.Dd December 2, 1994 .Dt CXCONFIG 8 .Os FreeBSD .Sh NAME .Nm cxconfig .Nd channel options management utility for Cronyx-Sigma adapter +.Sh SYNOPSIS +.Nm cxconfig +.Op Fl a +.Op Ar <channel> Op Ar <option>... .Sh DESCRIPTION -.Pp The .Nm utility is used for configuring the channel options of @@ -23,18 +27,11 @@ file. Note, that not all options have a sense for every particular case, and an attempt to set some of them can hang up the channel or the whole adapter. -.Sh "Usage" -.Bl -tag -width 10n -.It "cxconfig" -The brief information about all channels. -.It "cxconfig -a" -The full information about all channels. -.It "cxconfig <channel>" -The brief information about the channel. -.It "cxconfig -a <channel>" -The full information about the channel. -.It "cxconfig <channel> <option>..." -Setting the channel options. +.Pp +The following option is available: +.Bl -tag -width indent +.It Fl a +Display full information. .El .Sh "Channel options" .Bl -tag -width 10n @@ -105,7 +102,7 @@ source or .Em "internal clock" generation. .Pp -.Em"External clock" +.Em "External clock" mode is the most common method for connecting external modem hardware. In this mode the external timing signal is received on TXCIN pin of the connector, and it is @@ -183,13 +180,13 @@ Action .It parintr Generate the receiver error interrupt .It parnull -Input the NULL character +Input the NUL character .It parign Ignore the error, receive as good data .It pardisc Ignore the character .It parffnull -Input the sequence <0xFF, NULL, character> +Input the sequence <0xFF, NUL, character> .El .It "brkintr, brknull, brkdisc Line break state action: @@ -200,7 +197,7 @@ Action .It brkintr Generate the receiver error interrupt .It brknull -Input the NULL character +Input the NUL character .It brkdisc Ignore the line break state .El @@ -279,8 +276,8 @@ Send sync pattern. Frame address registers for address recognition. .El .Sh EXAMPLES -.Pp -Set up the channel 7 of the adapter Sigma-400 under FreeBSD. +Set up the channel 7 of the adapter Sigma-400 under +.Bx Free . Physical 4-wire leased line with Zelax+ M115 short-range modems. Synchronous mode, 128000 bits/sec, interface RS-232, protocol PpP/HDLC without keepalive support, NRZI encoding, @@ -290,7 +287,8 @@ cxconfig cx7 128000 hdlc ppp -keepalive nrzi -cts +dpll -extclock ifconfig cx7 158.250.244.2 158.250.244.1 up .Ed .Pp -Set up the channel 0 of the adapter Sigma-100 under FreeBSD. +Set up the channel 0 of the adapter Sigma-100 under +.Bx Free . Attachment to the near computer by short cable, internal clock source. Synchronous mode, 256000 bits/sec, interface RS-232, protocol Cisco/HDLC with keepalive support: @@ -307,7 +305,8 @@ cxconfig cx1 hdlc ext ifconfig cx1 193.124.254.50 193.124.254.49 multicast up .Ed .Pp -Set up the channel 0 of the adapter Sigma-840 under FreeBSD. +Set up the channel 0 of the adapter Sigma-840 under +.Bx Free . Attachment to the Cisco-4000 router by null-modem cable, internal clock source. Synchronous mode, 64000 bits/sec, interface RS-232, protocol PpP/HDLC with keepalive support and flow control, @@ -317,7 +316,9 @@ cxconfig cx0 hdlc 64000 port=rs232 ppp +keepalive -extclock +cts ifconfig cx0 100.0.0.2 100.0.0.1 debug up .Ed .Sh FILES +.Bl -tag -width /dev/cronyx -compact .Pa /dev/cronyx -The special device file for adapter options management. +the special device file for adapter options management +.El .Sh SEE ALSO .Xr cx 4 diff --git a/sbin/i386/cxconfig/cxconfig.c b/sbin/i386/cxconfig/cxconfig.c index 4e2400e8389a7..cae322b702b7f 100644 --- a/sbin/i386/cxconfig/cxconfig.c +++ b/sbin/i386/cxconfig/cxconfig.c @@ -21,12 +21,23 @@ * cxconfig <channel> <option>... * -- set channel options */ + +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ + +#include <err.h> +#include <fcntl.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <machine/cronyx.h> #include <net/if.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> #define NBRD 3 #define CXDEV "/dev/cronyx" @@ -54,8 +65,6 @@ char *symbol (unsigned char sym) unsigned char atosym (char *s) { - unsigned char c; - if (*s == '^') return (*++s & 037); if (*s == '\\') @@ -65,16 +74,10 @@ unsigned char atosym (char *s) void usage () { - printf ("Cronyx-Sigma Adapter Configuration Utility, Version 1.0\n"); - printf ("Copyright (C) 1994 Cronyx Ltd.\n"); - printf ("Usage:\n"); - printf ("\tcxconfig [-a]\n"); - printf ("\t\t-- print status of all channels\n"); - printf ("\tcxconfig [-a] <channel>\n"); - printf ("\t\t-- print status of the channel\n"); - printf ("\tcxconfig <channel> [async | hdlc | bisync | x.21] [ispeed #] [ospeed #]\n"); - printf ("\t\t[+cts | -cts]\n"); - printf ("\t\t-- set channel options\n"); + fprintf (stderr, + "Cronyx-Sigma Adapter Configuration Utility, Version 1.0\n"); + fprintf (stderr, "Copyright (C) 1994 Cronyx Ltd.\n"); + fprintf (stderr, "usage: cxconfig [-a] [<channel> [<option>...]]\n"); exit (1); } @@ -106,22 +109,16 @@ char *chanmode (int mode) void getchan (int channel) { int s = open (CXDEV, 0); - if (s < 0) { - perror (CXDEV); - exit (1); - } + if (s < 0) + err (1, "%s", CXDEV); o.board = channel/NCHAN; o.channel = channel%NCHAN; - if (ioctl (s, CXIOCGETMODE, (caddr_t)&o) < 0) { - perror ("cxconfig: CXIOCGETMODE"); - exit (1); - } + if (ioctl (s, CXIOCGETMODE, (caddr_t)&o) < 0) + err (1, "CXIOCGETMODE"); close (s); - if (o.type == T_NONE) { - fprintf (stderr, "cx%d: channel %d not configured\n", o.board, + if (o.type == T_NONE) + errx (1, "cx%d: channel %d not configured", o.board, o.channel); - exit (1); - } } int printstats (int channel, int hflag) @@ -129,10 +126,8 @@ int printstats (int channel, int hflag) int s, res; s = open (CXDEV, 0); - if (s < 0) { - perror (CXDEV); - exit (1); - } + if (s < 0) + err (1, "%s", CXDEV); st.board = channel/NCHAN; st.channel = channel%NCHAN; res = ioctl (s, CXIOCGETSTAT, (caddr_t)&st); @@ -161,16 +156,12 @@ void printallstats () void setchan (int channel) { int s = open (CXDEV, 0); - if (s < 0) { - perror (CXDEV); - exit (1); - } + if (s < 0) + err (1, "%s", CXDEV); o.board = channel/NCHAN; o.channel = channel%NCHAN; - if (ioctl (s, CXIOCSETMODE, (caddr_t)&o) < 0) { - perror ("cxconfig: CXIOCSETMODE"); - exit (1); - } + if (ioctl (s, CXIOCSETMODE, (caddr_t)&o) < 0) + err (1, "CXIOCSETMODE"); close (s); } @@ -414,22 +405,16 @@ void printall () int s, c; s = socket (AF_INET, SOCK_DGRAM, 0); - if (s < 0) { - perror ("cxconfig: socket"); - exit (1); - } + if (s < 0) + err (1, "socket"); ifc.ifc_len = sizeof (buf); ifc.ifc_buf = buf; - if (ioctl (s, SIOCGIFCONF, (caddr_t)&ifc) < 0) { - perror ("cxconfig: SIOCGIFCONF"); - exit (1); - } + if (ioctl (s, SIOCGIFCONF, (caddr_t)&ifc) < 0) + err (1, "SIOCGIFCONF"); close (s); s = open (CXDEV, 0); - if (s < 0) { - perror (CXDEV); - exit (1); - } + if (s < 0) + err (1, "%s", CXDEV); ifr = ifc.ifc_req; #define max(a,b) ((a)>(b) ? (a) : (b)) @@ -443,10 +428,8 @@ void printall () c = atoi (ifr->ifr_name + 2); o.board = c/NCHAN; o.channel = c%NCHAN; - if (ioctl (s, CXIOCGETMODE, (caddr_t)&o) < 0) { - perror ("cxconfig: CXIOCGETMODE"); - exit (1); - } + if (ioctl (s, CXIOCGETMODE, (caddr_t)&o) < 0) + err (1, "CXIOCGETMODE"); printchan (c); } close (s); diff --git a/sbin/i386/fdisk/fdisk.8 b/sbin/i386/fdisk/fdisk.8 index 70b0f8c5e0e7d..2248b6a0c2a98 100644 --- a/sbin/i386/fdisk/fdisk.8 +++ b/sbin/i386/fdisk/fdisk.8 @@ -5,7 +5,7 @@ .Nm fdisk .Nd DOS partition maintenance program .Sh SYNOPSIS -.Nm +.Nm fdisk .Op Fl i .Op Fl u .Op Fl a @@ -30,20 +30,21 @@ The BIOS brings in sector 0 and verifies the magic number. It then searches the 4 BIOS partitions described by sector 0 to determine which of them is -.Em active. +.Em active . This boot then brings in the secondary boot block from the .Em active partition and runs it. Under DOS, you could have one or more partitions with one -.Em active. +.Em active . The DOS .Nm program can be used to divide space on the disk into partitions and set one -.Em active. +.Em active . .Sh DESCRIPTION -.Pp -The FreeBSD program +The +.Bx Free +program .Nm serves a similar purpose to the DOS program. The first form is used to display partition information or to interactively edit the partition @@ -57,7 +58,7 @@ Is used for updating (editing) sector 0 of the disk. Ignored if .Fl f is given. .It Fl i -Initializes sector 0 of the disk. This implies +Initialize sector 0 of the disk. This implies .Fl u , unless .Fl f @@ -85,10 +86,10 @@ is read. The can be "-", in which case .Ar stdin is read. See -.Em CONFIGURATION FILE , +.Sx CONFIGURATION FILE , below, for file syntax. .Pp -.Em WARNING: +.Em WARNING Ns : when .Fl f is used, you are not asked if you really want to write the partition @@ -157,7 +158,9 @@ The second partition overlaps the end of the first. (Used for debugging purposes) .Bl -tag -width "cyl, sector and head" .It Em "sysid" -is used to label the partition. FreeBSD reserves the +is used to label the partition. +.Bx Free +reserves the magic number 165 decimal (A5 in hex). .It Em "start and size" fields provide the start address @@ -184,7 +187,7 @@ option is not used, the .Nm program will enter a conversational mode. This mode is designed not to change any data unless you explicitly tell it to. -.Nm +.Nm Fdisk selects defaults for its questions to guarantee the above behavior. .Pp It displays each partition @@ -195,7 +198,7 @@ and asking for a new one. When you are done with a partition, .Nm will display it and ask if it is correct. -.Nm +.Nm Fdisk will then proceed to the next entry. .Pp Getting the @@ -228,10 +231,10 @@ flag just edits the fields as they appear on the disk. While the .Fl i flag is used to "initialize" sector 0; -it will setup the last BIOS partition to use the whole disk for FreeBSD; +it will setup the last BIOS partition to use the whole disk for +.Bx Free ; and make it active. .Sh NOTES -.Pp The automatic calculation of starting cylinder etc. uses a set of figures that represent what the BIOS thinks is the geometry of the drive. @@ -241,7 +244,9 @@ This allows the user to create a bootblock that can work with drives that use geometry translation under the BIOS. .Pp If you hand craft your disk layout, -please make sure that the FreeBSD partition starts on a cylinder boundary. +please make sure that the +.Bx Free +partition starts on a cylinder boundary. A number of decisions made later may assume this. (This might not be necessary later.) .Pp @@ -253,7 +258,6 @@ works. This is completely safe as long as you answer the last question in the negative. There are subtleties that the program detects that are not fully explained in this manual page. .Sh CONFIGURATION FILE -.Pp When the .Fl f option is given, a disk's partition table can be written using values @@ -274,7 +278,7 @@ Lines beginning with a "#" are comments and are ignored. .No Ar spec3 .Xc Set the BIOS geometry used in partition calculations. There must be -three values specfied, with a letter preceding each number: +three values specified, with a letter preceding each number: .Bl -tag -width Ds .Sm off .It Cm c No Ar num @@ -309,7 +313,8 @@ It is an error if the following is not true: .Pp The number of cylinders should be less than or equal to 1024, but this is not enforced, although a warning will be output. Note that bootable -FreeBSD partitions (the "/" filesystem) must lie completely within the +.Bx Free +partitions (the "/" filesystem) must lie completely within the first 1024 cylinders; if this is not true, booting may fail. Non-bootable partitions do not have this restriction. .Pp @@ -352,7 +357,9 @@ if one is present. .Pp The .Ar type -is 165 for FreeBSD partitions. Specifying a partition type of zero is +is 165 for +.Bx Free +partitions. Specifying a partition type of zero is the same as clearing the partition and marking it as unused; however, dummy values (such as "0") must still be specified for .Ar start @@ -369,7 +376,9 @@ Example: to clear partition 4 and mark it as unused: p 4 0 0 0 .fi .Pp -Example: to set partition 1 to a FreeBSD partition, starting at sector 1 +Example: to set partition 1 to a +.Bx Free +partition, starting at sector 1 for 2503871 sectors (note: these numbers will be rounded upwards and downwards to correspond to head and cylinder boundaries): .Pp @@ -404,6 +413,8 @@ is used where it should actually be .Sq slice , in order to conform with the terms used elsewhere. .Pp -You cannot use this command to completely dedicate a disk to FreeBSD. The +You cannot use this command to completely dedicate a disk to +.Bx Free . +The .Xr disklabel 8 command must be used for this. diff --git a/sbin/i386/fdisk/fdisk.c b/sbin/i386/fdisk/fdisk.c index 1a0fc1cafc879..a4e3c1f518eb5 100644 --- a/sbin/i386/fdisk/fdisk.c +++ b/sbin/i386/fdisk/fdisk.c @@ -24,14 +24,20 @@ * the rights to redistribute these changes. */ -#include <sys/types.h> +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ + #include <sys/disklabel.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> #include <sys/stat.h> -#include <sys/ioctl.h> +#include <ctype.h> #include <fcntl.h> +#include <err.h> +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <unistd.h> int iotest; @@ -64,15 +70,13 @@ const char *disks[] = "/dev/rwd0", "/dev/rsd0", "/dev/rod0", 0 }; -char *name; - struct disklabel disklabel; /* disk parameters */ int cyls, sectors, heads, cylsecs, disksecs; struct mboot { - unsigned char padding[2]; /* force the longs to be long alligned */ + unsigned char padding[2]; /* force the longs to be long aligned */ unsigned char bootinst[DOSPARTOFF]; struct dos_partition parts[4]; unsigned short int signature; @@ -228,6 +232,7 @@ static int decimal(char *str, int *num, int deflt); static char *get_type(int type); static int read_config(char *config_file); static void reset_boot(void); +static void usage(void); #if 0 static int hex(char *str, int *num, int deflt); static int string(char *str, char **ans); @@ -239,11 +244,6 @@ main(int argc, char *argv[]) { int i; - name = *argv; - {register char *cp = name; - while (*cp) if (*cp++ == '/') name = cp; - } - for ( argv++ ; --argc ; argv++ ) { register char *token = *argv; if (*token++ != '-' || !*token) break; @@ -274,9 +274,7 @@ main(int argc, char *argv[]) else { if (argc == 1) - { - goto usage; - } + usage(); --argc; f_flag = *++argv; } @@ -297,7 +295,7 @@ main(int argc, char *argv[]) v_flag = 1; break; default: - goto usage; + usage(); } } } @@ -316,11 +314,7 @@ main(int argc, char *argv[]) } if (open_disk(u_flag) < 0) - { - fprintf(stderr, "Cannot open disk %s (%s)\n", - disk, sys_errlist[errno]); - exit(1); - } + err(1, "cannot open disk %s", disk); } else { @@ -333,11 +327,7 @@ main(int argc, char *argv[]) if(rv != -2) break; } if(rv < 0) - { - fprintf(stderr, "Cannot open any disk (%s)\n", - sys_errlist[errno]); - exit(1); - } + err(1, "cannot open any disk"); } printf("******* Working on device %s *******\n",disk); @@ -408,10 +398,14 @@ main(int argc, char *argv[]) } exit(0); +} -usage: - printf("fdisk {-a|-i|-u} [-f <config file> [-t] [-v]] [-{1,2,3,4}] [disk]\n"); - return(1); +static void +usage() +{ + fprintf(stderr, + "usage: fdisk {-a|-i|-u} [-f <config file> [-t] [-v]] [-{1,2,3,4}] [disk]\n"); + exit(1); } static void @@ -449,9 +443,9 @@ print_part(int i) part_mb *= secsize; part_mb /= (1024 * 1024); printf("sysid %d,(%s)\n", partp->dp_typ, get_type(partp->dp_typ)); - printf(" start %ld, size %ld (%qd Meg), flag %x%s\n", - partp->dp_start, - partp->dp_size, + printf(" start %lu, size %lu (%qd Meg), flag %x%s\n", + (u_long)partp->dp_start, + (u_long)partp->dp_size, part_mb, partp->dp_flag, partp->dp_flag == ACTIVE ? " (active)" : ""); @@ -648,22 +642,19 @@ open_disk(int u_flag) struct stat st; if (stat(disk, &st) == -1) { - fprintf(stderr, "%s: Can't get file status of %s\n", - name, disk); + warnx("can't get file status of %s", disk); return -1; } if ( !(st.st_mode & S_IFCHR) ) - fprintf(stderr,"%s: Device %s is not character special\n", - name, disk); + warnx("device %s is not character special", disk); if ((fd = open(disk, a_flag || u_flag ? O_RDWR : O_RDONLY)) == -1) { if(errno == ENXIO) return -2; - fprintf(stderr,"%s: Can't open device %s\n", name, disk); + warnx("can't open device %s", disk); return -1; } if (get_params(0) == -1) { - fprintf(stderr, "%s: Can't get disk parameters on %s\n", - name, disk); + warnx("can't get disk parameters on %s", disk); return -1; } return fd; @@ -702,9 +693,7 @@ get_params() { if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) { - fprintf(stderr, - "%s: Can't get disk parameters on %s; supplying dummy ones\n", - name, disk); + warnx("can't get disk parameters on %s; supplying dummy ones", disk); dos_cyls = cyls = 1; dos_heads = heads = 1; dos_sectors = sectors = 1; @@ -727,12 +716,11 @@ static int read_s0() { if (read_disk(0, (char *) mboot.bootinst) == -1) { - fprintf(stderr, "%s: Can't read fdisk partition table\n", name); + warnx("can't read fdisk partition table"); return -1; } if (mboot.signature != BOOT_MAGIC) { - fprintf(stderr, "%s: Invalid fdisk partition table found\n", - name); + warnx("invalid fdisk partition table found"); /* So should we initialize things */ return -1; } @@ -756,11 +744,10 @@ write_s0() flag = 1; #ifdef NOT_NOW if (ioctl(fd, DIOCWLABEL, &flag) < 0) - perror("ioctl DIOCWLABEL"); + warn("ioctl DIOCWLABEL"); #endif if (write_disk(0, (char *) mboot.bootinst) == -1) { - fprintf(stderr, "%s: Can't write fdisk partition table\n", - name); + warnx("can't write fdisk partition table"); return -1; flag = 0; #ifdef NOT_NOW @@ -979,18 +966,17 @@ process_geometry(command) geom_processed = 1; if (part_processed) { - fprintf(stderr, - "%s: ERROR line %d: the geometry specification line must occur before\n\ - all partition specifications.\n", - name, current_line_number); + warnx( + "ERROR line %d: the geometry specification line must occur before\n\ + all partition specifications", + current_line_number); status = 0; break; } if (command->n_args != 3) { - fprintf(stderr, - "%s: ERROR line %d: incorrect number of geometry args\n", - name, current_line_number); + warnx("ERROR line %d: incorrect number of geometry args", + current_line_number); status = 0; break; } @@ -1011,9 +997,9 @@ process_geometry(command) dos_sectors = command->args[i].arg_val; break; default: - fprintf(stderr, - "%s: ERROR line %d: unknown geometry arg type: '%c' (0x%02x)\n", - name, current_line_number, command->args[i].argtype, + warnx( + "ERROR line %d: unknown geometry arg type: '%c' (0x%02x)", + current_line_number, command->args[i].argtype, command->args[i].argtype); status = 0; break; @@ -1031,46 +1017,42 @@ process_geometry(command) */ if (dos_cyls < 0) { - fprintf(stderr, - "%s: ERROR line %d: number of cylinders not specified\n", - name, current_line_number); + warnx("ERROR line %d: number of cylinders not specified", + current_line_number); status = 0; } if (dos_cyls == 0 || dos_cyls > 1024) { - fprintf(stderr, - "%s: WARNING line %d: number of cylinders (%d) may be out-of-range\n\ + warnx( + "WARNING line %d: number of cylinders (%d) may be out-of-range\n\ (must be within 1-1024 for normal BIOS operation, unless the entire disk\n\ - is dedicated to FreeBSD).\n", - name, current_line_number, dos_cyls); + is dedicated to FreeBSD)", + current_line_number, dos_cyls); } if (dos_heads < 0) { - fprintf(stderr, - "%s: ERROR line %d: number of heads not specified\n", - name, current_line_number); + warnx("ERROR line %d: number of heads not specified", + current_line_number); status = 0; } else if (dos_heads < 1 || dos_heads > 256) { - fprintf(stderr, - "%s: ERROR line %d: number of heads must be within (1-256)\n", - name, current_line_number); + warnx("ERROR line %d: number of heads must be within (1-256)", + current_line_number); status = 0; } if (dos_sectors < 0) { - fprintf(stderr, "%s: ERROR line %d: number of sectors not specified\n", - name, current_line_number); + warnx("ERROR line %d: number of sectors not specified", + current_line_number); status = 0; } else if (dos_sectors < 1 || dos_sectors > 63) { - fprintf(stderr, - "%s: ERROR line %d: number of sectors must be within (1-63)\n", - name, current_line_number); + warnx("ERROR line %d: number of sectors must be within (1-63)", + current_line_number); status = 0; } @@ -1093,16 +1075,15 @@ process_partition(command) part_processed = 1; if (command->n_args != 4) { - fprintf(stderr, - "%s: ERROR line %d: incorrect number of partition args\n", - name, current_line_number); + warnx("ERROR line %d: incorrect number of partition args", + current_line_number); break; } partition = command->args[0].arg_val; if (partition < 1 || partition > 4) { - fprintf(stderr, "%s: ERROR line %d: invalid partition number %d\n", - name, current_line_number, partition); + warnx("ERROR line %d: invalid partition number %d", + current_line_number, partition); break; } partp = ((struct dos_partition *) &mboot.parts) + partition - 1; @@ -1137,16 +1118,16 @@ process_partition(command) /* * Can't go past end of partition */ - fprintf(stderr, - "%s: ERROR line %d: unable to adjust start of partition %d to fall on\n\ - a cylinder boundary.\n", - name, current_line_number, partition); + warnx( + "ERROR line %d: unable to adjust start of partition %d to fall on\n\ + a cylinder boundary", + current_line_number, partition); break; } - fprintf(stderr, - "%s: WARNING: adjusting start offset of partition '%d' from %d\n\ - to %d, to round to an head boundary.\n", - name, partition, partp->dp_start, adj_size); + warnx( + "WARNING: adjusting start offset of partition '%d' from %lu\n\ + to %lu, to round to an head boundary", + partition, (u_long)partp->dp_start, adj_size); partp->dp_start = adj_size; } @@ -1159,10 +1140,10 @@ process_partition(command) adj_size = chunks - partp->dp_start; if (adj_size != partp->dp_size) { - fprintf(stderr, - "%s: WARNING: adjusting size of partition '%d' from %d to %d,\n\ - to round to a cylinder boundary.\n", - name, partition, partp->dp_size, adj_size); + warnx( + "WARNING: adjusting size of partition '%d' from %lu to %lu,\n\ + to round to a cylinder boundary", + partition, (u_long)partp->dp_size, adj_size); if (chunks > 0) { partp->dp_size = adj_size; @@ -1174,9 +1155,8 @@ process_partition(command) } if (partp->dp_size < 1) { - fprintf(stderr, - "%s: ERROR line %d: size for partition '%d' is zero.\n", - name, current_line_number, partition); + warnx("ERROR line %d: size for partition '%d' is zero", + current_line_number, partition); break; } @@ -1203,17 +1183,16 @@ process_active(command) active_processed = 1; if (command->n_args != 1) { - fprintf(stderr, - "%s: ERROR line %d: incorrect number of active args\n", - name, current_line_number); + warnx("ERROR line %d: incorrect number of active args", + current_line_number); status = 0; break; } partition = command->args[0].arg_val; if (partition < 1 || partition > 4) { - fprintf(stderr, "%s: ERROR line %d: invalid partition number %d\n", - name, current_line_number, partition); + warnx("ERROR line %d: invalid partition number %d", + current_line_number, partition); break; } /* diff --git a/sbin/i386/ft/ft.8 b/sbin/i386/ft/ft.8 index 1306010637e90..986bb9267e183 100644 --- a/sbin/i386/ft/ft.8 +++ b/sbin/i386/ft/ft.8 @@ -10,7 +10,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" 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 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)ft.8 +.\" $Id$ .\" .Dd February 7, 1994 .Dt FT 8 @@ -40,15 +41,30 @@ .Sh SYNOPSIS .Nm ft .Op Fl f Ar tape +.Op Fl r .Op Ar description .Sh DESCRIPTION The -.Nm ft +.Nm command allows multi-volume dump, extract, and view of tape labels, for any pre-formatted QIC-40/80 tapes. It is totally system dependent, and has nothing to do with the QIC standards. .Pp -.Nm ft +The following options are available: +.Bl -tag -width indent +.It Fl f Ar tape +Read or write the specified +.Ar tape +(default is +.Pa /dev/rft0 +unless the environment variable +.Ev TAPE +is set). +.It Fl r +Do retension tape. +.El +.Pp +.Nm Ft is used primarily as a filter for tape i/o. For example, to save and compress the .Pa /usr @@ -84,5 +100,5 @@ drive makes a first pass over the entire tape writing out sectors. It then makes a second pass at a slower rate than usual (for sensitivity) to detect bad spots on the tape. Typically it takes an hour to format a single QIC-80 (120Mb uncompressed) tape. -.Sh AUTHOR -Steve Gerakines <steve2@genesis.nred.ma.us> +.Sh AUTHORS +.An Steve Gerakines Aq steve2@genesis.nred.ma.us diff --git a/sbin/i386/ft/ft.c b/sbin/i386/ft/ft.c index b1dbbb2c00b2f..41591a4239f9f 100644 --- a/sbin/i386/ft/ft.c +++ b/sbin/i386/ft/ft.c @@ -31,14 +31,21 @@ * 09/02/93 v0.2 pl01 * Initial revision. * - * usage: ft [ -f tape ] [ description ] + * usage: ft [ -f tape ] [ -r ] [ description ] */ +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ + +#include <err.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <signal.h> #include <time.h> +#include <unistd.h> #include <sys/ftape.h> #define DEFQIC "/dev/rft0" @@ -53,7 +60,7 @@ QIC_Geom geo; /* tape geometry */ int tvno = 1; /* tape volume number */ int tvlast; /* TRUE if last volume in set */ long tvsize = 0; /* tape volume size in bytes */ -long tvtime = NULL; /* tape change time */ +long tvtime = 0; /* tape change time */ char *tvnote = ""; /* tape note */ int doretension = 0; /* TRUE if we should retension tape */ @@ -73,7 +80,7 @@ int doretension = 0; /* TRUE if we should retension tape */ void usage(void) { - fprintf(stderr, "usage: ft [ -r ] [ -f device ] [ \"description\" ]\n"); + fprintf(stderr, "usage: ft [-f device] [-r] [\"description\"]\n"); exit(1); } @@ -84,35 +91,35 @@ usage(void) int check_stat(int fd, int wr) { - int r, s; + int s; int sawit = 0; /* get tape status */ if (ioctl(fd, QIOSTATUS, &s) < 0) { - fprintf(stderr, "could not get drive status\n"); + warnx("could not get drive status"); return(1); } /* wait for the tape drive to become ready */ while ((s & QS_READY) == 0) { if (!sawit) { - fprintf(stderr, "waiting for drive to become ready...\n"); + warnx("waiting for drive to become ready"); sawit = 1; } sleep(2); if (ioctl(fd, QIOSTATUS, &s) < 0) { - fprintf(stderr, "could not get drive status\n"); + warnx("could not get drive status"); return(1); } } if ((s & QS_FMTOK) == 0) { - fprintf(stderr, "tape is not formatted\n"); + warnx("tape is not formatted"); return(2); } if (wr && (s & QS_RDONLY) != 0) { - fprintf(stderr, "tape is write protected\n"); + warnx("tape is write protected"); return(3); } @@ -186,12 +193,12 @@ char *qstr(char *str, int nchar) int get_header(int fd) { - int r, sn, bytes; + int r, sn; QIC_Segment s; int gothdr = 0; if (ioctl(fd, QIOGEOM, &geo) < 0) { - fprintf(stderr, "couldn't determine tape geometry\n"); + warnx("couldn't determine tape geometry"); return(1); } @@ -208,7 +215,7 @@ get_header(int fd) if (hsn >= 0) { dhsn = sn; if (!r && !gothdr) { - fprintf(stderr, "using secondary header\n"); + warnx("using secondary header"); bcopy(s.sg_data, hbuff, QCV_SEGSIZE); gothdr = 1; } @@ -219,13 +226,13 @@ get_header(int fd) bcopy(s.sg_data, hbuff, QCV_SEGSIZE); gothdr = 1; } else { - fprintf(stderr, "too many errors in primary header\n"); + warnx("too many errors in primary header"); } } } if (!gothdr) { - fprintf(stderr, "couldn't read header segment\n"); + warnx("couldn't read header segment"); ioctl(fd, QIOREWIND); return(1); } @@ -237,16 +244,14 @@ get_header(int fd) /* * Open /dev/tty and ask for next volume. */ +void ask_vol(int vn) { - FILE *inp; int fd; char c; - if ((fd = open("/dev/tty", 2)) < 0) { - fprintf(stderr, "argh!! can't open /dev/tty\n"); - exit(1); - } + if ((fd = open("/dev/tty", 2)) < 0) + errx(1, "argh!! can't open /dev/tty"); fprintf(stderr, "Insert ftfilt volume %02d and press enter:", vn); read(fd, &c, 1); @@ -273,7 +278,7 @@ do_getname(void) void do_read(void) { - int sno, vno, sbytes, r, eccfails; + int sno, vno, sbytes, eccfails; long curpos; char *hname; QIC_Segment s; @@ -330,13 +335,12 @@ do_read(void) if (check_parity(s.sg_data, s.sg_badmap, s.sg_crcmap)) { if (++eccfails <= 5) { - fprintf(stderr, - "ft: retry %d at segment %d byte %ld\n", + warnx("retry %d at segment %d byte %ld", eccfails, sno, curpos); continue; } else - fprintf(stderr, - "ft: *** ecc failure in segment %d at byte %ld\n", + warnx( + "*** ecc failure in segment %d at byte %ld", sno, curpos); } if (tvsize < sbytes) sbytes = tvsize; @@ -360,7 +364,7 @@ void do_write(void) { int sno, vno, amt, sbytes; - int c, maxseg, r; + int maxseg, r; ULONG qnow; QIC_Segment s; char tmpstr[80]; @@ -414,11 +418,9 @@ do_write(void) if (amt < sbytes) bzero(&s.sg_data[amt], sbytes - amt); r = set_parity(s.sg_data, s.sg_badmap); - if (r) fprintf(stderr, "** warning: ecc problem !!\n"); - if (ioctl(tfd, QIOWRITE, &s) < 0) { - perror("QIOWRITE"); - exit(1); - } + if (r) warnx("** warning: ecc problem !!"); + if (ioctl(tfd, QIOWRITE, &s) < 0) + err(1, "QIOWRITE"); tvsize += amt; } } @@ -427,7 +429,7 @@ do_write(void) /* ftfilt vol*xx yyyyyyyyyy note56789012345678 */ /* 01234567890123456789012345678901234567890123 */ - sprintf(tmpstr, "ftfilt vol%s%02d %010d %s", + sprintf(tmpstr, "ftfilt vol%s%02d %010ld %s", (tvlast) ? "*" : " ", tvno, tvsize, tvnote); strncpy(hptr->qh_tname, tmpstr, 44); UL_VAL(hptr->qh_chgdate,0) = qnow; @@ -439,11 +441,9 @@ do_write(void) s.sg_badmap = 0; s.sg_data = (UCHAR *)hbuff; r = set_parity(s.sg_data, s.sg_badmap); - if (r) fprintf(stderr, "** warning: header ecc problem !!\n"); - if (ioctl(tfd, QIOWRITE, &s) < 0) { - perror("QIOWRITE"); - exit(1); - } + if (r) warnx("** warning: header ecc problem !!"); + if (ioctl(tfd, QIOWRITE, &s) < 0) + err(1, "QIOWRITE"); } if (dhsn >= 0) { s.sg_trk = dhsn / geo.g_segtrk; @@ -451,11 +451,9 @@ do_write(void) s.sg_badmap = 0; s.sg_data = (UCHAR *)hbuff; r = set_parity(s.sg_data, s.sg_badmap); - if (r) fprintf(stderr, "** warning: duphdr ecc problem !!\n"); - if (ioctl(tfd, QIOWRITE, &s) < 0) { - perror("QIOWRITE"); - exit(1); - } + if (r) warnx("** warning: duphdr ecc problem !!"); + if (ioctl(tfd, QIOWRITE, &s) < 0) + err(1, "QIOWRITE"); } ioctl(tfd, QIOREWIND); if (tvlast) break; @@ -467,10 +465,10 @@ do_write(void) /* * Entry. */ -void +int main(int argc, char *argv[]) { - int r, s, i; + int i; char *tape, *getenv(); @@ -500,10 +498,8 @@ main(int argc, char *argv[]) } /* Open the tape device */ - if ((tfd = open(tape, 2)) < 0) { - perror(tape); - exit(1); - } + if ((tfd = open(tape, 2)) < 0) + err(1, "%s", tape); if (!isatty(0)) do_write(); diff --git a/sbin/i386/nextboot/nextboot.8 b/sbin/i386/nextboot/nextboot.8 index 089debd204128..f4fab2b8380d4 100644 --- a/sbin/i386/nextboot/nextboot.8 +++ b/sbin/i386/nextboot/nextboot.8 @@ -1,40 +1,31 @@ -.\" $Id: nextboot.8,v 1.3 1996/09/23 22:23:15 wosch Exp $ +.\" $Id: nextboot.8,v 1.3.2.1 1996/12/10 16:43:01 joerg Exp $ .Dd July 9, 1996 .Dt NEXTBOOT 8 .\".Os BSD 4 .Sh NAME .Nm nextboot -.Nd Install a default bootstring block on the boot disk +.Nd install a default bootstring block on the boot disk .Sh SYNOPSIS -.Nm +.Nm nextboot .Op Fl b -.Ar filename bootstring ... -.Pp -.Nm +.Ar filename bootstring +.Ar +.Nm nextboot .Op Fl ed .Ar filename -.Bl -tag -width time -.It Fl b -Is used for bootstrapping (initially configuring) the nameblock. Without -this, -.Nm -will refuse to write to a block that does not already contain the magic -number. -.It Fl d -temporarily disables an existing name block by changing a bit -in the magic number. -.It Fl e -restores the good magic number on a block disabled by -d. -.El -.Sh PROLOGUE -The FreeBSD program +.Sh DESCRIPTION +The +.Bx Free +program .Nm controls the actions of the boot blocks at the time of the next boot. If compiled with the correct option, the boot blocks will check the nameblock for a magic number and a default name to use for booting. If compiled to do so they will also delete the name from the block, ensuring that if the boot should fail, -then it will not be tried again. It is the job of /etc/rc to use +then it will not be tried again. It is the job of +.Pa /etc/rc +to use .Nm to re-install the string if that boot is found to have succeeded. This allows a one-time only boot string to be used for such applications @@ -42,8 +33,29 @@ as remote debugging, and installation of new, untrusted kernels. The nameblock is defined at compile time to be the second physical block on the disk. .Pp -.Sh DESCRIPTION +The following options are available: +.Bl -tag -width indent +.It Fl b +Is used for bootstrapping (initially configuring) the nameblock. Without +this, .Nm +will refuse to write to a block that does not already contain the magic +number. +.It Fl d +Disable (temporarily) an existing name block by changing a bit +in the magic number. +.It Fl e +Restore the good magic number on a block disabled by +.Fl d . +.El +.Pp +The +.Fl e +and +.Fl d +flags are mutually exclusive. +.Sh DESCRIPTION +.Nm Nextboot first checks that the disk has an fdisk table and checks that none of the partitions defined in that table include the nameblock. If the name block is shown to be unused, it will install the bootstrings given as arguments, @@ -61,18 +73,20 @@ An example of usage might be: .Ed .Pp Which would instruct the boot blocks at the next boot, -to try boot the experimental kernel off the scsi disk. +to try boot the experimental kernel off the SCSI disk. If for any reason this failed, the next boot attempt would boot the kernel -.Em /kernel.old -off the IDE drive. (assuming the write-back option were enabled) If this -in turn failed. the compiled in default would be used. +.Pa /kernel.old +off the IDE drive. (Assuming the write-back option were enabled) If this +in turn failed. The compiled in default would be used. .Pp If the write-back feature is disabled, the nextboot program is a convenient way to change the default boot string. Note, that should the file specified in -the nameblock be non-existant, then the name compiled into the boot blocks +the nameblock be non-existent, then the name compiled into the boot blocks will be used for the boot rather than the next name in the nameblock. The -nameblock is only consulted ONCE per boot. +nameblock is only consulted +.Em once +per boot. .Sh SEE ALSO .Xr boot 8 , .Xr disklabel 8 , diff --git a/sbin/i386/nextboot/nextboot.c b/sbin/i386/nextboot/nextboot.c index f25dfbc9eeb18..d266061b1415e 100644 --- a/sbin/i386/nextboot/nextboot.c +++ b/sbin/i386/nextboot/nextboot.c @@ -1,4 +1,3 @@ - /* * Copyright (c) 1996 Whistle Communications * All Rights Reserved. @@ -14,22 +13,23 @@ * any damages whatsoever resulting from the use of this software. */ +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include <sys/types.h> #include <sys/disklabel.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <sys/stat.h> -#include <sys/ioctl.h> #include <fcntl.h> -#include <unistd.h> +#include <err.h> +#include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> struct mboot { - unsigned char padding[2]; /* force the longs to be long alligned */ + unsigned char padding[2]; /* force the longs to be long aligned */ unsigned char bootinst[DOSPARTOFF]; struct dos_partition parts[4]; unsigned short int signature; @@ -43,20 +43,18 @@ struct mboot mboot; static int bflag; static int eflag; static int dflag; -static int nameblock = NAMEBLOCK; #define BOOT_MAGIC 0xAA55 -extern char *__progname; - -static void usage(void) { - fprintf (stderr, " usage: %s [-b] device bootstring [bootstring] ...\n" - , __progname); - fprintf (stderr, " or: %s {-e,-d} device \n" , __progname); - fprintf (stderr, "The -e and -d flags are mutually exclusive\n"); +static void +usage(void) { + fprintf (stderr, "%s\n%s\n", + "usage: nextboot [-b] device bootstring [bootstring] ...", + " nextboot {-e,-d} device"); exit(1); } +int main (int argc, char** argv) { int fd = -1; @@ -66,7 +64,7 @@ main (int argc, char** argv) int part; bflag = 0; - while ((ch = getopt(argc, argv, "bde")) != -1) { + while ((ch = getopt(argc, argv, "bde")) != -1) { switch(ch) { case 'b': bflag = 1; @@ -97,11 +95,8 @@ main (int argc, char** argv) usage(); } } - if ((fd = open(argv[0], O_RDWR, 0)) < 0) { - perror("open"); - printf ("file: %s\n",argv[0]); - usage(); - } + if ((fd = open(argv[0], O_RDWR, 0)) < 0) + errx(1, "can't open %s", argv[0]); argc--; argv++; @@ -109,18 +104,12 @@ main (int argc, char** argv) /******************************************* * Check that we have an MBR */ - if (lseek(fd,0,0) == -1) { - perror("lseek"); - exit(1); - } - if (read (fd,&mboot.bootinst[0],BLOCKSIZE ) != BLOCKSIZE) { - perror("read0"); - exit(1); - } - if(mboot.signature != (unsigned short)BOOT_MAGIC) { - printf(" no fdisk part.. not touching block 1\n"); - exit(1); - } + if (lseek(fd,0,0) == -1) + err(1, "lseek"); + if (read (fd,&mboot.bootinst[0],BLOCKSIZE ) != BLOCKSIZE) + err(1, "read0"); + if (mboot.signature != (unsigned short)BOOT_MAGIC) + errx(1, "no fdisk part.. not touching block 1"); /******************************************* * And check that none of the partitions in it cover the name block; @@ -129,28 +118,22 @@ main (int argc, char** argv) if( mboot.parts[part].dp_size && (mboot.parts[part].dp_start <= NAMEBLOCK) && (mboot.parts[part].dp_start - + mboot.parts[part].dp_size > NAMEBLOCK)) { - printf(" Name sector lies within a Bios partition.\n"); - printf(" Aborting write.\n"); - exit(1); - } + + mboot.parts[part].dp_size > NAMEBLOCK)) + errx(1, + "name sector lies within a Bios partition: aborting write"); } /******************************************* - * Now check the name sector itself to see if it's been initialised. + * Now check the name sector itself to see if it's been initialized. */ - if (lseek(fd,NAMEBLOCK * BLOCKSIZE,0) == -1) { - perror("lseek"); - exit(1); - } - if ( read (fd,namebuf,BLOCKSIZE ) != BLOCKSIZE) { - perror("read1"); - exit(1); - } + if (lseek(fd,NAMEBLOCK * BLOCKSIZE,0) == -1) + err(1, "lseek"); + if (read(fd,namebuf,BLOCKSIZE) != BLOCKSIZE) + err(1, "read1"); /******************************************* * check if we are just enabling or disabling - * Remember the flags are exlusive.. + * Remember the flags are exclusive.. */ if(!bflag) { /* don't care what's there if bflag is set */ switch(*(unsigned long *)cp) @@ -159,10 +142,7 @@ main (int argc, char** argv) case ENABLE_MAGIC: break; default: - fprintf(stderr, - "namesector not initialised.." - "use the -b flag..\n"); - exit(1); + errx(1, "namesector not initialized, use the -b flag"); } } @@ -199,24 +179,18 @@ main (int argc, char** argv) /******************************************* * write it to disk. */ - if (lseek(fd,NAMEBLOCK * BLOCKSIZE,0) == -1) { - perror("lseek"); - exit(1); - } - if(write (fd,namebuf,BLOCKSIZE ) != BLOCKSIZE) { - perror("write"); - exit(1); - } + if (lseek(fd,NAMEBLOCK * BLOCKSIZE,0) == -1) + err(1, "lseek"); + if(write (fd,namebuf,BLOCKSIZE ) != BLOCKSIZE) + err(1, "write"); #if 0 /******************************************* * just to be safe/paranoid.. read it back.. * and print it.. */ - if (lseek(fd,NAMEBLOCK * BLOCKSIZE,0) == -1) { - perror("lseek (second) "); - exit(1); - } + if (lseek(fd,NAMEBLOCK * BLOCKSIZE,0) == -1) + err(1, "lseek (second)"); read (fd,namebuf,512); for (i = 0;i< 16;i++) { for ( j = 0; j < 16; j++) { @@ -227,5 +201,3 @@ main (int argc, char** argv) #endif exit(0); } - - diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 352d0387a36e9..282e049c24303 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -10,7 +10,7 @@ .\" 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: +.\" must display the following acknowledgment: .\" 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 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 -.\" $Id: ifconfig.8,v 1.9.2.3 1998/02/01 07:05:02 steve Exp $ +.\" $Id: ifconfig.8,v 1.9.2.4 1998/06/08 02:02:31 danny Exp $ .\" .Dd February 13, 1996 .Dt IFCONFIG 8 @@ -47,36 +47,31 @@ .Oc .Op Ar parameters .Nm ifconfig -.Op Fl m -.Ar interface -.Op Ar protocol_family -.Nm ifconfig .Fl a -.Op Fl m .Op Fl d .Op Fl u -.Op Ar protocol_family +.Op Ar address_family .Nm ifconfig .Fl l .Op Fl d .Op Fl u +.Op Ar address_family .Sh DESCRIPTION -.Nm +.Nm Ifconfig is used to assign an address to a network interface and/or configure network interface parameters. -.Nm +.Nm Ifconfig must be used at boot time to define the network address of each interface present on a machine; it may also be used at a later time to redefine an interface's address or other operating parameters. .Pp -Available operands for -.Nm ifconfig : -.Bl -tag -width Ds -.It Ar Address +The following options are available: +.Bl -tag -width indent +.It Ar address For the -.Tn DARPA-Internet +.Tn DARPA Ns -Internet family, the address is either a host name present in the host name data base, @@ -106,8 +101,8 @@ Internet address expressed in the Internet standard .\" byte, and the dots are optional, if the user wishes to (carefully) .\" count out long strings of digits in network byte order. .It Ar address_family -Specifies the -.Ar address family +Specify the +.Ar "address family" which affects interpretation of the remaining parameters. Since an interface can receive transmissions in differing protocols with different naming schemes, specifying the address family is recommended. @@ -120,18 +115,20 @@ and .Dq ipx . .\" and .\" .Dq ns . -.It Ar Interface -The -.Ar interface +.It Ar dest_address +Specify the address of the correspondent on the other end +of a point to point link. +.It Ar interface +This parameter is a string of the form .Dq name unit , for example, -.Dq en0 +.Dq en0 . .El .Pp The following parameters may be set with .Nm ifconfig : -.Bl -tag -width dest_addressxx +.Bl -tag -width indent .It Cm alias Establish an additional network address for this interface. This is sometimes useful when changing network numbers, and @@ -162,9 +159,6 @@ was no longer needed. If you have incorrectly set an NS address having the side effect of specifying the host portion, removing all NS addresses will allow you to respecify the host portion. -.It Cm dest_address -Specify the address of the correspondent on the other end -of a point to point link. .It Cm down Mark an interface ``down''. When an interface is marked ``down'', the system will not attempt to @@ -181,7 +175,8 @@ This action does not automatically disable routes using the interface. .\" .Tn CLNP .\" packets is done differently. .It Cm media Ar type -Set the media type of the interface to +If the driver supports the media selection system, set the media type +of the interface to .Ar type . Some interfaces support the mutually exclusive use of one of several different physical media connectors. For example, a 10Mb/s Ethernet @@ -193,15 +188,18 @@ would change the currently active connector to the AUI port. Setting it to .Dq 10baseT/UTP would activate twisted pair. Refer to the interfaces' driver -specific man page for a complete list of the available types. +specific documentation or man page for a complete list of the +available types. .It Cm mediaopt Ar opts -Set the specified media options on the interface. -.Ar opts +If the driver supports the media selection system, set the specified +media options on the interface. +.Ar Opts is a comma delimited list of options to apply to the interface. Refer to the interfaces' driver specific man page for a complete list of available options. .It Fl mediaopt Ar opts -Disable the specified media options on the interface. +If the driver supports the media selection system, disable the +specified media options on the interface. .It Cm metric Ar n Set the routing metric of the interface to .Ar n , @@ -267,7 +265,9 @@ portion. Under appletalk, set the interface to respond to a .Em netrange. of the form startnet-endnet. Appletalk uses this scheme instead of -netmasks though FreeBSD implements it internally as a set of netmasks. +netmasks though +.Bx Free +implements it internally as a set of netmasks. .It Cm phase The argument following this specifies the version (phase) of the Appletalk network attached to the interface. Values of 1 or 2 are permitted. @@ -276,37 +276,38 @@ Enable special processing of the link level of the interface. These three options are interface specific in actual effect, however, they are in general used to select special modes of operation. An example of this is to enable SLIP compression, or to select the connector type -for some ethernet cards. Refer to the man page for the specific driver +for some Ethernet cards. Refer to the man page for the specific driver for more information. .It Fl link[0-2] Disable special processing at the link level with the specified interface. .It Cm up -Mark an interface ``up''. -This may be used to enable an interface after an ``ifconfig down.'' +Mark an interface +.Dq up . +This may be used to enable an interface after an +.Dq ifconfig down . It happens automatically when setting the first address on an interface. If the interface was reset when previously marked down, the hardware will be re-initialized. .El .Pp -.Nm +.Nm Ifconfig displays the current configuration for a network interface when no optional parameters are supplied. If a protocol family is specified, -Ifconfig will report only the details specific to that protocol family. -.Pp -If the -.Fl m -flag is passed before an interface name, .Nm -will display all of the supported media for the specified interface. +will report only the details specific to that protocol family. +.Pp +If the driver does supports the media selection system, the supported +media list will be included in the output. .Pp Optionally, the .Fl a flag may be used instead of an interface name. This flag instructs .Nm to display information about all interfaces in the system. +The .Fl d -limits this to interfaces that are down, and +flag limits this to interfaces that are down, and .Fl u limits this to interfaces that are up. .Pp @@ -322,6 +323,9 @@ and (only list interfaces that are up). .Pp Only the super-user may modify the configuration of a network interface. +.Sh NOTES +The media selection system is relatively new and only some drivers support +it (or have need for it). .Sh DIAGNOSTICS Messages indicating the specified interface does not exist, the requested address is unknown, or the user is not privileged and diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 6ae7410bfdbb0..2b38511ac973f 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -38,11 +38,11 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint -/* +#if 0 static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; -*/ +#endif static const char rcsid[] = - "$Id: ifconfig.c,v 1.30 1997/05/10 17:14:52 peter Exp $"; + "$Id: ifconfig.c,v 1.19.2.1 1997/06/30 11:02:00 peter Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -117,7 +117,6 @@ int setipdst; int doalias; int clearaddr; int newaddr = 1; -int allmedia; struct afswtch; @@ -219,8 +218,8 @@ struct afswtch { short af_af; af_status *af_status; af_getaddr *af_getaddr; - int af_difaddr; - int af_aifaddr; + u_long af_difaddr; + u_long af_aifaddr; caddr_t af_ridreq; caddr_t af_addreq; } afs[] = { @@ -278,21 +277,11 @@ rt_xaddrs(cp, cplim, rtinfo) void usage() { - fputs("usage: ifconfig -a [ -m ] [ -d ] [ -u ] [ af ]\n", stderr); - fputs(" ifconfig -l [ -d ] [ -u ]\n", stderr); - fputs(" ifconfig [ -m ] interface\n", stderr); - fputs(" [ af [ address [ dest_addr ] ] [ netmask mask ] [ broadcast addr ]\n", stderr); - fputs(" [ alias ] [ delete ] ]\n", stderr); - fputs(" [ up ] [ down ]\n", stderr); - fputs(" [ metric n ]\n", stderr); - fputs(" [ mtu n ]\n", stderr); - fputs(" [ arp | -arp ]\n", stderr); - fputs(" [ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ]\n", stderr); -#ifdef USE_IF_MEDIA - fputs(" [ media mtype ]\n", stderr); - fputs(" [ mediaopt mopts ]\n", stderr); - fputs(" [ -mediaopt mopts ]\n", stderr); -#endif + fprintf(stderr, "%s\n%s\n%s\n%s\n", + "usage: ifconfig interface address_family [address [dest_address]]", + " [parameters]", + " ifconfig -a [-d] [-u] [address_family]", + " ifconfig -l [-d] [-u] [address_family]"); exit(1); } @@ -316,7 +305,7 @@ main(argc, argv) int mib[6]; /* Parse leading line options */ - all = allmedia = downonly = uponly = namesonly = 0; + all = downonly = uponly = namesonly = 0; while ((c = getopt(argc, argv, "adlmu")) != -1) { switch (c) { case 'a': /* scan all interfaces */ @@ -328,16 +317,11 @@ main(argc, argv) case 'd': /* restrict scan to "down" interfaces */ downonly++; break; - case 'u': /* restrict scan to "down" interfaces */ + case 'u': /* restrict scan to "up" interfaces */ uponly++; break; case 'm': /* show media choices in status */ -#ifdef USE_IF_MEDIA - allmedia++; -#else - fputs("WARNING: if_media not compiled in!\n", stderr); - usage(); -#endif + /* ignored for compatibility */ break; default: usage(); @@ -348,7 +332,7 @@ main(argc, argv) argv += optind; /* -l cannot be used with -a or -m */ - if (namesonly && (all || allmedia)) + if (namesonly && all) usage(); /* nonsense.. */ @@ -371,7 +355,7 @@ main(argc, argv) /* leave with afp non-zero */ } } else { - /* not listsing, need an argument */ + /* not listing, need an argument */ if (argc < 1) usage(); @@ -454,10 +438,14 @@ main(argc, argv) strncpy(name, sdl->sdl_data, sdl->sdl_nlen); name[sdl->sdl_nlen] = '\0'; if (namesonly) { - if (need_nl) - putchar(' '); - fputs(name, stdout); - need_nl++; + if (afp == NULL || + afp->af_status != ether_status || + sdl->sdl_type == IFT_ETHER) { + if (need_nl) + putchar(' '); + fputs(name, stdout); + need_nl++; + } continue; } } else { @@ -503,10 +491,8 @@ ifconfig(argc, argv, afp) ifr.ifr_addr.sa_family = afp->af_af; strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); - if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0) { - perror("ifconfig: socket"); - exit(1); - } + if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0) + err(1, "socket"); while (argc > 0) { register const struct cmd *p; @@ -710,7 +696,7 @@ setifmetric(val, dummy, s, afp) strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_metric = atoi(val); if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0) - perror("ioctl (set metric)"); + warn("ioctl (set metric)"); } void @@ -723,7 +709,7 @@ setifmtu(val, dummy, s, afp) strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_mtu = atoi(val); if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0) - perror("ioctl (set mtu)"); + warn("ioctl (set mtu)"); } #ifdef ISO @@ -766,10 +752,8 @@ status(afp, addrcount, sdl, ifm, ifam) ifr.ifr_addr.sa_family = afp->af_af; strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); - if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0) { - perror("ifconfig: socket"); - exit(1); - } + if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0) + err(1, "socket"); /* * XXX is it we are doing a SIOCGIFMETRIC etc for one family. @@ -778,12 +762,12 @@ status(afp, addrcount, sdl, ifm, ifam) * metric and mtu is printed on the global the flags line. */ if (ioctl(s, SIOCGIFMETRIC, (caddr_t)&ifr) < 0) - perror("ioctl (SIOCGIFMETRIC)"); + warn("ioctl (SIOCGIFMETRIC)"); else metric = ifr.ifr_metric; if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) < 0) - perror("ioctl (SIOCGIFMTU)"); + warn("ioctl (SIOCGIFMTU)"); else mtu = ifr.ifr_mtu; @@ -1041,7 +1025,8 @@ in_getaddr(s, which) if (inet_aton(s, &sin->sin_addr)) return; if ((hp = gethostbyname(s)) != 0) - bcopy(hp->h_addr, (char *)&sin->sin_addr, hp->h_length); + bcopy(hp->h_addr, (char *)&sin->sin_addr, + MIN(hp->h_length, sizeof(sin->sin_addr))); else if ((np = getnetbyname(s)) != 0) sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY); else @@ -1112,7 +1097,7 @@ at_getaddr(addr, which) sat->sat_family = AF_APPLETALK; sat->sat_len = sizeof(*sat); if (which == MASK) - errx(1, "AppleTalk does not use netmasks\n"); + errx(1, "AppleTalk does not use netmasks"); if (sscanf(addr, "%u.%u", &net, &node) != 2 || net > 0xffff || node > 0xfe) errx(1, "%s: illegal address", addr); @@ -1222,9 +1207,9 @@ setnsellength(val) { nsellength = atoi(val); if (nsellength < 0) - errx(1, "Negative NSEL length is absurd"); + errx(1, "negative NSEL length is absurd"); if (afp == 0 || afp->af_af != AF_ISO) - errx(1, "Setting NSEL length valid only for iso"); + errx(1, "setting NSEL length valid only for iso"); } void diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c index 8b1cdb2fe4aef..cfaef8870da7d 100644 --- a/sbin/ifconfig/ifmedia.c +++ b/sbin/ifconfig/ifmedia.c @@ -1,5 +1,5 @@ /* $NetBSD: ifconfig.c,v 1.34 1997/04/21 01:17:58 lukem Exp $ */ -/* $Id$ */ +/* $Id: ifmedia.c,v 1.3.2.1 1997/06/30 11:02:04 peter Exp $ */ /* * Copyright (c) 1997 Jason R. Thorpe. @@ -157,7 +157,7 @@ media_status(s, info) putchar('\n'); - if (allmedia) { + if (ifmr.ifm_count > 0) { printf("\tsupported media:"); for (i = 0; i < ifmr.ifm_count; i++) { putchar(' '); diff --git a/sbin/init/init.8 b/sbin/init/init.8 index d00dcf7c62526..7e50f613994a3 100644 --- a/sbin/init/init.8 +++ b/sbin/init/init.8 @@ -33,7 +33,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)init.8 8.3 (Berkeley) 4/18/94 -.\" $Id: init.8,v 1.4.2.3 1997/08/18 03:30:04 davidn Exp $ +.\" $Id: init.8,v 1.4.2.4 1998/07/06 12:01:34 jkoshy Exp $ .\" .Dd April 18, 1994 .Dt INIT 8 @@ -45,18 +45,18 @@ .Nm init .Sh DESCRIPTION The -.Nm init +.Nm program is the last stage of the boot process. It normally runs the automatic reboot sequence as described in .Xr reboot 8 , and if this succeeds, begins multi-user operation. If the reboot scripts fail, -.Nm init +.Nm commences single user operation by giving the super-user a shell on the console. The -.Nm init +.Nm program may be passed parameters from the boot program to prevent the system from going multi-user and to instead execute @@ -66,27 +66,27 @@ later be made to go to multi-user by exiting the single-user shell (with ^D). This causes -.Nm init +.Nm to run the .Pa /etc/rc start up command file in fastboot mode (skipping disk checks). .Pp If the -.Nm console +.Em console entry in the .Xr ttys 5 file is marked ``insecure'', then -.Nm init +.Nm will require that the superuser password be entered before the system will start a single-user shell. The password check is skipped if the -.Nm console +.Em console is marked as ``secure''. .Pp The kernel runs with four different levels of security. Any superuser process can raise the security level, but only -.Nm init +.Nm can lower it. The security levels are: .Bl -tag -width flag @@ -116,10 +116,10 @@ while the system is multi-user. .El .Pp If the security level is initially -1, then -.Nm init +.Nm leaves it unchanged. Otherwise, -.Nm init +.Nm arranges to run the system in level 0 mode while single user and in level 1 mode while multiuser. If level 2 mode is desired while running multiuser, @@ -127,12 +127,12 @@ it can be set while single user, e.g., in the startup script .Pa /etc/rc , using .Xr sysctl 8 -to set the +to set the .Dq kern.securelevel -variable to the desired security level. +variable to the required security level. .Pp In multi-user operation, -.Nm init +.Nm maintains processes for the terminal ports found in the file .Xr ttys 5 . @@ -153,7 +153,7 @@ executes a shell for that user. When this shell dies, either because the user logged out or an abnormal termination occurred (a signal), the -.Nm init +.Nm program wakes up, deletes the user from the .Xr utmp 5 @@ -162,7 +162,7 @@ file of current users and records the logout in the file. The cycle is then restarted by -.Nm init +.Nm executing a new .Nm getty for the line. @@ -173,34 +173,34 @@ may be changed in the file without a reboot by sending the signal .Dv SIGHUP to -.Nm init +.Nm with the command .Dq Li "kill -HUP 1" . On receipt of this signal, -.Nm init +.Nm re-reads the .Xr ttys 5 file. When a line is turned off in .Xr ttys 5 , -.Nm init +.Nm will send a SIGHUP signal to the controlling process for the session associated with the line. For any lines that were previously turned off in the .Xr ttys 5 file and are now on, -.Nm init +.Nm executes a new .Nm getty to enable a new login. If the getty or window field for a line is changed, the change takes effect at the end of the current login session (e.g., the next time -.Nm init +.Nm starts a process on the line). If a line is commented out or deleted from .Xr ttys 5 , -.Nm init +.Nm will not do anything at all to that line. However, it will complain that the relationship between lines in the @@ -218,7 +218,7 @@ signal, for example, .Dq Li "kill \-TERM 1" . If there are processes outstanding that are deadlocked (because of hardware or software failure), -.Nm init +.Nm will not wait for them all to die (which might take forever), but will time out after 30 seconds and print a warning message. .Pp @@ -246,7 +246,7 @@ This is useful for shutting the machine down cleanly from inside the kernel or from X when the machine appears to be hung. .Pp When shutting down the machine, -.Nm init +.Nm will try to run the .Pa /etc/rc.shutdown script. This script can be used to cleanly terminate specific programs such @@ -255,11 +255,11 @@ as (the InterNetNews server). .Pp The role of -.Nm init +.Nm is so critical that if it dies, the system will reboot itself automatically. If, at bootstrap time, the -.Nm init +.Nm process cannot be located, the system will panic with the message ``panic: "init died (signal %d, exit %d)''. .Sh DIAGNOSTICS @@ -281,20 +281,20 @@ a persistent device error condition. .Sh FILES .Bl -tag -width /var/log/wtmp -compact .It Pa /dev/console -System console device. +system console device .It Pa /dev/tty* -Terminal ports found in -.Xr ttys 5 . +terminal ports found in +.Xr ttys 5 .It Pa /var/run/utmp -Record of Current users on the system. +record of current users on the system .It Pa /var/log/wtmp -Record of all logins and logouts. +record of all logins and logouts .It Pa /etc/ttys -The terminal initialization information file. +the terminal initialization information file .It Pa /etc/rc -System startup commands. +system startup commands .It Pa /etc/rc.shutdown -System shutdown commands. +system shutdown commands .El .Sh SEE ALSO .Xr kill 1 , @@ -318,10 +318,10 @@ Systems without .Xr sysctl behave as though they have security level \-1. .Pp -Setting the security level to 2 too early in the boot sequence can +Setting the security level to 2 too early in the boot sequence can prevent -.Xr fsck 8 -from repairing inconsistent filesystems. The +.Xr fsck 8 +from repairing inconsistent filesystems. The preferred location to set the security level is at the end of -.Pa /etc/rc +.Pa /etc/rc after all multi-user startup actions are complete. diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1 index 676e4a00c5555..7fb415fd07174 100644 --- a/sbin/md5/md5.1 +++ b/sbin/md5/md5.1 @@ -5,12 +5,12 @@ .Nm md5 .Nd calculate a message-digest fingerprint (checksum) for a file .Sh SYNOPSIS -.Nm +.Nm md5 .Op Fl ptx .Op Fl s Ar string .Op Ar file ... .Sh DESCRIPTION -.Nm +.Nm Md5 takes as input a message of arbitrary length and produces as output a 128-bit .Dq fingerprint @@ -31,16 +31,16 @@ The following four options may be used in any combination and must precede any files named on the command line. The MD5 sum of each file listed on the command line is printed after the options are processed. -.Bl -tag -width Fl +.Bl -tag -width indent .It Fl s Ar string -prints a checksum of the given +Print a checksum of the given .Ar string . .It Fl p -echos stdin to stdout and appends the MD5 sum to stdout. +Echo stdin to stdout and appends the MD5 sum to stdout. .It Fl t -runs a built-in time trial. +Run a built-in time trial. .It Fl x -runs a built-in test script. +Run a built-in test script. .El .Sh SEE ALSO .Xr cksum 1 @@ -49,6 +49,6 @@ runs a built-in test script. .%T The MD5 Message-Digest Algorithm .%O RFC1321 .Re -.Sh ACKNOWLEDGEMENTS +.Sh ACKNOWLEDGMENTS This program is placed in the public domain for free general use by RSA Data Security. diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index 454f830bf4f78..81a86168dd74c 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -1,5 +1,5 @@ /* - * $Id: md5.c,v 1.7.2.1 1997/09/03 06:49:48 jkh Exp $ + * $Id: md5.c,v 1.7.2.2 1998/03/06 08:15:33 jkh Exp $ * * Derived from: */ @@ -21,12 +21,16 @@ * documentation and/or software. */ +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ + #include <sys/types.h> +#include <err.h> #include <md5.h> - #include <stdio.h> #include <stdlib.h> -#include <string.h> #include <time.h> #include <unistd.h> @@ -84,7 +88,7 @@ main(argc, argv) while (optind < argc) { p = MD5File(argv[optind], buf); if (!p) - perror(argv[optind]); + warn("%s", argv[optind]); else printf("MD5 (%s) = %s\n", argv[optind], p); optind++; @@ -182,10 +186,8 @@ MDFilter(pipe) MD5Init(&context); while ((len = fread(buffer, 1, BUFSIZ, stdin))) { - if(pipe && (len != fwrite(buffer, 1, len, stdout))) { - perror("stdout"); - exit(1); - } + if(pipe && (len != fwrite(buffer, 1, len, stdout))) + err(1, "stdout"); MD5Update(&context, buffer, len); } printf("%s\n", MD5End(&context,buf)); diff --git a/sbin/mknod/mknod.8 b/sbin/mknod/mknod.8 index ebcc86f8e02ca..0c6d5c605e96f 100644 --- a/sbin/mknod/mknod.8 +++ b/sbin/mknod/mknod.8 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)mknod.8 8.2 (Berkeley) 12/11/93 +.\" $Id$ .\" .Dd December 11, 1993 .Dt MKNOD 8 @@ -49,13 +50,13 @@ command creates device special files. Normally the shell script .Pa /dev/MAKEDEV is used to create special files for commonly known devices; it executes -.Nm mknod +.Nm with the appropriate arguments and can make all the files required for the device. .Pp To make nodes manually, the four required arguments are: .Pp -.Bl -tag -width majorx +.Bl -tag -width indent .It Ar name Device name, for example .Dq sd diff --git a/sbin/modload/modload.8 b/sbin/modload/modload.8 index a56fad6724dbb..7e8dfb16a5d78 100644 --- a/sbin/modload/modload.8 +++ b/sbin/modload/modload.8 @@ -23,7 +23,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $Id: modload.8,v 1.10 1997/02/22 14:32:39 peter Exp $ +.\" $Id: modload.8,v 1.7.2.1 1997/03/03 07:01:31 mpp Exp $ .\" .Dd September 22, 1994 .Dt MODLOAD 8 @@ -114,10 +114,8 @@ The command was designed to be similar in functionality to the corresponding command in .Tn "SunOS 4.1.3" . -.Sh AUTHOR -.Bl -tag -Terrence R. Lambert, terry@cs.weber.edu -.El +.Sh AUTHORS +.An Terrence R. Lambert Aq terry@cs.weber.edu .Sh BUGS The loadable device driver framework can only reserve either a character or block device entry, not both. diff --git a/sbin/modunload/modunload.8 b/sbin/modunload/modunload.8 index cfeac8ebae364..889f17f48ef59 100644 --- a/sbin/modunload/modunload.8 +++ b/sbin/modunload/modunload.8 @@ -23,7 +23,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $Id: modunload.8,v 1.4 1995/10/26 21:44:11 torstenb Exp $ +.\" $Id: modunload.8,v 1.4.2.1 1996/12/14 13:57:47 joerg Exp $ .\" .Dd June 7, 1993 .Dt MODUNLOAD 8 @@ -70,7 +70,5 @@ The command was designed to be similar in functionality to the corresponding command in .Tn "SunOS 4.1.3" . -.Sh AUTHOR -.Bl -tag -Terrence R. Lambert, terry@cs.weber.edu -.El +.Sh AUTHORS +.An Terrence R. Lambert Aq terry@cs.weber.edu diff --git a/sbin/modunload/modunload.c b/sbin/modunload/modunload.c index b6ea0d9786e88..ab9a5752fd14b 100644 --- a/sbin/modunload/modunload.c +++ b/sbin/modunload/modunload.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: modunload.c,v 1.1.8.1 1996/12/14 13:57:48 joerg Exp $ + * $Id: modunload.c,v 1.1.8.2 1997/09/03 06:55:39 jkh Exp $ */ #include <stdio.h> @@ -98,7 +98,7 @@ main(argc, argv) /* * Open the virtual device device driver for exclusive use (needed - * to ioctl() to retrive the loaded module(s) status). + * to ioctl() to retrieve the loaded module(s) status). */ if ((devfd = open(_PATH_LKM, O_RDWR, 0)) == -1) err(2, _PATH_LKM); diff --git a/sbin/mount_cd9660/mount_cd9660.8 b/sbin/mount_cd9660/mount_cd9660.8 index d3dfdb47d9466..52b91cf2b870f 100644 --- a/sbin/mount_cd9660/mount_cd9660.8 +++ b/sbin/mount_cd9660/mount_cd9660.8 @@ -48,7 +48,7 @@ .Ar special | node .Sh DESCRIPTION The -.Nm mount_cd9660 +.Nm command attaches the ISO-9660 filesystem residing on the device .Pa special to the global filesystem namespace at the location indicated by @@ -113,6 +113,6 @@ the one with the highest. There is no ECMA support. .Sh HISTORY The -.Nm mount_cd9660 +.Nm utility first appeared .Bx 4.4 . diff --git a/sbin/mount_ext2fs/mount_ext2fs.8 b/sbin/mount_ext2fs/mount_ext2fs.8 index 01bce0a113b72..9441c8bcd2e03 100644 --- a/sbin/mount_ext2fs/mount_ext2fs.8 +++ b/sbin/mount_ext2fs/mount_ext2fs.8 @@ -29,8 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" +.\" $Id$ .\" -.Dd "January 31, 1996" +.Dd January 31, 1996 .Dt MOUNT_EXT2FS 8 .Os FreeBSD 2.2 .Sh NAME @@ -43,7 +44,7 @@ .Ar node .Sh DESCRIPTION The -.Nm mount_ext2fs +.Nm command attaches a ext2fs file system .Ar special device on to the file system tree at the point @@ -54,7 +55,7 @@ This command is normally executed by at boot time. .Pp The options are as follows: -.Bl -tag -width Ds +.Bl -tag -width indent .It Fl o Options are specified with a .Fl o @@ -70,6 +71,6 @@ man page for possible options and their meanings. .Xr mount 8 .Sh HISTORY The -.Nm mount_ext2fs +.Nm function first appeared in .Fx 2.2 . diff --git a/sbin/mount_lfs/Makefile b/sbin/mount_lfs/Makefile deleted file mode 100644 index 0020b8bfebad1..0000000000000 --- a/sbin/mount_lfs/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# @(#)Makefile 8.2 (Berkeley) 3/27/94 - -PROG= mount_lfs -SRCS= mount_lfs.c getmntopts.c -MAN8= mount_lfs.8 - -MOUNT= ${.CURDIR}/../mount -CFLAGS+= -I${MOUNT} -.PATH: ${MOUNT} - -.include <bsd.prog.mk> diff --git a/sbin/mount_lfs/mount_lfs.8 b/sbin/mount_lfs/mount_lfs.8 deleted file mode 100644 index 11ccfe69f29e6..0000000000000 --- a/sbin/mount_lfs/mount_lfs.8 +++ /dev/null @@ -1,129 +0,0 @@ -.\" Copyright (c) 1993, 1994 -.\" 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. -.\" -.\" @(#)mount_lfs.8 8.5 (Berkeley) 3/30/94 -.\" -.Dd "March 30, 1994" -.Dt MOUNT_LFS 8 -.Os BSD 4.4 -.Sh NAME -.Nm mount_lfs -.Nd mount a log-structured file system -.Sh SYNOPSIS -.Nm mount_lfs -.Op Fl dns -.Op Fl o Ar options -.Ar special -.Ar node -.Sh DESCRIPTION -The -.Nm mount_lfs -command attaches a log-structured file system -.Ar special -device on to the file system tree at the point -.Ar node . -In addition, the -.Xr lfs_cleanerd 8 -utility is invoked to clean the file system periodically. -.Pp -This command is normally executed by -.Xr mount 8 -at boot time. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl d -Run -.Xr lfs_cleanerd 8 -in debug mode. -.It Fl o -Options are specified with a -.Fl o -flag followed by a comma separated string of options. -See the -.Xr mount 8 -man page for possible options and their meanings. -.It Fl n -Don't start -.Xr lfs_cleanerd 8 -on the file system. -.It Fl s -Cause -.Xr lfs_cleanerd 8 -to read data in small chunks when cleaning the file system. -.El -.Sh SEE ALSO -.Xr mount 2 , -.Xr unmount 2 , -.Xr fstab 5 , -.Xr lfs_cleanerd 8 , -.Xr mount 8 -.sp -.Rs -.%A Ousterhout and Douglis -.%D 1989 -.%T "Beating the I/O Bottleneck: A Case for Log-structured File Systems" -.%J "Operating Systems Review" -.%V Vol. 23 -.%N No. 1 -.%P pp. 11-27 -.%O "also available as Technical Report UCB/CSD 88/467" -.Re -.Rs -.%A Rosenblum and Ousterhout -.%D 1991 -.%T "The Design and Implementation of a Log-Structured File System" -.%J "ACM SIGOPS Operating Systems Review" -.%V Vol. 25 -.%N No. 5 -.Re -.Rs -.%A Seltzer -.%D 1992 -.%T "File System Performance and Transaction Support" -.%B "PhD Thesis, University of California, Berkeley" -.%O "also available as Technical Report UCB/ERL M92" -.Re -.Rs -.%A Seltzer, Bostic, McKusick and Staelin -.%D 1993 -.%T "An Implementation of a Log-Structured File System for UNIX" -.%J "Proc. of the Winter 1993 USENIX Conf." -.%P pp. 315-331 -.Re -.Sh BUGS -LFS does not currently work in any variant of FreeBSD and should therefore -not be used. -.Sh HISTORY -The -.Nm mount_lfs -function first appeared in -.Bx 4.4 . diff --git a/sbin/mount_lfs/mount_lfs.c b/sbin/mount_lfs/mount_lfs.c deleted file mode 100644 index 86d4efe222d33..0000000000000 --- a/sbin/mount_lfs/mount_lfs.c +++ /dev/null @@ -1,165 +0,0 @@ -/*- - * Copyright (c) 1993, 1994 - * 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 -static char copyright[] = -"@(#) Copyright (c) 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -/* -static char sccsid[] = "@(#)mount_lfs.c 8.3 (Berkeley) 3/27/94"; -*/ -static const char rcsid[] = - "$Id: mount_lfs.c,v 1.5 1996/09/14 02:58:07 bde Exp $"; -#endif /* not lint */ - -#include <sys/param.h> -#include <sys/mount.h> - -#include <err.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sysexits.h> -#include <unistd.h> - -#include "mntopts.h" -#include "pathnames.h" - -static struct mntopt mopts[] = { - MOPT_STDOPTS, - MOPT_UPDATE, - { NULL } -}; - -static void usage __P((void)) __dead2; -static void invoke_cleaner __P((char *, int, int)); - -int -main(argc, argv) - int argc; - char *argv[]; -{ - struct ufs_args args; - int ch, mntflags, noclean; - char *fs_name, *options; - struct vfsconf *vfc; - int short_rds, cleaner_debug; - - - options = NULL; - mntflags = noclean = short_rds = cleaner_debug = 0; - while ((ch = getopt(argc, argv, "dno:s")) != -1) - switch (ch) { - case 'd': - cleaner_debug = 1; - break; - case 'n': - noclean = 1; - break; - case 'o': - getmntopts(optarg, mopts, &mntflags, 0); - break; - case 's': - short_rds = 1; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (argc != 2) - usage(); - - args.fspec = argv[0]; /* the name of the device file */ - fs_name = argv[1]; /* the mount point */ - -#define DEFAULT_ROOTUID -2 - args.export.ex_root = DEFAULT_ROOTUID; - if (mntflags & MNT_RDONLY) - args.export.ex_flags = MNT_EXRDONLY; - else - args.export.ex_flags = 0; - - vfc = getvfsbyname("lfs"); - if(!vfc && vfsisloadable("lfs")) { - if(vfsload("lfs")) - err(EX_OSERR, "vfsload(lfs)"); - endvfsent(); /* flush cache */ - vfc = getvfsbyname("lfs"); - } - if (!vfc) - errx(EX_OSERR, "lfs filesystem is not available"); - - if (mount(vfc ? vfc->vfc_index : MOUNT_LFS, fs_name, mntflags, &args)) - err(EX_OSERR, args.fspec); - - if (!noclean) - invoke_cleaner(fs_name, short_rds, cleaner_debug); - /* NOTREACHED */ - - exit(0); -} - -static void -invoke_cleaner(name, short_rds, cleaner_debug) - char *name; - int short_rds; - int cleaner_debug; -{ - char *args[6], **ap = args; - - /* Build the argument list. */ - *ap++ = _PATH_LFS_CLEANERD; - if (short_rds) - *ap++ = "-s"; - if (cleaner_debug) - *ap++ = "-d"; - *ap++ = name; - *ap = NULL; - - execv(args[0], args); - err(EX_OSERR, "exec %s", _PATH_LFS_CLEANERD); -} - -static void -usage() -{ - (void)fprintf(stderr, - "usage: mount_lfs [-dns] [-o options] special node\n"); - exit(EX_USAGE); -} diff --git a/sbin/mount_lfs/pathnames.h b/sbin/mount_lfs/pathnames.h deleted file mode 100644 index fafbf714db527..0000000000000 --- a/sbin/mount_lfs/pathnames.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 1993 - * 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. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/8/93 - */ - -#define _PATH_LFS_CLEANERD "/usr/libexec/lfs_cleanerd" diff --git a/sbin/mount_portal/activate.c b/sbin/mount_portal/activate.c index 33617988f7dfb..3ee9a0e27bc16 100644 --- a/sbin/mount_portal/activate.c +++ b/sbin/mount_portal/activate.c @@ -36,7 +36,7 @@ * * @(#)activate.c 8.2 (Berkeley) 3/27/94 * - * $Id: activate.c,v 1.2 1992/05/27 07:09:27 jsp Exp jsp $ + * $Id: activate.c,v 1.1.1.1 1994/05/26 06:34:32 rgrimes Exp $ */ #include <stdio.h> @@ -89,7 +89,7 @@ int klen; iov[1].iov_base = key; iov[1].iov_len = klen; - bzero((char *) &msg, sizeof(msg)); + memset(&msg, 0, sizeof(msg)); msg.msg_iov = iov; msg.msg_iovlen = 2; @@ -129,7 +129,7 @@ int error; /* * Build a msghdr */ - bzero((char *) &msg, sizeof(msg)); + memset(&msg, 0, sizeof(msg)); msg.msg_iov = &iov; msg.msg_iovlen = 1; diff --git a/sbin/mount_portal/mount_portal.8 b/sbin/mount_portal/mount_portal.8 index 5c1f17746dc66..ed9434e557fe0 100644 --- a/sbin/mount_portal/mount_portal.8 +++ b/sbin/mount_portal/mount_portal.8 @@ -35,7 +35,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)mount_portal.8 8.3 (Berkeley) 3/27/94 -.\" +.\" $Id$ .\" .Dd March 27, 1994 .Dt MOUNT_PORTAL 8 @@ -50,12 +50,12 @@ .Ar mount_point .Sh DESCRIPTION The -.Nm mount_portal +.Nm command attaches an instance of the portal daemon to the global filesystem namespace. The conventional mount point is .Pa /p . -.PA /dev . +.\" .PA /dev . This command is normally executed by .Xr mount 8 at boot time. @@ -132,6 +132,6 @@ fs/ file fs/ This filesystem may not be NFS-exported. .Sh HISTORY The -.Nm mount_portal +.Nm utility first appeared in .Bx 4.4 . diff --git a/sbin/mount_std/mount_std.8 b/sbin/mount_std/mount_std.8 index e4acd6c3f1a74..b9694d9ac417d 100644 --- a/sbin/mount_std/mount_std.8 +++ b/sbin/mount_std/mount_std.8 @@ -34,7 +34,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: mount_std.8,v 1.5 1996/12/23 23:09:46 wosch Exp $ +.\" $Id: mount_std.8,v 1.3.2.2 1997/01/02 17:48:06 mpp Exp $ .\" .Dd May 13, 1996 .Dt MOUNT_STD 8 @@ -126,12 +126,11 @@ and .Sh DIAGNOSTICS .Bl -diag .It argv[0] must end in _fsname -The -.Nm mount_std -command was called with a zero'th argument of +.Nm Mount_std +was called with a zeroth argument of .Dq Li mount_std . .It vfsload(%s) -.Nm +.Nm Mount_std was unable to load a kernel module implementing the %s filesystem type. .It %s filesystem not available diff --git a/sbin/mountd/mountd.8 b/sbin/mountd/mountd.8 index fb4ca6f234189..f42399ae5dbb5 100644 --- a/sbin/mountd/mountd.8 +++ b/sbin/mountd/mountd.8 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)mountd.8 8.4 (Berkeley) 4/28/95 -.\" $Id: mountd.8,v 1.5.2.2 1997/04/09 20:31:32 guido Exp $ +.\" $Id: mountd.8,v 1.5.2.3 1997/05/14 08:19:20 dfr Exp $ .\" .Dd April 28, 1995 .Dt MOUNTD 8 @@ -41,16 +41,15 @@ .Tn NFS mount requests .Sh SYNOPSIS -.Nm /sbin/mountd -.Op Fl 2nr +.Nm mountd +.Op Fl 2dlnr .Op Ar exportsfile .Sh DESCRIPTION -.Xr Mountd +.Nm Mountd is the server for .Tn NFS mount requests from other client machines. -.Xr Mountd -listens for service requests at the port indicated in the +It listens for service requests at the port indicated in the .Tn NFS server specification; see .%T "Network File System Protocol Specification" , @@ -58,26 +57,27 @@ RFC1094, Appendix A and .%T "NFS: Network File System Version 3 Protocol Specification" , Appendix I. .Pp -Options and operands available for -.Nm mountd : -.Bl -tag -width Ds +The following options are available: +.Bl -tag -width indent .It Fl 2 -The -.Fl 2 -option allows the administrator to force clients to use only the -version 2 NFS protocol to mount filesystems from this server. +Allow the administrator to force clients to use only the +version 2 +.Tn NFS +protocol to mount filesystems from this server. +.It Fl d +Output debugging information. +.It Fl l +Cause all succeeded +.Nm +requests to be logged. .It Fl n -The -.Fl n -option allows non-root mount requests to be served. +Allow non-root mount requests to be served. This should only be specified if there are clients such as PC's, that require it. It will automatically clear the vfs.nfs.nfs_privport sysctl flag, which -controls if the kernel will accept nfs requests form reserved ports only. +controls if the kernel will accept NFS requests form reserved ports only. .It Fl r -The -.Fl r -option allows mount RPCs requests for regular files to be served. +Allow mount RPCs requests for regular files to be served. Although this seems to violate the mount protocol specification, some diskless workstations do mount requests for their swapfiles and expect them to be regular files. @@ -88,25 +88,29 @@ will have to be exported with the .Fl alldirs flag. .It Ar exportsfile -The -.Ar exportsfile -argument specifies an alternate location +Specify an alternate location for the exports file. .El .Pp -When mountd is started, +When +.Nm +is started, it loads the export host addresses and options into the kernel using the mount(2) system call. After changing the exports file, -a hangup signal should be sent to the mountd daemon +a hangup signal should be sent to the +.Nm +daemon to get it to reload the export information. After sending the SIGHUP -(kill -HUP `cat /var/run/mountd.pid`), -check the syslog output to see if mountd logged any parsing +(kill \-s HUP `cat /var/run/mountd.pid`), +check the syslog output to see if +.Nm +logged any parsing errors in the exports file. .Pp If -.Nm mountd +.Nm detects that the running kernel does not include .Tn NFS support, it will attempt to load a loadable kernel module containing @@ -118,7 +122,7 @@ by way of If this fails, or no .Tn NFS LKM was available, -.Nm mountd +.Nm exits with an error. .Sh FILES .Bl -tag -width /var/run/mountd.pid -compact @@ -138,6 +142,6 @@ the current list of remote mounted filesystems .Xr showmount 8 .Sh HISTORY The -.Nm mountd +.Nm utility first appeared in .Bx 4.4 . diff --git a/sbin/mountd/netgroup.5 b/sbin/mountd/netgroup.5 index 5560d19cde43d..83cc9c72c1fba 100644 --- a/sbin/mountd/netgroup.5 +++ b/sbin/mountd/netgroup.5 @@ -41,7 +41,7 @@ .Nm netgroup .Sh DESCRIPTION The -.Nm netgroup +.Nm file specifies ``netgroups'', which are sets of .Sy (host, user, domain) @@ -55,6 +55,7 @@ of a tuple as follows: .Bd -literal -offset indent (host, user, domain) .Ed +.Pp where the .Sy host , .Sy user , @@ -65,47 +66,60 @@ Any of the comma separated fields may be empty to specify a ``wildcard'' value or may consist of the string ``-'' to specify ``no valid value''. The members of the list may be separated by whitespace and/or commas; the ``\e'' character may be used at the end of a line to specify -line continuation. Lines in the database are restricted to 1024 characters. +line continuation. Lines are limited to 1024 characters. The functions specified in .Xr getnetgrent 3 should normally be used to access the -.Nm netgroup +.Nm database. .Pp Lines that begin with a # are treated as comments. .Sh NIS/YP INTERACTION On most other platforms, -.Nm netgroups +.Nm Ns s are only used in conjunction with -NIS and local +.Tn NIS +and local .Pa /etc/netgroup -files are ignored. With FreeBSD, -.Nm netgroups -can be used with either NIS or local files, but there are certain +files are ignored. With +.Bx Free , +.Nm Ns s +can be used with either +.Tn NIS +or local files, but there are certain caveats to consider. The existing -.Nm netgroup +.Nm system is extremely inefficient where .Fn innetgr 3 lookups are concerned since -.Nm netgroup -memberships are computed on the fly. By contrast, the NIS -.Nm netgroup +.Nm +memberships are computed on the fly. By contrast, the +.Tn NIS +.Nm database consists of three separate maps (netgroup, netgroup.byuser and netgroup.byhost) that are keyed to allow .Fn innetgr 3 -lookups to be done quickly. The FreeBSD -.Nm netgroup -system can interact with the NIS -.Nm netgroup +lookups to be done quickly. The +.Bx Free +.Nm +system can interact with the +.Tn NIS +.Nm maps in the following ways: .Bl -bullet -offset indent .It If the .Pa /etc/netgroup file does not exist, or it exists and is empty, or -it exists and contains only a '+', and NIS is running, -.Nm netgroup -lookups will be done exclusively through NIS, with +it exists and contains only a +.Sq + , +and +.Tn NIS +is running, +.Nm +lookups will be done exclusively through +.Tn NIS , +with .Fn innetgr 3 taking advantage of the netgroup.byuser and netgroup.byhost maps to speed up searches. (This @@ -115,18 +129,28 @@ similar platforms.) If the .Pa /etc/netgroup exists and contains only local -.Nm netgroup -information (with no NIS '+' token), then only the local -.Nm netgroup -information will be processed (and NIS will be ignored). +.Nm +information (with no +.Tn NIS +.Sq + +token), then only the local +.Nm +information will be processed (and +.Tn NIS +will be ignored). .It If .Pa /etc/netgroup exists and contains both local netgroup data .Pa and -the NIS '+' token, the local data and the NIS netgroup +the +.Tn NIS +.Sq + +token, the local data and the +.Tn NIS +netgroup map will be processed as a single combined -.Nm netgroup +.Nm database. While this configuration is the most flexible, it is also the least efficient: in particular, .Fn innetgr 3 @@ -136,7 +160,7 @@ database is large. .Sh FILES .Bl -tag -width /etc/netgroup -compact .It Pa /etc/netgroup -the netgroup database. +the netgroup database .El .Sh SEE ALSO .Xr getnetgrent 3 , @@ -148,10 +172,12 @@ appears that not all vendors use an identical format. The interpretation of access restrictions based on the member tuples of a netgroup is left up to the various network applications. Also, it is not obvious how the domain specification -applies to the BSD environment. +applies to the +.Bx +environment. .Pp The -.Nm netgroup +.Nm database should be stored in the form of a hashed .Xr db 3 diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8 index 4f2c4e9fdb922..147db97bab9cc 100644 --- a/sbin/newfs/newfs.8 +++ b/sbin/newfs/newfs.8 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)newfs.8 8.6 (Berkeley) 5/3/95 +.\" $Id$ .\" .Dd May 3, 1995 .Dt NEWFS 8 @@ -84,7 +85,7 @@ replaces the more obtuse .Xr mkfs 8 program. Before running -.Nm newfs +.Nm or .Nm mount_mfs , the disk must be labeled using @@ -92,7 +93,7 @@ the disk must be labeled using .Nm Newfs builds a file system on the specified special device. Typically the defaults are reasonable, however -.Nm newfs +.Nm has numerous options to allow the defaults to be selectively overridden. .Pp .Nm Mount_mfs @@ -110,7 +111,7 @@ corresponding file system. The parameters to .Nm mount_mfs are the same as those to -.Nm newfs . +.Nm Ns . If the .Fl T flag is specified (see below), the special file is unused. @@ -121,33 +122,35 @@ since that is where the file system will be backed up when free memory gets low and the memory supporting the file system has to be paged. .Pp -The following options define the general layout policies. -.Bl -tag -width Fl +The following options define the general layout policies: +.Bl -tag -width indent .It Fl T Ar disktype For backward compatibility and for .Nm mount_mfs . .It Fl F Ar file -.Nm mount_mfs +.Nm Mount_mfs will use this file for the image of the filesystem. When .Nm mount_mfs exits, this file will be left behind. .It Fl N -Causes the file system parameters to be printed out +Cause the file system parameters to be printed out without really creating the file system. .It Fl O -Creates a 4.3BSD format filesystem. +Create a +.Bx 4.3 +format filesystem. This options is primarily used to build root filesystems that can be understood by older boot ROMs. .It Fl T -Uses information for the specified disk from +Use information for the specified disk from .Pa /etc/disktab instead of trying to get the information from a disklabel. .It Fl a Ar maxcontig -This specifies the maximum number of contiguous blocks that will be +Specify the maximum number of contiguous blocks that will be laid out before forcing a rotational delay (see the .Fl d option). -The default value is one. +The default value is 1. See .Xr tunefs 8 for more details on how to set this option. @@ -157,7 +160,7 @@ The block size of the file system, in bytes. The number of cylinders per cylinder group in a file system. The default value is 16. .It Fl d Ar rotdelay -This specifies the expected time (in milliseconds) to service a transfer +Specify the expected time (in milliseconds) to service a transfer completion interrupt and initiate a new transfer on the same disk. The default is 0 milliseconds. See @@ -165,7 +168,7 @@ See for more details on how to set this option. .ne 1i .It Fl e Ar maxbpg -This indicates the maximum number of blocks any single file can +Indicate 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. The default is about one quarter of the total blocks in a cylinder group. @@ -176,7 +179,7 @@ for more details on how to set this option. The fragment size of the file system in bytes. The default is 1024 bytes. .It Fl i Ar number of bytes per inode -This specifies the density of inodes in the file system. +Specify the density of inodes in the file system. The default is to create an inode for every (4 * frag-size) bytes of data space. If fewer inodes are desired, a larger number should be used; to create more inodes a smaller number should be given. @@ -193,8 +196,9 @@ See .Xr tunefs 8 for more details on how to set this option. .It Fl n Ar number of distinguished rotational positions -Determines how many rotational time slots there are in one revolution of -the disk. Defaults to 1, which essentially disables the rotational position table. +Determine how many rotational time slots there are in one revolution of +the disk. Defaults to 1, which essentially disables the rotational position +table. .It Fl o Ar optimization\ preference .Pq ``space'' or ``time'' The file system can either be instructed to try to minimize the time spent @@ -213,15 +217,15 @@ The size of the file system in sectors. The following options override the standard sizes for the disk geometry. Their default values are taken from the disk label. Changing these defaults is useful only when using -.Nm newfs +.Nm to build a file system whose raw image will eventually be used on a different type of disk than the one on which it is initially created (for example on a write-once disk). Note that changing any of these values from their defaults will make it impossible for -.Xr fsck +.Xr fsck 8 to find the alternate superblocks if the standard superblock is lost. -.Bl -tag -width Fl +.Bl -tag -width indent .It Fl S Ar sector-size The size of a sector in bytes (almost never anything but 512). .It Fl k Ar sector \&0 skew , per track @@ -259,7 +263,7 @@ If zero is specified, the value from the disklabel will be used. This does not include sectors reserved at the end of each track for bad block replacement (see the .Fl p -option.) +option). .It Fl x Ar spare sectors per cylinder Spare sectors (bad sector replacements) are physical sectors that occupy space at the end of the last track in the cylinder. @@ -272,7 +276,7 @@ system for data allocation. The options to the .Nm mount_mfs command are as described for the -.Nm newfs +.Nm command, except for the .Fl o option. @@ -294,6 +298,12 @@ man page for possible options and their meanings. Mount a 64 MB large memory file system on /tmp, with .Xr mount 8 options nosuid and nodev. +.Sh BUGS +The boot code of +.Bx Free +assumes that the file system that carries the +kernel has blocks of 8 kilobytes and fragments of 1 kilobyte. You will +not be able to boot from a file system that uses another size. .Sh SEE ALSO .Xr fdformat 1 , .Xr disktab 5 , diff --git a/sbin/newlfs/Makefile b/sbin/newlfs/Makefile deleted file mode 100644 index 2f6c03f4f5648..0000000000000 --- a/sbin/newlfs/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/18/93 - -PROG= newlfs -CFLAGS+=-I${.CURDIR}/../../sys/ufs/lfs -SRCS= dkcksum.c lfs.c lfs_cksum.c misc.c newfs.c -MAN8= newlfs.8 -.PATH: ${.CURDIR}/../../sys/ufs/lfs ${.CURDIR}/../disklabel - -.include <bsd.prog.mk> diff --git a/sbin/newlfs/config.h b/sbin/newlfs/config.h deleted file mode 100644 index 55fed691517fe..0000000000000 --- a/sbin/newlfs/config.h +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * 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. - * - * @(#)config.h 8.2 (Berkeley) 4/22/94 - */ - -/* - * The first boot and super blocks are given in absolute disk addresses. - * The byte-offset forms are preferred, as they don't imply a sector size. - */ -#define BBSIZE 8192 -#define SBSIZE 8192 - -/* - * The following two constants set the default block and fragment sizes. - * Both constants must be a power of 2 and meet the following constraints: - * MINBSIZE <= DESBLKSIZE <= MAXBSIZE - * sectorsize <= DESFRAGSIZE <= DESBLKSIZE - * DESBLKSIZE / DESFRAGSIZE <= 8 - */ -#define DFL_FRAGSIZE 1024 -#define DFL_BLKSIZE 8192 - -/* - * Cylinder groups may have up to many cylinders. The actual - * number used depends upon how much information can be stored - * on a single cylinder. The default is to use 16 cylinders - * per group. - */ -#define DESCPG 16 /* desired fs_cpg */ - -/* - * MINFREE gives the minimum acceptable percentage of file system - * blocks which may be free. If the freelist drops below this level - * only the superuser may continue to allocate blocks. This may - * be set to 0 if no reserve of free blocks is deemed necessary, - * however throughput drops by fifty percent if the file system - * is run at between 90% and 100% full; thus the default value of - * fs_minfree is 10%. With 10% free space, fragmentation is not a - * problem, so we choose to optimize for time. - */ -#define MINFREE 10 -#define DEFAULTOPT FS_OPTTIME - -/* - * Preference for optimization. - */ -#define FS_OPTTIME 0 /* minimize allocation time */ -#define FS_OPTSPACE 1 /* minimize disk fragmentation */ - - -/* - * ROTDELAY gives the minimum number of milliseconds to initiate - * another disk transfer on the same cylinder. It is used in - * determining the rotationally optimal layout for disk blocks - * within a file; the default of fs_rotdelay is 4ms. - */ -#define ROTDELAY 0 - -/* - * MAXCONTIG sets the default for the maximum number of blocks - * that may be allocated sequentially. Since UNIX drivers are - * not capable of scheduling multi-block transfers, this defaults - * to 1 (ie no contiguous blocks are allocated). - */ -#define MAXCONTIG 1 - -/* - * MAXBLKPG determines the maximum number of data blocks which are - * placed in a single cylinder group. The default is one indirect - * block worth of data blocks. - */ -#define MAXBLKPG(bsize) ((bsize) / sizeof(daddr_t)) - -/* - * Each file system has a number of inodes statically allocated. - * We allocate one inode slot per NFPI fragments, expecting this - * to be far more than we will ever need. - */ -#define NFPI 4 - -/* - * For each cylinder we keep track of the availability of blocks at different - * rotational positions, so that we can lay out the data to be picked - * up with minimum rotational latency. NRPOS is the default number of - * rotational positions that we distinguish. With NRPOS of 8 the resolution - * of our summary information is 2ms for a typical 3600 rpm drive. - */ -#define NRPOS 1 /* number distinct rotational positions */ - -/* - * The following constants set the default block and segment size for a log - * structured file system. Both must be powers of two and the segment size - * must be a multiple of the block size. We also set minimum block and segment - * sizes. - */ -#define LFS_MINSEGSIZE (64*1024) -#define DFL_LFSSEG (1024 * 1024) -#define DFL_LFSSEG_SHIFT 20 -#define DFL_LFSSEG_MASK 0xFFFFF - -#define LFS_MINBLOCKSIZE 1024 -#define DFL_LFSBLOCK 8192 -#define DFL_LFSBLOCK_SHIFT 13 -#define DFL_LFSBLOCK_MASK 0x1FFF diff --git a/sbin/newlfs/extern.h b/sbin/newlfs/extern.h deleted file mode 100644 index c65cdba305899..0000000000000 --- a/sbin/newlfs/extern.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * 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. - * - * @(#)extern.h 8.1 (Berkeley) 6/5/93 - */ - -u_long cksum __P((void *, size_t)); -u_short dkcksum __P((struct disklabel *)); -void fatal __P((const char *fmt, ...)); -u_int log2 __P((u_int)); -int make_lfs - __P((int, struct disklabel *, struct partition *, int, int, int)); -int mkfs __P((struct partition *, char *, int, int)); - -extern char *progname; -extern char *special; diff --git a/sbin/newlfs/lfs.c b/sbin/newlfs/lfs.c deleted file mode 100644 index c22f19ffd04bf..0000000000000 --- a/sbin/newlfs/lfs.c +++ /dev/null @@ -1,673 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * 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 -static char sccsid[] = "@(#)lfs.c 8.1 (Berkeley) 6/5/93"; -#endif /* not lint */ - -#include <sys/param.h> -#include <sys/disklabel.h> -#include <sys/time.h> -#include <sys/mount.h> - -#include <ufs/ufs/dir.h> -#include <ufs/ufs/quota.h> -#include <ufs/ufs/dinode.h> -#include <ufs/lfs/lfs.h> - -#include <unistd.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include "config.h" -#include "extern.h" - -/* - * This table is indexed by the log base 2 of the block size. - * It returns the maximum file size allowed in a file system - * with the specified block size. For block sizes smaller than - * 8K, the size is limited by tha maximum number of blocks that - * can be reached by triply indirect blocks: - * NDADDR + INOPB(bsize) + INOPB(bsize)^2 + INOPB(bsize)^3 - * For block size of 8K or larger, the file size is limited by the - * number of blocks that can be represented in the file system. Since - * we use negative block numbers to represent indirect blocks, we can - * have a maximum of 2^31 blocks. - */ - -u_quad_t maxtable[] = { - /* 1 */ -1, - /* 2 */ -1, - /* 4 */ -1, - /* 8 */ -1, - /* 16 */ -1, - /* 32 */ -1, - /* 64 */ -1, - /* 128 */ -1, - /* 256 */ -1, - /* 512 */ NDADDR + 128 + 128 * 128 + 128 * 128 * 128, - /* 1024 */ NDADDR + 256 + 256 * 256 + 256 * 256 * 256, - /* 2048 */ NDADDR + 512 + 512 * 512 + 512 * 512 * 512, - /* 4096 */ NDADDR + 1024 + 1024 * 1024 + 1024 * 1024 * 1024, - /* 8192 */ 1 << 31, - /* 16 K */ 1 << 31, - /* 32 K */ 1 << 31, -}; - -static struct lfs lfs_default = { - /* lfs_magic */ LFS_MAGIC, - /* lfs_version */ LFS_VERSION, - /* lfs_size */ 0, - /* lfs_ssize */ DFL_LFSSEG/DFL_LFSBLOCK, - /* lfs_dsize */ 0, - /* lfs_bsize */ DFL_LFSBLOCK, - /* lfs_fsize */ DFL_LFSBLOCK, - /* lfs_frag */ 1, - /* lfs_free */ LFS_FIRST_INUM, - /* lfs_bfree */ 0, - /* lfs_nfiles */ 0, - /* lfs_avail */ 0, - /* lfs_uinodes */ 0, - /* lfs_idaddr */ 0, - /* lfs_ifile */ LFS_IFILE_INUM, - /* lfs_lastseg */ 0, - /* lfs_nextseg */ 0, - /* lfs_curseg */ 0, - /* lfs_offset */ 0, - /* lfs_lastpseg */ 0, - /* lfs_tstamp */ 0, - /* lfs_maxsymlinklen */ MAXSYMLINKLEN, - /* lfs_minfree */ MINFREE, - /* lfs_maxfilesize */ 0, - /* lfs_dbpseg */ DFL_LFSSEG/DEV_BSIZE, - /* lfs_inopb */ DFL_LFSBLOCK/sizeof(struct dinode), - /* lfs_ifpb */ DFL_LFSBLOCK/sizeof(IFILE), - /* lfs_sepb */ DFL_LFSBLOCK/sizeof(SEGUSE), - /* lfs_nindir */ DFL_LFSBLOCK/sizeof(daddr_t), - /* lfs_nseg */ 0, - /* lfs_nspf */ 0, - /* lfs_cleansz */ 0, - /* lfs_segtabsz */ 0, - /* lfs_segmask */ DFL_LFSSEG_MASK, - /* lfs_segshift */ DFL_LFSSEG_SHIFT, - /* lfs_bmask */ DFL_LFSBLOCK_MASK, - /* lfs_bshift */ DFL_LFSBLOCK_SHIFT, - /* lfs_ffmask */ 0, - /* lfs_ffshift */ 0, - /* lfs_fbmask */ 0, - /* lfs_fbshift */ 0, - /* lfs_fsbtodb */ 0, - /* lfs_sushift */ 0, - /* lfs_sboffs */ { 0 }, - /* lfs_sp */ NULL, - /* lfs_ivnode */ NULL, - /* lfs_seglock */ 0, - /* lfs_lockpid */ 0, - /* lfs_iocount */ 0, - /* lfs_writer */ 0, - /* lfs_dirops */ 0, - /* lfs_doifile */ 0, - /* lfs_nactive */ 0, - /* lfs_fmod */ 0, - /* lfs_clean */ 0, - /* lfs_ronly */ 0, - /* lfs_flags */ 0, - /* lfs_fsmnt */ { 0 }, - /* lfs_pad */ { 0 }, - /* lfs_pad2 */ { 0 }, - /* lfs_cksum */ 0 -}; - - -struct direct lfs_root_dir[] = { - { ROOTINO, sizeof(struct direct), DT_DIR, 1, "."}, - { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".."}, - { LFS_IFILE_INUM, sizeof(struct direct), DT_REG, 5, "ifile"}, - { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 10, "lost+found"}, -}; - -struct direct lfs_lf_dir[] = { - { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 1, "." }, - { ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, -}; - -static daddr_t make_dinode - __P((ino_t, struct dinode *, int, daddr_t, struct lfs *)); -static void make_dir __P(( void *, struct direct *, int)); -static void put __P((int, off_t, void *, size_t)); - -int -make_lfs(fd, lp, partp, minfree, bsize, seg_size) - int fd; - struct disklabel *lp; - struct partition *partp; - int minfree; - int bsize; - int seg_size; -{ - struct dinode *dip; /* Pointer to a disk inode */ - struct dinode *dpagep; /* Pointer to page of disk inodes */ - CLEANERINFO *cleaninfo; /* Segment cleaner information table */ - FINFO file_info; /* File info structure in summary blocks */ - IFILE *ifile; /* Pointer to array of ifile structures */ - IFILE *ip; /* Pointer to array of ifile structures */ - struct lfs *lfsp; /* Superblock */ - SEGUSE *segp; /* Segment usage table */ - SEGUSE *segtable; /* Segment usage table */ - SEGSUM summary; /* Segment summary structure */ - SEGSUM *sp; /* Segment summary pointer */ - daddr_t last_sb_addr; /* Address of superblocks */ - daddr_t last_addr; /* Previous segment address */ - daddr_t sb_addr; /* Address of superblocks */ - daddr_t seg_addr; /* Address of current segment */ - void *ipagep; /* Pointer to the page we use to write stuff */ - void *sump; /* Used to copy stuff into segment buffer */ - u_long *block_array; /* Array of logical block nos to put in sum */ - u_long blocks_used; /* Number of blocks in first segment */ - u_long *dp; /* Used to computed checksum on data */ - u_long *datasump; /* Used to computed checksum on data */ - int block_array_size; /* How many entries in block array */ - int db_per_fb; /* Disk blocks per file block */ - int i, j; - int off; /* Offset at which to write */ - int sb_interval; /* number of segs between super blocks */ - int seg_seek; /* Seek offset for a segment */ - int ssize; /* Segment size */ - int sum_size; /* Size of the summary block */ - - lfsp = &lfs_default; - - if (!(ssize = seg_size)) - ssize = DFL_LFSSEG; - - /* Modify parts of superblock overridden by command line arguments */ - if (bsize != DFL_LFSBLOCK) { - lfsp->lfs_bshift = log2(bsize); - if (1 << lfsp->lfs_bshift != bsize) - fatal("%d: block size not a power of 2", bsize); - lfsp->lfs_bsize = bsize; - lfsp->lfs_fsize = bsize; - lfsp->lfs_bmask = bsize - 1; - lfsp->lfs_inopb = bsize / sizeof(struct dinode); - -/* MIS -- should I round to power of 2 */ - lfsp->lfs_ifpb = bsize / sizeof(IFILE); - lfsp->lfs_sepb = bsize / sizeof(SEGUSE); - lfsp->lfs_nindir = bsize / sizeof(daddr_t); - } - - if (ssize != DFL_LFSSEG) { - lfsp->lfs_segshift = log2(ssize); - if (1 << lfsp->lfs_segshift != ssize) - fatal("%d: segment size not power of 2", ssize); - lfsp->lfs_ssize = ssize; - lfsp->lfs_segmask = ssize - 1; - lfsp->lfs_dbpseg = ssize / DEV_BSIZE; - } - lfsp->lfs_ssize = ssize >> lfsp->lfs_bshift; - - if (minfree) - lfsp->lfs_minfree = minfree; - - /* - * Fill in parts of superblock that can be computed from file system - * size, disk geometry and current time. - */ - db_per_fb = bsize/lp->d_secsize; - lfsp->lfs_fsbtodb = log2(db_per_fb); - lfsp->lfs_sushift = log2(lfsp->lfs_sepb); - lfsp->lfs_size = partp->p_size >> lfsp->lfs_fsbtodb; - lfsp->lfs_dsize = lfsp->lfs_size - (LFS_LABELPAD >> lfsp->lfs_bshift); - lfsp->lfs_nseg = lfsp->lfs_dsize / lfsp->lfs_ssize; - lfsp->lfs_maxfilesize = maxtable[lfsp->lfs_bshift] << lfsp->lfs_bshift; - - /* - * The number of free blocks is set from the number of segments times - * the segment size - 2 (that we never write because we need to make - * sure the cleaner can run). Then we'll subtract off the room for the - * superblocks ifile entries and segment usage table. - */ - lfsp->lfs_dsize = fsbtodb(lfsp, (lfsp->lfs_nseg - 2) * lfsp->lfs_ssize); - lfsp->lfs_bfree = lfsp->lfs_dsize; - lfsp->lfs_segtabsz = SEGTABSIZE_SU(lfsp); - lfsp->lfs_cleansz = CLEANSIZE_SU(lfsp); - if ((lfsp->lfs_tstamp = time(NULL)) == -1) - fatal("time: %s", strerror(errno)); - if ((sb_interval = lfsp->lfs_nseg / LFS_MAXNUMSB) < LFS_MIN_SBINTERVAL) - sb_interval = LFS_MIN_SBINTERVAL; - - /* - * Now, lay out the file system. We need to figure out where - * the superblocks go, initialize the checkpoint information - * for the first two superblocks, initialize the segment usage - * information, put the segusage information in the ifile, create - * the first block of IFILE structures, and link all the IFILE - * structures into a free list. - */ - - /* Figure out where the superblocks are going to live */ - lfsp->lfs_sboffs[0] = LFS_LABELPAD/lp->d_secsize; - for (i = 1; i < LFS_MAXNUMSB; i++) { - sb_addr = ((i * sb_interval) << - (lfsp->lfs_segshift - lfsp->lfs_bshift + lfsp->lfs_fsbtodb)) - + lfsp->lfs_sboffs[0]; - if (sb_addr > partp->p_size) - break; - lfsp->lfs_sboffs[i] = sb_addr; - } - last_sb_addr = lfsp->lfs_sboffs[i - 1]; - lfsp->lfs_lastseg = lfsp->lfs_sboffs[0]; - lfsp->lfs_nextseg = - lfsp->lfs_sboffs[1] ? lfsp->lfs_sboffs[1] : lfsp->lfs_sboffs[0]; - lfsp->lfs_curseg = lfsp->lfs_lastseg; - - /* - * Initialize the segment usage table. The first segment will - * contain the superblock, the cleanerinfo (cleansz), the segusage - * table * (segtabsz), 1 block's worth of IFILE entries, the root - * directory, the lost+found directory and one block's worth of - * inodes (containing the ifile, root, and l+f inodes). - */ - if (!(cleaninfo = malloc(lfsp->lfs_cleansz << lfsp->lfs_bshift))) - fatal("%s", strerror(errno)); - cleaninfo->clean = lfsp->lfs_nseg - 1; - cleaninfo->dirty = 1; - - if (!(segtable = malloc(lfsp->lfs_segtabsz << lfsp->lfs_bshift))) - fatal("%s", strerror(errno)); - segp = segtable; - blocks_used = lfsp->lfs_segtabsz + lfsp->lfs_cleansz + 4; - segp->su_nbytes = ((blocks_used - 1) << lfsp->lfs_bshift) + - 3 * sizeof(struct dinode) + LFS_SUMMARY_SIZE; - segp->su_lastmod = lfsp->lfs_tstamp; - segp->su_nsums = 1; /* 1 summary blocks */ - segp->su_ninos = 1; /* 1 inode block */ - segp->su_flags = SEGUSE_SUPERBLOCK | SEGUSE_DIRTY; - lfsp->lfs_bfree -= LFS_SUMMARY_SIZE / lp->d_secsize; - lfsp->lfs_bfree -= - fsbtodb(lfsp, lfsp->lfs_cleansz + lfsp->lfs_segtabsz + 4); - - /* - * Now figure out the address of the ifile inode. The inode block - * appears immediately after the segment summary. - */ - lfsp->lfs_idaddr = (LFS_LABELPAD + LFS_SBPAD + LFS_SUMMARY_SIZE) / - lp->d_secsize; - - for (segp = segtable + 1, i = 1; i < lfsp->lfs_nseg; i++, segp++) { - if ((i % sb_interval) == 0) { - segp->su_flags = SEGUSE_SUPERBLOCK; - lfsp->lfs_bfree -= (LFS_SBPAD / lp->d_secsize); - } else - segp->su_flags = 0; - segp->su_lastmod = 0; - segp->su_nbytes = 0; - segp->su_ninos = 0; - segp->su_nsums = 0; - } - - /* - * Initialize dynamic accounting. The blocks available for - * writing are the bfree blocks minus 1 segment summary for - * each segment since you can't write any new data without - * creating a segment summary - 2 segments that the cleaner - * needs. - */ - lfsp->lfs_avail = lfsp->lfs_bfree - lfsp->lfs_nseg - - fsbtodb(lfsp, 2 * lfsp->lfs_ssize); - lfsp->lfs_uinodes = 0; - /* - * Ready to start writing segments. The first segment is different - * because it contains the segment usage table and the ifile inode - * as well as a superblock. For the rest of the segments, set the - * time stamp to be 0 so that the first segment is the most recent. - * For each segment that is supposed to contain a copy of the super - * block, initialize its first few blocks and its segment summary - * to indicate this. - */ - lfsp->lfs_nfiles = LFS_FIRST_INUM - 1; - lfsp->lfs_cksum = - cksum(lfsp, sizeof(struct lfs) - sizeof(lfsp->lfs_cksum)); - - /* Now create a block of disk inodes */ - if (!(dpagep = malloc(lfsp->lfs_bsize))) - fatal("%s", strerror(errno)); - dip = (struct dinode *)dpagep; - bzero(dip, lfsp->lfs_bsize); - - /* Create a block of IFILE structures. */ - if (!(ipagep = malloc(lfsp->lfs_bsize))) - fatal("%s", strerror(errno)); - ifile = (IFILE *)ipagep; - - /* - * Initialize IFILE. It is the next block following the - * block of inodes (whose address has been calculated in - * lfsp->lfs_idaddr; - */ - sb_addr = lfsp->lfs_idaddr + lfsp->lfs_bsize / lp->d_secsize; - sb_addr = make_dinode(LFS_IFILE_INUM, dip, - lfsp->lfs_cleansz + lfsp->lfs_segtabsz+1, sb_addr, lfsp); - dip->di_mode = IFREG|IREAD|IWRITE; - ip = &ifile[LFS_IFILE_INUM]; - ip->if_version = 1; - ip->if_daddr = lfsp->lfs_idaddr; - - /* Initialize the ROOT Directory */ - sb_addr = make_dinode(ROOTINO, ++dip, 1, sb_addr, lfsp); - dip->di_mode = IFDIR|IREAD|IWRITE|IEXEC; - dip->di_size = DIRBLKSIZ; - dip->di_nlink = 3; - ip = &ifile[ROOTINO]; - ip->if_version = 1; - ip->if_daddr = lfsp->lfs_idaddr; - - /* Initialize the lost+found Directory */ - sb_addr = make_dinode(LOSTFOUNDINO, ++dip, 1, sb_addr, lfsp); - dip->di_mode = IFDIR|IREAD|IWRITE|IEXEC; - dip->di_size = DIRBLKSIZ; - dip->di_nlink = 2; - ip = &ifile[LOSTFOUNDINO]; - ip->if_version = 1; - ip->if_daddr = lfsp->lfs_idaddr; - - /* Make all the other dinodes invalid */ - for (i = INOPB(lfsp)-3, dip++; i; i--, dip++) - dip->di_inumber = LFS_UNUSED_INUM; - - - /* Link remaining IFILE entries in free list */ - for (ip = &ifile[LFS_FIRST_INUM], i = LFS_FIRST_INUM; - i < lfsp->lfs_ifpb; ++ip) { - ip->if_version = 1; - ip->if_daddr = LFS_UNUSED_DADDR; - ip->if_nextfree = ++i; - } - ifile[lfsp->lfs_ifpb - 1].if_nextfree = LFS_UNUSED_INUM; - - /* Now, write the segment */ - - /* Compute a checksum across all the data you're writing */ - dp = datasump = malloc (blocks_used * sizeof(u_long)); - *dp++ = ((u_long *)dpagep)[0]; /* inode block */ - for (i = 0; i < lfsp->lfs_cleansz; i++) - *dp++ = ((u_long *)cleaninfo)[(i << lfsp->lfs_bshift) / - sizeof(u_long)]; /* Cleaner info */ - for (i = 0; i < lfsp->lfs_segtabsz; i++) - *dp++ = ((u_long *)segtable)[(i << lfsp->lfs_bshift) / - sizeof(u_long)]; /* Segusage table */ - *dp++ = ((u_long *)ifile)[0]; /* Ifile */ - - /* Still need the root and l+f bytes; get them later */ - - /* Write out the inode block */ - off = LFS_LABELPAD + LFS_SBPAD + LFS_SUMMARY_SIZE; - put(fd, off, dpagep, lfsp->lfs_bsize); - free(dpagep); - off += lfsp->lfs_bsize; - - /* Write out the ifile */ - - put(fd, off, cleaninfo, lfsp->lfs_cleansz << lfsp->lfs_bshift); - off += (lfsp->lfs_cleansz << lfsp->lfs_bshift); - (void)free(cleaninfo); - - put(fd, off, segtable, lfsp->lfs_segtabsz << lfsp->lfs_bshift); - off += (lfsp->lfs_segtabsz << lfsp->lfs_bshift); - (void)free(segtable); - - put(fd, off, ifile, lfsp->lfs_bsize); - off += lfsp->lfs_bsize; - - /* - * use ipagep for space for writing out other stuff. It used to - * contain the ifile, but we're done with it. - */ - - /* Write out the root and lost and found directories */ - bzero(ipagep, lfsp->lfs_bsize); - make_dir(ipagep, lfs_root_dir, - sizeof(lfs_root_dir) / sizeof(struct direct)); - *dp++ = ((u_long *)ipagep)[0]; - put(fd, off, ipagep, lfsp->lfs_bsize); - off += lfsp->lfs_bsize; - - bzero(ipagep, lfsp->lfs_bsize); - make_dir(ipagep, lfs_lf_dir, - sizeof(lfs_lf_dir) / sizeof(struct direct)); - *dp++ = ((u_long *)ipagep)[0]; - put(fd, off, ipagep, lfsp->lfs_bsize); - - /* Write Supberblock */ - lfsp->lfs_offset = (off + lfsp->lfs_bsize) / lp->d_secsize; - put(fd, LFS_LABELPAD, lfsp, sizeof(struct lfs)); - - /* - * Finally, calculate all the fields for the summary structure - * and write it. - */ - - summary.ss_next = lfsp->lfs_nextseg; - summary.ss_create = lfsp->lfs_tstamp; - summary.ss_nfinfo = 3; - summary.ss_ninos = 3; - summary.ss_datasum = cksum(datasump, sizeof(u_long) * blocks_used); - - /* - * Make sure that we don't overflow a summary block. We have to - * record: FINFO structures for ifile, root, and l+f. The number - * of blocks recorded for the ifile is determined by the size of - * the cleaner info and the segments usage table. There is room - * for one block included in sizeof(FINFO) so we don't need to add - * any extra space for the ROOT and L+F, and one block of the ifile - * is already counted. Finally, we leave room for 1 inode block - * address. - */ - sum_size = 3*sizeof(FINFO) + sizeof(SEGSUM) + sizeof(daddr_t) + - (lfsp->lfs_cleansz + lfsp->lfs_segtabsz) * sizeof(u_long); -#define SUMERR \ -"Multiple summary blocks in segment 1 not yet implemented\nsummary is %d bytes." - if (sum_size > LFS_SUMMARY_SIZE) - fatal(SUMERR, sum_size); - - block_array_size = lfsp->lfs_cleansz + lfsp->lfs_segtabsz + 1; - - if (!(block_array = malloc(block_array_size *sizeof(int)))) - fatal("%s: %s", special, strerror(errno)); - - /* fill in the array */ - for (i = 0; i < block_array_size; i++) - block_array[i] = i; - - /* copy into segment */ - sump = ipagep; - bcopy(&summary, sump, sizeof(SEGSUM)); - sump += sizeof(SEGSUM); - - /* Now, add the ifile */ - file_info.fi_nblocks = block_array_size; - file_info.fi_version = 1; - file_info.fi_ino = LFS_IFILE_INUM; - - bcopy(&file_info, sump, sizeof(FINFO) - sizeof(u_long)); - sump += sizeof(FINFO) - sizeof(u_long); - bcopy(block_array, sump, sizeof(u_long) * file_info.fi_nblocks); - sump += sizeof(u_long) * file_info.fi_nblocks; - - /* Now, add the root directory */ - file_info.fi_nblocks = 1; - file_info.fi_version = 1; - file_info.fi_ino = ROOTINO; - file_info.fi_blocks[0] = 0; - bcopy(&file_info, sump, sizeof(FINFO)); - sump += sizeof(FINFO); - - /* Now, add the lost and found */ - file_info.fi_ino = LOSTFOUNDINO; - bcopy(&file_info, sump, sizeof(FINFO)); - - ((daddr_t *)ipagep)[LFS_SUMMARY_SIZE / sizeof(daddr_t) - 1] = - lfsp->lfs_idaddr; - ((SEGSUM *)ipagep)->ss_sumsum = cksum(ipagep+sizeof(summary.ss_sumsum), - LFS_SUMMARY_SIZE - sizeof(summary.ss_sumsum)); - put(fd, LFS_LABELPAD + LFS_SBPAD, ipagep, LFS_SUMMARY_SIZE); - - sp = (SEGSUM *)ipagep; - sp->ss_create = 0; - sp->ss_nfinfo = 0; - sp->ss_ninos = 0; - sp->ss_datasum = 0; - - /* Now write the summary block for the next partial so it's invalid */ - lfsp->lfs_tstamp = 0; - off += lfsp->lfs_bsize; - sp->ss_sumsum = - cksum(&sp->ss_datasum, LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum)); - put(fd, off, sp, LFS_SUMMARY_SIZE); - - /* Now, write rest of segments containing superblocks */ - lfsp->lfs_cksum = - cksum(lfsp, sizeof(struct lfs) - sizeof(lfsp->lfs_cksum)); - for (seg_addr = last_addr = lfsp->lfs_sboffs[0], j = 1, i = 1; - i < lfsp->lfs_nseg; i++) { - - seg_addr += lfsp->lfs_ssize << lfsp->lfs_fsbtodb; - sp->ss_next = last_addr; - last_addr = seg_addr; - seg_seek = seg_addr * lp->d_secsize; - - if (seg_addr == lfsp->lfs_sboffs[j]) { - if (j < (LFS_MAXNUMSB - 2)) - j++; - put(fd, seg_seek, lfsp, sizeof(struct lfs)); - seg_seek += LFS_SBPAD; - } - - /* Summary */ - sp->ss_sumsum = cksum(&sp->ss_datasum, - LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum)); - put(fd, seg_seek, sp, LFS_SUMMARY_SIZE); - } - free(ipagep); - close(fd); - return (0); -} - -static void -put(fd, off, p, len) - int fd; - off_t off; - void *p; - size_t len; -{ - int wbytes; - - if (lseek(fd, off, SEEK_SET) < 0) - fatal("%s: %s", special, strerror(errno)); - if ((wbytes = write(fd, p, len)) < 0) - fatal("%s: %s", special, strerror(errno)); - if (wbytes != len) - fatal("%s: short write (%d, not %d)", special, wbytes, len); -} - -/* - * Create the root directory for this file system and the lost+found - * directory. - */ - - u_long d_ino; /* inode number of entry */ - u_short d_reclen; /* length of this record */ - u_short d_namlen; /* length of string in d_name */ - char d_name[MAXNAMLEN + 1]; /* name with length <= MAXNAMLEN */ -void -lfsinit() -{} - -static daddr_t -make_dinode(ino, dip, nblocks, saddr, lfsp) - ino_t ino; /* inode we're creating */ - struct dinode *dip; /* disk inode */ - int nblocks; /* number of blocks in file */ - daddr_t saddr; /* starting block address */ - struct lfs *lfsp; /* superblock */ -{ - int db_per_fb, i; - - dip->di_nlink = 1; - dip->di_blocks = nblocks << lfsp->lfs_fsbtodb; - - dip->di_size = (nblocks << lfsp->lfs_bshift); - dip->di_atime.tv_sec = dip->di_mtime.tv_sec = - dip->di_ctime.tv_sec = lfsp->lfs_tstamp; - dip->di_atime.tv_nsec = dip->di_mtime.tv_nsec = - dip->di_ctime.tv_nsec = 0; - dip->di_inumber = ino; - -#define SEGERR \ -"File requires more than the number of direct blocks; increase block or segment size." - if (NDADDR < nblocks) - fatal("%s", SEGERR); - - /* Assign the block addresses for the ifile */ - db_per_fb = 1 << lfsp->lfs_fsbtodb; - for (i = 0; i < nblocks; i++, saddr += db_per_fb) - dip->di_db[i] = saddr; - - return (saddr); -} - - -/* - * Construct a set of directory entries in "bufp". We assume that all the - * entries in protodir fir in the first DIRBLKSIZ. - */ -static void -make_dir(bufp, protodir, entries) - void *bufp; - register struct direct *protodir; - int entries; -{ - char *cp; - int i, spcleft; - - spcleft = DIRBLKSIZ; - for (cp = bufp, i = 0; i < entries - 1; i++) { - protodir[i].d_reclen = DIRSIZ(NEWDIRFMT, &protodir[i]); - bcopy(&protodir[i], cp, protodir[i].d_reclen); - cp += protodir[i].d_reclen; - if ((spcleft -= protodir[i].d_reclen) < 0) - fatal("%s: %s", special, "directory too big"); - } - protodir[i].d_reclen = spcleft; - bcopy(&protodir[i], cp, DIRSIZ(NEWDIRFMT, &protodir[i])); -} diff --git a/sbin/newlfs/misc.c b/sbin/newlfs/misc.c deleted file mode 100644 index 074fb71e92468..0000000000000 --- a/sbin/newlfs/misc.c +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * 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 -static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/5/93"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/types.h> -#include <sys/disklabel.h> -#include <stdlib.h> -#include <stdio.h> -#include "extern.h" - -u_int -log2(num) - u_int num; -{ - register u_int i, limit; - - limit = 1; - for (i = 0; limit < num; limit = limit << 1, i++); - return (i); -} - -#if __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -void -#if __STDC__ -fatal(const char *fmt, ...) -#else -fatal(fmt, va_alist) - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "%s: ", progname); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - exit(1); - /* NOTREACHED */ -} diff --git a/sbin/newlfs/newfs.c b/sbin/newlfs/newfs.c deleted file mode 100644 index 2515b356f0907..0000000000000 --- a/sbin/newlfs/newfs.c +++ /dev/null @@ -1,483 +0,0 @@ -/*- - * Copyright (c) 1989, 1992, 1993 - * 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 -static char copyright[] = -"@(#) Copyright (c) 1989, 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)newfs.c 8.3 (Berkeley) 4/22/94"; -#endif /* not lint */ - -/* - * newfs: friendly front end to mkfs - */ -#include <sys/param.h> -#include <sys/ucred.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <sys/disklabel.h> -#include <sys/file.h> -#include <sys/mount.h> - -#include <ufs/ufs/dir.h> -#include <ufs/ufs/dinode.h> - -#include <errno.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <string.h> -#include <paths.h> -#include "config.h" -#include "extern.h" - -#define COMPAT /* allow non-labeled disks */ - -int mfs; /* run as the memory based filesystem */ -int Nflag; /* run without writing file system */ -int fssize; /* file system size */ -int ntracks; /* # tracks/cylinder */ -int nsectors; /* # sectors/track */ -int nphyssectors; /* # sectors/track including spares */ -int secpercyl; /* sectors per cylinder */ -int trackspares = -1; /* spare sectors per track */ -int cylspares = -1; /* spare sectors per cylinder */ -int sectorsize; /* bytes/sector */ -#ifdef tahoe -int realsectorsize; /* bytes/sector in hardware */ -#endif -int rpm; /* revolutions/minute of drive */ -int interleave; /* hardware sector interleave */ -int trackskew = -1; /* sector 0 skew, per track */ -int headswitch; /* head switch time, usec */ -int trackseek; /* track-to-track seek, usec */ -int fsize = 0; /* fragment size */ -int bsize = 0; /* block size */ -int cpg = DESCPG; /* cylinders/cylinder group */ -int cpgflg; /* cylinders/cylinder group flag was given */ -int minfree = MINFREE; /* free space threshold */ -int opt = DEFAULTOPT; /* optimization preference (space or time) */ -int density; /* number of bytes per inode */ -int maxcontig = MAXCONTIG; /* max contiguous blocks to allocate */ -int rotdelay = ROTDELAY; /* rotational delay between blocks */ -int maxbpg; /* maximum blocks per file in a cyl group */ -int nrpos = NRPOS; /* # of distinguished rotational positions */ -int bbsize = BBSIZE; /* boot block size */ -int sbsize = SBSIZE; /* superblock size */ -int mntflags; /* flags to be passed to mount */ -u_long memleft; /* virtual memory available */ -caddr_t membase; /* start address of memory based filesystem */ -#ifdef COMPAT -char *disktype; -int unlabeled; -#endif - -char device[MAXPATHLEN]; -char *progname, *special; - -static struct disklabel *getdisklabel __P((char *, int)); -static struct disklabel *debug_readlabel __P((int)); -static void rewritelabel __P((char *, int, struct disklabel *)); -static void usage __P((void)); - -int -main(argc, argv) - int argc; - char *argv[]; -{ - register int ch; - register struct partition *pp; - register struct disklabel *lp; - struct partition oldpartition; - struct stat st; - int debug, lfs, fsi, fso, segsize; - char *cp, *opstring; - - if (progname = rindex(*argv, '/')) - ++progname; - else - progname = *argv; - - if (strstr(progname, "mfs")) { - mfs = 1; - Nflag++; - } - - /* -F is mfs only and MUST come first! */ - opstring = "F:B:DLNS:T:a:b:c:d:e:f:i:k:l:m:n:o:p:r:s:t:u:x:"; - if (!mfs) - opstring += 2; - - debug = lfs = segsize = 0; - while ((ch = getopt(argc, argv, opstring)) != -1) - switch(ch) { - case 'B': /* LFS segment size */ - if ((segsize = atoi(optarg)) < LFS_MINSEGSIZE) - fatal("%s: bad segment size", optarg); - break; - case 'D': - debug = 1; - break; - case 'F': - if ((mntflags = atoi(optarg)) == 0) - fatal("%s: bad mount flags", optarg); - break; - case 'L': /* Create lfs */ - lfs = 1; - break; - case 'N': - Nflag++; - break; - case 'S': - if ((sectorsize = atoi(optarg)) <= 0) - fatal("%s: bad sector size", optarg); - break; -#ifdef COMPAT - case 'T': - disktype = optarg; - break; -#endif - case 'a': - if ((maxcontig = atoi(optarg)) <= 0) - fatal("%s: bad max contiguous blocks\n", - optarg); - break; - case 'b': /* used for LFS */ - if ((bsize = atoi(optarg)) < LFS_MINBLOCKSIZE) - fatal("%s: bad block size", optarg); - break; - case 'c': - if ((cpg = atoi(optarg)) <= 0) - fatal("%s: bad cylinders/group", optarg); - cpgflg++; - break; - case 'd': - if ((rotdelay = atoi(optarg)) < 0) - fatal("%s: bad rotational delay\n", optarg); - break; - case 'e': - if ((maxbpg = atoi(optarg)) <= 0) - fatal("%s: bad blocks per file in a cyl group\n", - optarg); - break; - case 'f': - if ((fsize = atoi(optarg)) <= 0) - fatal("%s: bad frag size", optarg); - break; - case 'i': - if ((density = atoi(optarg)) <= 0) - fatal("%s: bad bytes per inode\n", optarg); - break; - case 'k': - if ((trackskew = atoi(optarg)) < 0) - fatal("%s: bad track skew", optarg); - break; - case 'l': - if ((interleave = atoi(optarg)) <= 0) - fatal("%s: bad interleave", optarg); - break; - case 'm': /* used for LFS */ - if ((minfree = atoi(optarg)) < 0 || minfree > 99) - fatal("%s: bad free space %%\n", optarg); - break; - case 'n': - if ((nrpos = atoi(optarg)) <= 0) - fatal("%s: bad rotational layout count\n", - optarg); - break; - case 'o': - if (strcmp(optarg, "space") == 0) - opt = FS_OPTSPACE; - else if (strcmp(optarg, "time") == 0) - opt = FS_OPTTIME; - else - fatal("%s: bad optimization preference %s", - optarg, "(options are `space' or `time')"); - break; - case 'p': - if ((trackspares = atoi(optarg)) < 0) - fatal("%s: bad spare sectors per track", - optarg); - break; - case 'r': - if ((rpm = atoi(optarg)) <= 0) - fatal("%s: bad revs/minute\n", optarg); - break; - case 's': /* used for LFS */ - if ((fssize = atoi(optarg)) <= 0) - fatal("%s: bad file system size", optarg); - break; - case 't': - if ((ntracks = atoi(optarg)) <= 0) - fatal("%s: bad total tracks", optarg); - break; - case 'u': - if ((nsectors = atoi(optarg)) <= 0) - fatal("%s: bad sectors/track", optarg); - break; - case 'x': - if ((cylspares = atoi(optarg)) < 0) - fatal("%s: bad spare sectors per cylinder", - optarg); - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (argc != 2 && (mfs || argc != 1)) - usage(); - - /* - * If the -N flag isn't specified, open the output file. If no path - * prefix, try /dev/r%s and then /dev/%s. - */ - special = argv[0]; - if (index(special, '/') == NULL) { - (void)sprintf(device, "%sr%s", _PATH_DEV, special); - if (stat(device, &st) == -1) - (void)sprintf(device, "%s%s", _PATH_DEV, special); - special = device; - } - if (!Nflag) { - fso = open(special, - (debug ? O_CREAT : 0) | O_WRONLY, DEFFILEMODE); - if (fso < 0) - fatal("%s: %s", special, strerror(errno)); - } else - fso = -1; - - /* Open the input file. */ - fsi = open(special, O_RDONLY); - if (fsi < 0) - fatal("%s: %s", special, strerror(errno)); - if (fstat(fsi, &st) < 0) - fatal("%s: %s", special, strerror(errno)); - - if (!debug && !mfs && !S_ISCHR(st.st_mode)) - (void)printf("%s: %s: not a character-special device\n", - progname, special); - cp = index(argv[0], '\0') - 1; - if (!debug && (cp == 0 || (*cp < 'a' || *cp > 'h') && !isdigit(*cp))) - fatal("%s: can't figure out file system partition", argv[0]); - -#ifdef COMPAT - if (!mfs && disktype == NULL) - disktype = argv[1]; -#endif - if (debug) - lp = debug_readlabel(fsi); - else - lp = getdisklabel(special, fsi); - - if (isdigit(*cp)) - pp = &lp->d_partitions[0]; - else - pp = &lp->d_partitions[*cp - 'a']; - if (pp->p_size == 0) - fatal("%s: `%c' partition is unavailable", argv[0], *cp); - if (fsize == 0) { - fsize = pp->p_fsize; - if (fsize <= 0) - fsize = MAX(DFL_FRAGSIZE, lp->d_secsize); - } - - if (bsize == 0) { - bsize = pp->p_frag * fsize; - if (bsize <= 0) - bsize = MIN(DFL_LFSBLOCK, 8 * fsize); - } - - if (segsize == 0) { - segsize = pp->p_cpg * bsize; - if (segsize <= 0) - segsize = DFL_LFSSEG; - } - - /* If we're making a LFS, we break out here */ - exit(make_lfs(fso, lp, pp, minfree, bsize, segsize)); -} - -#ifdef COMPAT -char lmsg[] = "%s: can't read disk label; disk type must be specified"; -#else -char lmsg[] = "%s: can't read disk label"; -#endif - -static struct disklabel * -getdisklabel(s, fd) - char *s; - int fd; -{ - static struct disklabel lab; - - if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { -#ifdef COMPAT - if (disktype) { - struct disklabel *lp, *getdiskbyname(); - - unlabeled++; - lp = getdiskbyname(disktype); - if (lp == NULL) - fatal("%s: unknown disk type", disktype); - return (lp); - } -#endif - (void)fprintf(stderr, - "%s: ioctl (GDINFO): %s\n", progname, strerror(errno)); - fatal(lmsg, s); - } - return (&lab); -} - - -static struct disklabel * -debug_readlabel(fd) - int fd; -{ - static struct disklabel lab; - int n; - - if ((n = read(fd, &lab, sizeof(struct disklabel))) < 0) - fatal("unable to read disk label: %s", strerror(errno)); - else if (n < sizeof(struct disklabel)) - fatal("short read of disklabel: %d of %d bytes", n, - sizeof(struct disklabel)); - return(&lab); -} - -static void -rewritelabel(s, fd, lp) - char *s; - int fd; - register struct disklabel *lp; -{ -#ifdef COMPAT - if (unlabeled) - return; -#endif - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - if (ioctl(fd, DIOCWDINFO, (char *)lp) < 0) { - (void)fprintf(stderr, - "%s: ioctl (WDINFO): %s\n", progname, strerror(errno)); - fatal("%s: can't rewrite disk label", s); - } -#if vax - if (lp->d_type == DTYPE_SMD && lp->d_flags & D_BADSECT) { - register i; - int cfd; - daddr_t alt; - char specname[64]; - char blk[1024]; - char *cp; - - /* - * Make name for 'c' partition. - */ - strcpy(specname, s); - cp = specname + strlen(specname) - 1; - if (!isdigit(*cp)) - *cp = 'c'; - cfd = open(specname, O_WRONLY); - if (cfd < 0) - fatal("%s: %s", specname, strerror(errno)); - bzero(blk, sizeof(blk)); - *(struct disklabel *)(blk + LABELOFFSET) = *lp; - alt = lp->d_ncylinders * lp->d_secpercyl - lp->d_nsectors; - for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) { - if (lseek(cfd, (off_t)(alt + i) * lp->d_secsize, - L_SET) == -1) - fatal("lseek to badsector area: %s", - strerror(errno)); - if (write(cfd, blk, lp->d_secsize) < lp->d_secsize) - fprintf(stderr, - "%s: alternate label %d write: %s\n", - progname, i/2, strerror(errno)); - } - close(cfd); - } -#endif -} - -void -usage() -{ - if (mfs) { - fprintf(stderr, - "usage: mfs [ -fsoptions ] special-device mount-point\n"); - } else - fprintf(stderr, - "usage: newlfs [ -fsoptions ] special-device%s\n", -#ifdef COMPAT - " [device-type]"); -#else - ""); -#endif - fprintf(stderr, "where fsoptions are:\n"); - fprintf(stderr, "\t-B LFS segment size\n"); - fprintf(stderr, "\t-D debug\n"); - fprintf(stderr, "\t-F mount flags\n"); - fprintf(stderr, "\t-L create LFS file system\n"); - fprintf(stderr, - "\t-N do not create file system, just print out parameters\n"); - fprintf(stderr, "\t-S sector size\n"); -#ifdef COMPAT - fprintf(stderr, "\t-T disktype\n"); -#endif - fprintf(stderr, "\t-a maximum contiguous blocks\n"); - fprintf(stderr, "\t-b block size\n"); - fprintf(stderr, "\t-c cylinders/group\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-f frag size\n"); - fprintf(stderr, "\t-i number of bytes per inode\n"); - fprintf(stderr, "\t-k sector 0 skew, per track\n"); - fprintf(stderr, "\t-l hardware sector interleave\n"); - fprintf(stderr, "\t-m minimum free space %%\n"); - fprintf(stderr, "\t-n number of distinguished rotational positions\n"); - fprintf(stderr, "\t-o optimization preference (`space' or `time')\n"); - fprintf(stderr, "\t-p spare sectors per track\n"); - fprintf(stderr, "\t-r revolutions/minute\n"); - fprintf(stderr, "\t-s file system size (sectors)\n"); - fprintf(stderr, "\t-t tracks/cylinder\n"); - fprintf(stderr, "\t-u sectors/track\n"); - fprintf(stderr, "\t-x spare sectors per cylinder\n"); - exit(1); -} diff --git a/sbin/newlfs/newlfs.8 b/sbin/newlfs/newlfs.8 deleted file mode 100644 index f60c19e1595d4..0000000000000 --- a/sbin/newlfs/newlfs.8 +++ /dev/null @@ -1,99 +0,0 @@ -.\" Copyright (c) 1993 -.\" 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. -.\" -.\" @(#)newlfs.8 8.1 (Berkeley) 6/19/93 -.\" $Id: newlfs.8,v 1.5 1997/02/22 14:33:04 peter Exp $ -.\" -.Dd June 19, 1993 -.Dt NEWLFS 8 -.Os BSD 4.4 -.Sh NAME -.Nm newlfs -.Nd construct a new LFS file system -.Sh SYNOPSIS -.Nm newlfs -.Fl L -.Op Ar newlfs-options -.Ar special -.Sh DESCRIPTION -.Nm Newlfs -builds a log-structured file system on the specified special -device basing its defaults on the information in the disk label. -(Before running -.Nm newlfs -the disk must be labeled using -.Xr disklabel 8 .) -.Pp -The following options define the general layout policies. -.Bl -tag -width Fl -.It Fl B -The logical segment size of the file system in bytes. -.It Fl b Ar block-size -The block size of the file system in bytes. -.It Fl L -Create a log-structured file system (LFS). -This flag is currently required. -.It Fl m Ar free space \&% -The percentage of space reserved from normal users; the minimum -free space threshold. The default value used is 10%. -See -.Xr tunefs 8 -for more details on how to set this option. -.It Fl s Ar size -The size of the file system in sectors. -.El -.Sh SEE ALSO -.Xr disktab 5 , -.Xr fs 5 , -.Xr disklabel 8 , -.Xr diskpart 8 , -.Xr dumplfs 8 , -.Xr tunefs 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 -.%V 3 -.%P pp 181-197 -.%D August 1984 -.%O (reprinted in the BSD System Manager's Manual) -.Re -.Sh BUGS -LFS does not currently work in any variant of FreeBSD and should therefore -not be used. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.4 . diff --git a/sbin/nfsd/nfsd.8 b/sbin/nfsd/nfsd.8 index 4965876786198..5be6ff809f179 100644 --- a/sbin/nfsd/nfsd.8 +++ b/sbin/nfsd/nfsd.8 @@ -29,9 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)nfsd.8 8.3 (Berkeley) 2/22/94 +.\" @(#)nfsd.8 8.4 (Berkeley) 3/29/95 .\" -.Dd February 22, 1994 +.Dd March 29, 1995 .Dt NFSD 8 .Os .Sh NAME @@ -82,7 +82,7 @@ clients. .El .Pp For example, -.Dq Li "nfsd -u -t 6" +.Dq Li "nfsd -u -t -n 6" serves .Tn UDP and diff --git a/sbin/nfsiod/nfsiod.8 b/sbin/nfsiod/nfsiod.8 index 51249e1bd50c7..a676a7b183c14 100644 --- a/sbin/nfsiod/nfsiod.8 +++ b/sbin/nfsiod/nfsiod.8 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" From: @(#)nfsiod.8 8.2 (Berkeley) 2/22/94 -.\" $Id: nfsiod.8,v 1.2 1994/09/22 22:16:59 wollman Exp $ +.\" $Id: nfsiod.8,v 1.3 1996/08/23 20:35:40 mpp Exp $ .\" .Dd September 22, 1994 .Dt NFSIOD 8 @@ -53,7 +53,7 @@ It improves performance but is not required for correct operation. Unless otherwise specified, a single server is started. .Pp The options are as follows: -.Bl -tag -width Ds +.Bl -tag -width indent .It Fl n Specify how many servers are to be started. .El @@ -62,7 +62,7 @@ A client should run enough daemons to handle its maximum level of concurrency, typically four to six. .Pp If -.Nm nfsiod +.Nm detects that the running kernel does not include .Tn NFS support, it will attempt to load a loadable kernel module containing @@ -74,11 +74,11 @@ by way of If this fails, or no .Tn NFS LKM was available, -.Nm nfsiod +.Nm exits with an error. .Pp The -.Nm nfsiod +.Nm utility exits 0 on success, and >0 if an error occurs. .Sh SEE ALSO .Xr nfsstat 1 , @@ -88,6 +88,6 @@ utility exits 0 on success, and >0 if an error occurs. .Xr portmap 8 .Sh HISTORY The -.Nm nfsiod +.Nm utility first appeared in .Bx 4.4 . diff --git a/sbin/nologin/nologin.5 b/sbin/nologin/nologin.5 index 70b7392047f1d..d84c56604419e 100644 --- a/sbin/nologin/nologin.5 +++ b/sbin/nologin/nologin.5 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)nologin.8 8.1 (Berkeley) 6/19/93 +.\" $Id$ .\" .Dd June 19, 1993 .Dt NOLOGIN 5 @@ -53,7 +54,7 @@ for user root. .Bl -tag -width /etc/nologinxxx -compact .It Pa /etc/nologin The -.Nm nologin +.Nm file resides in .Pa /etc . .El diff --git a/sbin/nologin/nologin.8 b/sbin/nologin/nologin.8 index 32a7e73070b84..9802672007d76 100644 --- a/sbin/nologin/nologin.8 +++ b/sbin/nologin/nologin.8 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)nologin.8 8.1 (Berkeley) 6/19/93 +.\" $Id$ .\" .Dd June 19, 1993 .Dt NOLOGIN 8 @@ -49,6 +50,6 @@ have been disabled. .Xr login 1 .Sh HISTORY The -.Nm nologin +.Nm command appeared in .Bx 4.4 . diff --git a/sbin/nologin/nologin.sh b/sbin/nologin/nologin.sh index a396e9c7396d3..346836f63918d 100644 --- a/sbin/nologin/nologin.sh +++ b/sbin/nologin/nologin.sh @@ -32,6 +32,7 @@ # SUCH DAMAGE. # # @(#)nologin.sh 8.1 (Berkeley) 6/5/93 +# $Id$ # echo 'This account is currently not available.' diff --git a/sbin/ping/ping.8 b/sbin/ping/ping.8 index 437d2dc5d19ba..56a46ce854c7a 100644 --- a/sbin/ping/ping.8 +++ b/sbin/ping/ping.8 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)ping.8 8.2 (Berkeley) 12/11/93 -.\" $Id: ping.8,v 1.3.2.5 1997/03/03 07:01:37 mpp Exp $ +.\" $Id: ping.8,v 1.3.2.6 1997/09/14 19:40:03 jkh Exp $ .\" .Dd March 1, 1997 .Dt PING 8 @@ -41,7 +41,7 @@ .Tn ICMP ECHO_REQUEST packets to network hosts .Sh SYNOPSIS -.Nm +.Nm ping .Op Fl QRadfnqrv .Op Fl c Ar count .Op Fl i Ar wait @@ -74,7 +74,7 @@ header, followed by a and then an arbitrary number of .Dq pad bytes used to fill out the packet. The options are as follows: -.Bl -tag -width Ds +.Bl -tag -width indent .It Fl a Audible. Include a bell .Pq ASCII 0x07 @@ -122,7 +122,7 @@ This flag only applies if the ping destination is a multicast address. If .Ar preload is specified, -.Nm ping +.Nm sends that many packets as fast as possible before falling into its normal mode of behavior. Only the super-user may use this option. @@ -173,6 +173,9 @@ the .Xr traceroute 8 command is usually better at determining the route packets take to a particular destination. +If more routes come back than should, such as due to an illegal spoofed +packet, ping will print the route list and then truncate it at the correct +spot. Many hosts ignore or discard the .Tn RECORD_ROUTE option. @@ -187,7 +190,7 @@ e.g., after the interface was dropped by .Xr routed 8 .Pc . .It Fl s Ar packetsize -Specifies the number of data bytes to be sent. +Specify the number of data bytes to be sent. The default is 56, which translates into 64 .Tn ICMP data bytes when combined @@ -268,7 +271,7 @@ to the same request. .Pp Damaged packets are obviously serious cause for alarm and often indicate broken hardware somewhere in the -.Nm ping +.Nm packet's path (in the network or in the hosts). .Sh TRYING DIFFERENT DATA PATTERNS The @@ -323,7 +326,9 @@ uses 30, used 15 .Pc . .Pp -The maximum possible value of this field is 255, and most Unix systems set +The maximum possible value of this field is 255, and most +.Ux +systems set the .Tn TTL field of @@ -336,14 +341,18 @@ some hosts, but not reach them with or .Xr ftp 1 . .Pp -In normal operation ping prints the ttl value from the packet it receives. +In normal operation +.Nm +prints the ttl value from the packet it receives. When a remote system receives a ping packet, it can do one of three things with the .Tn TTL field in its response: .Bl -bullet .It -Not change it; this is what Berkeley Unix systems did before the +Not change it; this is what +.Bx +systems did before the .Bx 4.3 tahoe release. In this case the @@ -352,7 +361,7 @@ value in the received packet will be 255 minus the number of routers in the round-trip path. .It Set it to 255; this is what current -.Tn BSD +.Bx systems do. In this case the .Tn TTL @@ -396,7 +405,9 @@ command appeared in .Sh AUTHORS The original .Nm -command was written by Mike Muuss while at the US Army Ballistics +command was written by +.An Mike Muuss +while at the US Army Ballistics Research Laboratory. .Sh BUGS Many Hosts and Gateways ignore the diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 3bdac032a9d3b..4fe954ba3feb8 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -41,17 +41,17 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint -/* +#if 0 static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; -*/ +#endif static const char rcsid[] = - "$Id: ping.c,v 1.8.2.15 1998/03/06 13:07:12 jkh Exp $"; + "$Id: ping.c,v 1.8.2.16 1998/05/25 20:21:34 fenner Exp $"; #endif /* not lint */ /* * P I N G . C * - * Using the InterNet Control Message Protocol (ICMP) "ECHO" facility, + * Using the Internet Control Message Protocol (ICMP) "ECHO" facility, * measure round-trip-delays and packet loss across network paths. * * Author - @@ -82,7 +82,6 @@ static const char rcsid[] = #include <unistd.h> #include <sys/socket.h> -#include <sys/file.h> #include <sys/time.h> #include <sys/uio.h> @@ -93,7 +92,8 @@ static const char rcsid[] = #include <netinet/ip_var.h> #include <arpa/inet.h> -#define DEFDATALEN (64 - 8) /* default data length */ +#define PHDR_LEN sizeof(struct timeval) +#define DEFDATALEN (64 - PHDR_LEN) /* default data length */ #define FLOOD_BACKOFF 20000 /* usecs to back off if F_FLOOD mode */ /* runs out of buffer space */ #define MAXIPLEN 60 @@ -175,7 +175,7 @@ static void pr_retip(struct ip *); static void status(int); static void stopit(int); static void tvsub(struct timeval *, struct timeval *); -static void usage(const char *) __dead2; +static void usage(void) __dead2; int main(argc, argv) @@ -216,7 +216,7 @@ main(argc, argv) preload = 0; - datap = &outpack[8 + sizeof(struct timeval)]; + datap = &outpack[8 + PHDR_LEN]; while ((ch = getopt(argc, argv, "I:LQRT:c:adfi:l:np:qrs:v")) != -1) { switch(ch) { case 'a': @@ -313,13 +313,12 @@ main(argc, argv) options |= F_VERBOSE; break; default: - - usage(argv[0]); + usage(); } } if (argc - optind != 1) - usage(argv[0]); + usage(); target = argv[optind]; bzero((char *)&whereto, sizeof(struct sockaddr)); @@ -353,14 +352,14 @@ main(argc, argv) errx(EX_USAGE, "-I, -L, -T flags cannot be used with unicast destination"); - if (datalen >= sizeof(struct timeval)) /* can we time transfer */ + if (datalen >= PHDR_LEN) /* can we time transfer */ timing = 1; packlen = datalen + MAXIPLEN + MAXICMPLEN; if (!(packet = (u_char *)malloc((size_t)packlen))) err(EX_UNAVAILABLE, "malloc"); if (!(options & F_PINGFILLED)) - for (i = 8; i < datalen; ++i) + for (i = PHDR_LEN; i < datalen; ++i) *datap++ = i; ident = getpid() & 0xFFFF; @@ -501,7 +500,7 @@ main(argc, argv) timeout.tv_usec += 1000000; timeout.tv_sec--; } - while (timeout.tv_usec > 1000000) { + while (timeout.tv_usec >= 1000000) { timeout.tv_usec -= 1000000; timeout.tv_sec++; } @@ -519,14 +518,17 @@ main(argc, argv) if ((cc = recvmsg(s, &msg, 0)) < 0) { if (errno == EINTR) continue; - perror("ping: recvmsg"); + warn("recvmsg"); continue; } #ifdef SO_TIMESTAMP if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMP && - cmsg->cmsg_len == (sizeof *cmsg + sizeof *t)) - t = (struct timeval *)CMSG_DATA(cmsg); + cmsg->cmsg_len == (sizeof *cmsg + sizeof *t)) { + /* Copy to avoid alignment problems: */ + memcpy(&now,CMSG_DATA(cmsg),sizeof(now)); + t = &now; + } #endif if (t == 0) { (void)gettimeofday(&now, NULL); @@ -599,7 +601,7 @@ pinger(void) (void)gettimeofday((struct timeval *)&outpack[8], (struct timezone *)NULL); - cc = datalen + 8; /* skips ICMP portion */ + cc = datalen + PHDR_LEN; /* skips ICMP portion */ /* compute ICMP checksum here */ icp->icmp_cksum = in_cksum((u_short *)icp, cc); @@ -616,7 +618,7 @@ pinger(void) warn("sendto"); } else { warn("%s: partial write: %d of %d bytes", - hostname, cc, i); + hostname, i, cc); } } ntransmitted++; @@ -668,14 +670,17 @@ pr_pack(buf, cc, from, tv) ++nreceived; triptime = 0.0; if (timing) { + struct timeval tv1; #ifndef icmp_data tp = (struct timeval *)&icp->icmp_ip; #else tp = (struct timeval *)icp->icmp_data; #endif - tvsub(tv, tp); - triptime = ((double)tv->tv_sec) * 1000.0 + - ((double)tv->tv_usec) / 1000.0; + /* Avoid unaligned data: */ + memcpy(&tv1,tp,sizeof(tv1)); + tvsub(tv, &tv1); + triptime = ((double)tv->tv_sec) * 1000.0 + + ((double)tv->tv_usec) / 1000.0; tsum += triptime; tsumsq += triptime * triptime; if (triptime < tmin) @@ -710,14 +715,22 @@ pr_pack(buf, cc, from, tv) if (options & F_AUDIBLE) (void)printf("\a"); /* check the data */ - cp = (u_char*)&icp->icmp_data[8]; - dp = &outpack[8 + sizeof(struct timeval)]; - for (i = 8; i < datalen; ++i, ++cp, ++dp) { + cp = (u_char*)&icp->icmp_data[PHDR_LEN]; + dp = &outpack[8 + PHDR_LEN]; + for (i = PHDR_LEN; i < datalen; ++i, ++cp, ++dp) { if (*cp != *dp) { (void)printf("\nwrong data byte #%d should be 0x%x but was 0x%x", i, *dp, *cp); + printf("\ncp:"); cp = (u_char*)&icp->icmp_data[0]; - for (i = 8; i < datalen; ++i, ++cp) { + for (i = 0; i < datalen; ++i, ++cp) { + if ((i % 32) == 8) + (void)printf("\n\t"); + (void)printf("%x ", *cp); + } + printf("\ndp:"); + cp = &outpack[8]; + for (i = 0; i < datalen; ++i, ++cp) { if ((i % 32) == 8) (void)printf("\n\t"); (void)printf("%x ", *cp); @@ -810,9 +823,14 @@ pr_pack(buf, cc, from, tv) cp += i; break; } - old_rrlen = i; - bcopy((char *)cp, old_rr, i); + if (i < MAX_IPOPTLEN) { + old_rrlen = i; + bcopy((char *)cp, old_rr, i); + } else + old_rrlen = 0; + (void)printf("\nRR: "); + j = 0; for (;;) { l = *++cp; l = (l<<8) + *++cp; @@ -827,8 +845,13 @@ pr_pack(buf, cc, from, tv) } hlen -= 4; i -= 4; + j += 4; if (i <= 0) break; + if (j >= MAX_IPOPTLEN) { + (void) printf("\t(truncated route)"); + break; + } (void)putchar('\n'); } break; @@ -1151,8 +1174,9 @@ pr_iph(ip) (void)printf(" %1x %1x %02x %04x %04x", ip->ip_v, ip->ip_hl, ip->ip_tos, ntohs(ip->ip_len), ntohs(ip->ip_id)); - (void)printf(" %1lx %04lx", (ntohl(ip->ip_off) & 0xe000) >> 13, - ntohl(ip->ip_off) & 0x1fff); + (void)printf(" %1lx %04lx", + (u_long) (ntohl(ip->ip_off) & 0xe000) >> 13, + (u_long) ntohl(ip->ip_off) & 0x1fff); (void)printf(" %02x %02x %04x", ip->ip_ttl, ip->ip_p, ntohs(ip->ip_sum)); (void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_src.s_addr)); @@ -1230,7 +1254,7 @@ fill(bp, patp) if (ii > 0) for (kk = 0; - kk <= MAXPACKET - (8 + sizeof(struct timeval) + ii); + kk <= MAXPACKET - (8 + PHDR_LEN + ii); kk += ii) for (jj = 0; jj < ii; ++jj) bp[jj + kk] = pat[jj]; @@ -1243,15 +1267,10 @@ fill(bp, patp) } static void -usage(argv0) - const char *argv0; +usage() { - if (strrchr(argv0,'/')) - argv0 = strrchr(argv0,'/') + 1; - fprintf(stderr, - "usage: %s [-QRadfnqrv] [-c count] [-i wait] [-l preload] " - "[-p pattern]\n [-s packetsize] " - "[host | [-L] [-I iface] [-T ttl] mcast-group]\n", - argv0); + fprintf(stderr, "%s\n%s\n", +"usage: ping [-QRadfnqrv] [-c count] [-i wait] [-l preload] [-p pattern]", +" [-s packetsize] [host | [-L] [-I iface] [-T ttl] mcast-group]"); exit(EX_USAGE); } diff --git a/sbin/quotacheck/quotacheck.8 b/sbin/quotacheck/quotacheck.8 index b9bbdad2eafe6..080f8851ad287 100644 --- a/sbin/quotacheck/quotacheck.8 +++ b/sbin/quotacheck/quotacheck.8 @@ -33,6 +33,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)quotacheck.8 8.1 (Berkeley) 6/5/93 +.\" $Id$ .\" .Dd June 5, 1993 .Dt QUOTACHECK 8 @@ -45,7 +46,8 @@ .Op Fl g .Op Fl u .Op Fl v -.Ar filesystem Ar ... +.Ar filesystem +.Ar .Nm quotacheck .Op Fl g .Op Fl u @@ -63,13 +65,11 @@ incorrect quotas are updated (the latter only occurs if an active filesystem is checked). By default both user and group quotas are checked. .Pp -Available options: -.Bl -tag -width Ds +The following options are available: +.Bl -tag -width indent .It Fl a -If the -.Fl a -flag is supplied in place of any filesystem names, -.Nm quotacheck +If supplied in place of any filesystem names, +.Nm will check all the filesystems indicated in .Pa /etc/fstab to be read-write with disk quotas. @@ -85,7 +85,7 @@ Only user quotas listed in .Pa /etc/fstab are to be checked. .It Fl v -.Nm quotacheck +.Nm Quotacheck reports discrepancies between the calculated and recorded disk quotas and other additional diagnostic messages. .El @@ -101,8 +101,8 @@ using the pass numbers in in an identical fashion to .Xr fsck 8 . .Pp -Normally -.Nm quotacheck +Normally, +.Nm operates silently. .Pp .Nm Quotacheck @@ -115,7 +115,7 @@ which are located at the root of the associated file system. These defaults may be overridden in .Pa /etc/fstab . If a file is not present, -.Nm quotacheck +.Nm will create it. .Pp .Nm Quotacheck @@ -131,7 +131,7 @@ accesses the raw device in calculating the actual disk usage for each user. Thus, the filesystems checked should be quiescent while -.Nm quotacheck +.Nm is running. .Sh FILES .Bl -tag -width quota.group -compact diff --git a/sbin/reboot/reboot.8 b/sbin/reboot/reboot.8 index 6252093b0588e..c43c5f172a669 100644 --- a/sbin/reboot/reboot.8 +++ b/sbin/reboot/reboot.8 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)reboot.8 8.1 (Berkeley) 6/9/93 +.\" $Id$ .\" .Dd June 9, 1993 .Dt REBOOT 8 @@ -52,7 +53,7 @@ stopping and restarting the system The .Nm halt and -.Nm reboot +.Nm utilities flush the file system cache to disk, send all running processes a SIGTERM (and subsequently a SIGKILL) and, respectively, halt or restart the system. @@ -60,28 +61,20 @@ The action is logged, including entering a shutdown record into the login accounting file. .Pp The options are as follows: -.Bl -tag -width Ds +.Bl -tag -width indent .It Fl n -If the -.Fl n -option is specified, -the file system cache is not flushed. +The file system cache is not flushed. This option should probably not be used. .It Fl q -If the -.Fl q -option is specified, -the system is halted or restarted quickly and ungracefully, and only +The system is halted or restarted quickly and ungracefully, and only the flushing of the file system cache is performed. This option should probably not be used. .It Fl p -If the -.Fl p -option is specified, then the system will turn off the power +The system will turn off the power if it can. This is of course likely to make -.Nm reboot +.Nm rather similar to -.Nm halt. +.Nm halt . .El .Pp The @@ -91,7 +84,7 @@ and utilities are nothing more than aliases for the .Nm halt and -.Nm reboot +.Nm utilities. .Pp Normally, the @@ -105,6 +98,6 @@ users advance warning of their impending doom. .Xr sync 8 .Sh HISTORY A -.Nm reboot +.Nm command appeared in .At v6 . diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index cfd3514e05a99..d0ee42c27097e 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: reboot.c,v 1.3.2.2 1997/06/30 11:18:14 charnier Exp $ + * $Id: reboot.c,v 1.3.2.3 1997/09/14 19:41:49 jkh Exp $ */ #ifndef lint @@ -178,6 +178,6 @@ restart: void usage() { - (void)fprintf(stderr, "usage: %s [-nq]\n", dohalt ? "halt" : "reboot"); + (void)fprintf(stderr, "usage: %s [-npq]\n", dohalt ? "halt" : "reboot"); exit(1); } diff --git a/sbin/route/route.8 b/sbin/route/route.8 index 31e03145eac18..c1ec89e3492cc 100644 --- a/sbin/route/route.8 +++ b/sbin/route/route.8 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)route.8 8.3 (Berkeley) 3/19/94 -.|' $Id: route.8,v 1.10 1997/02/22 14:33:09 peter Exp $ +.|' $Id: route.8,v 1.7.2.1 1997/03/03 07:01:44 mpp Exp $ .\" .Dd March 19, 1994 .Dt ROUTE 8 @@ -200,7 +200,7 @@ symbolic names. .Pp The optional .Fl netmask -qualifier is intended +modifier is intended to achieve the effect of an .Tn OSI .Tn ESIS diff --git a/sbin/routed/parms.c b/sbin/routed/parms.c index 1379479ed4a8c..9d501d55b16d2 100644 --- a/sbin/routed/parms.c +++ b/sbin/routed/parms.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)if.c 8.1 (Berkeley) 6/5/93"; #elif defined(__NetBSD__) static char rcsid[] = "$NetBSD$"; #endif -#ident "$Revision: 1.1.1.3 $" +#ident "$Revision: 1.1.1.1.2.1 $" #include "defs.h" #include "pathnames.h" @@ -557,7 +557,7 @@ parse_parms(char *line, /* "subnet=x.y.z.u/mask,metric" must be alone on the line */ if (!strncasecmp(line, "subnet=", sizeof("subnet=")-1) - && *(val = &line[sizeof("subnet=")]) != '\0') { + && *(val = &line[sizeof("subnet=")-1]) != '\0') { intnetp = (struct intnet*)malloc(sizeof(*intnetp)); intnetp->intnet_metric = 1; if ((p = strrchr(val,','))) { diff --git a/sbin/routed/routed.8 b/sbin/routed/routed.8 index 0266458aa9971..5ef87d8fcdfb8 100644 --- a/sbin/routed/routed.8 +++ b/sbin/routed/routed.8 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)routed.8 8.2 (Berkeley) 12/11/93 -.\" $Id: routed.8,v 1.9 1997/03/12 13:22:17 mpp Exp $ +.\" $Id: routed.8,v 1.2.2.3 1997/08/19 21:22:05 joerg Exp $ .\" .Dd June 1, 1996 .Dt ROUTED 8 @@ -633,7 +633,6 @@ for distant gateways .Xr icmp 4 , .Xr udp 4 , .Xr gated 8 , -.Xr htable 8 , .Xr rtquery 8 . .Rs .%T Internet Transport Protocols diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c index d78a55a478e63..14061dab2ee92 100644 --- a/sbin/savecore/savecore.c +++ b/sbin/savecore/savecore.c @@ -246,7 +246,7 @@ kmem_setup() Lseek(kmem, (off_t)current_nl[X_DUMPLO].n_value, L_SET); (void)Read(kmem, &dumplo, sizeof(dumplo)); if (verbose) - (void)printf("dumplo = %d (%d * %d)\n", + (void)printf("dumplo = %ld (%ld * %d)\n", dumplo, dumplo/DEV_BSIZE, DEV_BSIZE); Lseek(kmem, (off_t)current_nl[X_DUMPMAG].n_value, L_SET); (void)Read(kmem, &dumpmag, sizeof(dumpmag)); diff --git a/sbin/scsi/scsi.c b/sbin/scsi/scsi.c index 5c42681259b9d..c2da6e4b312bb 100644 --- a/sbin/scsi/scsi.c +++ b/sbin/scsi/scsi.c @@ -39,7 +39,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: scsi.c,v 1.12.2.1 1997/06/19 14:25:07 charnier Exp $ + * $Id: scsi.c,v 1.12.2.2 1997/09/14 19:48:28 jkh Exp $ */ #include <stdio.h> @@ -329,8 +329,7 @@ do_cmd(int fd, char *fmt, int argc, char **argv) } if (amount == -1) { - perror("read"); - exit(errno); + err(1, "read"); } else if (amount == 0) { @@ -375,13 +374,13 @@ do_cmd(int fd, char *fmt, int argc, char **argv) } if (amount < 0) { - perror("write"); - exit(errno); + err(1, "write"); } else if (amount == 0) - fprintf(stderr, "Warning: wrote only %d bytes out of %d.\n", - scsireq->datalen - count, - scsireq->datalen); + fprintf(stderr, + "Warning: wrote only %lu bytes out of %lu.\n", + (u_long)scsireq->datalen - count, + (u_long)scsireq->datalen); } else @@ -396,13 +395,11 @@ static void freeze_ioctl(int fd, int op, void *data) { if (ioctl(fd, SCIOCFREEZE, 0) == -1) { - if (errno == ENODEV) { - fprintf(stderr, - "Your kernel must be configured with option SCSI_FREEZE.\n"); - } + if (errno == ENODEV) + errx(1, + "your kernel must be configured with option SCSI_FREEZE"); else - perror("SCIOCFREEZE"); - exit(errno); + err(1, "ioctl [SCIOCFREEZE]"); } } @@ -457,7 +454,7 @@ void mode_sense(int fd, u_char *data, int len, int pc, int page) if (SCSIREQ_ERROR(scsireq)) { scsi_debug(stderr, 0, scsireq); - exit(-1); + exit(1); } free(scsireq); @@ -480,7 +477,7 @@ void mode_select(int fd, u_char *data, int len, int perm) if (SCSIREQ_ERROR(scsireq)) { scsi_debug(stderr, 0, scsireq); - exit(-1); + exit(1); } free(scsireq); @@ -542,16 +539,14 @@ static char *mode_lookup(int page) found = 1; skipwhite(modes); - if (getc(modes) != START_ENTRY) { - fprintf(stderr, "Expected %c.\n", START_ENTRY); - exit(-1); - } + if (getc(modes) != START_ENTRY) + errx(1, "expected %c", START_ENTRY); match = 1; while (match != 0) { c = getc(modes); if (c == EOF) { - fprintf(stderr, "Expected %c.\n", END_ENTRY); + warnx("expected %c", END_ENTRY); } if (c == START_ENTRY) { @@ -563,10 +558,8 @@ static char *mode_lookup(int page) break; } if (found && c != '\n') { - if (next >= sizeof(fmt)) { - fprintf(stderr, "Stupid program: Buffer overflow.\n"); - exit(ENOMEM); - } + if (next >= sizeof(fmt)) + errx(1, "buffer overflow"); fmt[next++] = (u_char)c; } @@ -614,9 +607,9 @@ edit_done(void) if (opened) { if (fclose(edit_file)) - perror(edit_name); + warn("%s", edit_name); if (unlink(edit_name)) - perror(edit_name); + warn("%s", edit_name); } } @@ -624,14 +617,10 @@ static void edit_init(void) { edit_rewind(); - if (tmpnam(edit_name) == 0) { - perror("tmpnam failed"); - exit(errno); - } - if ( (edit_file = fopen(edit_name, "w")) == 0) { - perror(edit_name); - exit(errno); - } + if (tmpnam(edit_name) == 0) + errx(1, "tmpnam failed"); + if ((edit_file = fopen(edit_name, "w")) == 0) + err(1, "%s", edit_name); edit_opened = 1; atexit(edit_done); @@ -640,15 +629,12 @@ edit_init(void) static void edit_check(void *hook, int letter, void *arg, int count, char *name) { - if (letter != 'i' && letter != 'b') { - fprintf(stderr, "Can't edit format %c.\n", letter); - exit(-1); - } + if (letter != 'i' && letter != 'b') + errx(1, "can't edit format %c", letter); + + if (editind >= sizeof(editinfo) / sizeof(editinfo[0])) + errx(1, "edit table overflow"); - if (editind >= sizeof(editinfo) / sizeof(editinfo[0])) { - fprintf(stderr, "edit table overflow\n"); - exit(ENOMEM); - } editinfo[editind].can_edit = ((int)arg != 0); editind++; } @@ -656,10 +642,8 @@ edit_check(void *hook, int letter, void *arg, int count, char *name) static void edit_defaults(void *hook, int letter, void *arg, int count, char *name) { - if (letter != 'i' && letter != 'b') { - fprintf(stderr, "Can't edit format %c.\n", letter); - exit(-1); - } + if (letter != 'i' && letter != 'b') + errx(1, "can't edit format %c", letter); editinfo[editind].default_value = ((int)arg); editind++; @@ -669,10 +653,8 @@ static void edit_report(void *hook, int letter, void *arg, int count, char *name) { if (editinfo[editind].can_edit) { - if (letter != 'i' && letter != 'b') { - fprintf(stderr, "Can't report format %c.\n", letter); - exit(-1); - } + if (letter != 'i' && letter != 'b') + errx(1, "can't report format %c", letter); fprintf(edit_file, "%s: %d\n", name, (int)arg); } @@ -687,18 +669,13 @@ edit_get(void *hook, char *name) if (editinfo[editind].can_edit) { char line[80]; - if (fgets(line, sizeof(line), edit_file) == 0) { - perror("fgets"); - exit(errno); - } + if (fgets(line, sizeof(line), edit_file) == 0) + err(1, "fgets"); line[strlen(line) - 1] = 0; - if (strncmp(name, line, strlen(name)) != 0) { - fprintf(stderr, "Expected \"%s\" and read \"%s\"\n", - name, line); - exit(-1); - } + if (strncmp(name, line, strlen(name)) != 0) + errx(1, "expected \"%s\" and read \"%s\"", name, line); arg = strtoul(line + strlen(name) + 2, 0, 0); } @@ -722,10 +699,8 @@ edit_edit(void) system(system_line); free(system_line); - if ( (edit_file = fopen(edit_name, "r")) == 0) { - perror(edit_name); - exit(errno); - } + if ((edit_file = fopen(edit_name, "r")) == 0) + err(1, "%s", edit_name); } static void @@ -759,16 +734,12 @@ mode_edit(int fd, int page, int edit, int argc, char *argv[]) } if (edit) { - if (!fmt) { - fprintf(stderr, "Sorry: can't edit without a format.\n"); - exit(-1); - } + if (!fmt) + errx(1, "can't edit without a format"); - if (pagectl != 0 && pagectl != 3) { - fprintf(stderr, -"It only makes sense to edit page 0 (current) or page 3 (saved values)\n"); - exit(-1); - } + if (pagectl != 0 && pagectl != 3) + errx(1, +"it only makes sense to edit page 0 (current) or page 3 (saved values)"); verbose = 1; @@ -929,18 +900,15 @@ void main(int argc, char **argv) scaddr.lun = lun; if (ioctl(fd,SCIOCREPROBE,&scaddr) == -1) - perror("ioctl"); + warn("ioctl [SCIOCREPROBE]"); } else if(debugflag) { if (ioctl(fd,SCIOCDEBUG,&debuglevel) == -1) - { - perror("ioctl [SCIODEBUG]"); - exit(1); - } + err(1, "ioctl [SCIODEBUG]"); } else if (commandflag) { char *fmt; if (argc < 1) { - fprintf(stderr, "Need the command format string.\n"); + warnx("need the command format string"); usage(); } diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c index dea6a279417f6..567ae64fb0cb9 100644 --- a/sbin/shutdown/shutdown.c +++ b/sbin/shutdown/shutdown.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: shutdown.c,v 1.10 1998/01/08 02:23:59 alex Exp $ + * $Id: shutdown.c,v 1.4.2.5 1998/01/26 01:01:39 alex Exp $ */ #ifndef lint @@ -73,10 +73,18 @@ static char sccsid[] = "@(#)shutdown.c 8.2 (Berkeley) 2/16/94"; struct interval { int timeleft, timetowait; } tlist[] = { - 10 H, 5 H, 5 H, 3 H, 2 H, 1 H, 1 H, 30 M, - 30 M, 10 M, 20 M, 10 M, 10 M, 5 M, 5 M, 3 M, - 2 M, 1 M, 1 M, 30 S, 30 S, 30 S, - 0, 0, + { 10 H, 5 H }, + { 5 H, 3 H }, + { 2 H, 1 H }, + { 1 H, 30 M }, + { 30 M, 10 M }, + { 20 M, 10 M }, + { 10 M, 5 M }, + { 5 M, 3 M }, + { 2 M, 1 M }, + { 1 M, 30 S }, + { 30 S, 30 S }, + { 0 , 0 } }; #undef H #undef M @@ -226,7 +234,7 @@ loop() * Warn now, if going to sleep more than a fifth of * the next wait time. */ - if (sltime = offset - tp->timeleft) { + if ((sltime = offset - tp->timeleft)) { if (sltime > tp->timetowait / 5) timewarn(offset); (void)sleep(sltime); @@ -247,6 +255,11 @@ loop() static jmp_buf alarmbuf; +static char *restricted_environ[] = { + "PATH=" _PATH_STDPATH, + NULL +}; + void timewarn(timeleft) int timeleft; @@ -255,12 +268,14 @@ timewarn(timeleft) static char hostname[MAXHOSTNAMELEN + 1]; FILE *pf; char wcmd[MAXPATHLEN + 4]; + extern char **environ; if (!first++) (void)gethostname(hostname, sizeof(hostname)); /* undoc -n option to wall suppresses normal wall banner */ (void)snprintf(wcmd, sizeof(wcmd), "%s -n", _PATH_WALL); + environ = restricted_environ; if (!(pf = popen(wcmd, "w"))) { syslog(LOG_ERR, "shutdown: can't find %s: %m", _PATH_WALL); return; @@ -307,6 +322,7 @@ timeout(signo) void die_you_gravy_sucking_pig_dog() { + char *empty_environ[] = { NULL }; syslog(LOG_NOTICE, "%s by %s: %s", doreboot ? "reboot" : dohalt ? "halt" : "shutdown", whom, mbuf); @@ -327,14 +343,16 @@ die_you_gravy_sucking_pig_dog() (void)printf("\nkill -HUP 1\n"); #else if (doreboot) { - execle(_PATH_REBOOT, "reboot", "-l", nosync, 0); + execle(_PATH_REBOOT, "reboot", "-l", nosync, + (char *)NULL, empty_environ); syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REBOOT); - perror("shutdown"); + warn(_PATH_REBOOT); } else if (dohalt) { - execle(_PATH_HALT, "halt", "-l", nosync, 0); + execle(_PATH_HALT, "halt", "-l", nosync, + (char *)NULL, empty_environ); syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT); - perror("shutdown"); + warn(_PATH_HALT); } (void)kill(1, SIGTERM); /* to single user */ #endif diff --git a/sbin/slattach/slattach.c b/sbin/slattach/slattach.c index 3a9147796f843..8a0ea1eae5e78 100644 --- a/sbin/slattach/slattach.c +++ b/sbin/slattach/slattach.c @@ -42,7 +42,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)slattach.c 4.6 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$Id$"; +static char rcsid[] = "$Id: slattach.c,v 1.20.2.2 1997/09/14 19:50:36 jkh Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -212,13 +212,13 @@ main(int argc, char **argv) slip_discipline(); /* switch to slip line discipline */ /* upon INT log a timestamp and exit. */ - if ((int)signal(SIGINT,sigint_handler) < 0) + if (signal(SIGINT,sigint_handler) == SIG_ERR) syslog(LOG_NOTICE,"cannot install SIGINT handler: %m"); /* upon TERM log a timestamp and exit. */ - if ((int)signal(SIGTERM,sigterm_handler) < 0) + if (signal(SIGTERM,sigterm_handler) == SIG_ERR) syslog(LOG_NOTICE,"cannot install SIGTERM handler: %m"); /* upon HUP redial and reconnect. */ - if ((int)signal(SIGHUP,sighup_handler) < 0) + if (signal(SIGHUP,sighup_handler) == SIG_ERR) syslog(LOG_NOTICE,"cannot install SIGHUP handler: %m"); if (redial_on_startup) @@ -272,11 +272,11 @@ void acquire_line() /* create PID file */ if((pidfile = fopen(pidfilename, "w"))) { - fprintf(pidfile, "%ld\n", getpid()); + fprintf(pidfile, "%ld\n", (long)getpid()); fclose(pidfile); } - if ((int)signal(SIGHUP,sighup_handler) < 0) /* Re-enable HUP signal */ + if (signal(SIGHUP,sighup_handler) == SIG_ERR) /* Re-enable HUP signal */ syslog(LOG_NOTICE,"cannot install SIGHUP handler: %m"); if (uucp_lock) { diff --git a/sbin/swapon/swapon.8 b/sbin/swapon/swapon.8 index 1f87bf93f6e12..638ce597d704b 100644 --- a/sbin/swapon/swapon.8 +++ b/sbin/swapon/swapon.8 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)swapon.8 8.1 (Berkeley) 6/5/93 -.\" $Id: swapon.8,v 1.4 1996/09/23 22:23:19 wosch Exp $ +.\" $Id: swapon.8,v 1.4.2.1 1997/08/26 00:32:59 imp Exp $ .\" .Dd June 5, 1993 .Dt SWAPON 8 @@ -72,6 +72,7 @@ available to the system for swap allocation. .Xr swapon 2 , .Xr fstab 5 , .Xr init 8 , +.Xr pstat 8 , .Xr rc 8 , .Xr vnconfig 8 .Sh FILES |
