diff options
author | Philippe Charnier <charnier@FreeBSD.org> | 1997-10-09 07:22:08 +0000 |
---|---|---|
committer | Philippe Charnier <charnier@FreeBSD.org> | 1997-10-09 07:22:08 +0000 |
commit | d9961cfdb97c3a6095df8fee9c9ef9f0b490fa7a (patch) | |
tree | 594bb346c2fea5b377ca1277d707fe81d59e158e /usr.sbin/pstat | |
parent | 4a9670dd7611f7099912f5326cadb5cdc64393c0 (diff) | |
download | src-d9961cfdb97c3a6095df8fee9c9ef9f0b490fa7a.tar.gz src-d9961cfdb97c3a6095df8fee9c9ef9f0b490fa7a.zip |
Use err(3). Add usage().
Default source of tables (-M) is /dev/mem, not /dev/kmem.
Notes
Notes:
svn path=/head/; revision=30243
Diffstat (limited to 'usr.sbin/pstat')
-rw-r--r-- | usr.sbin/pstat/pstat.8 | 14 | ||||
-rw-r--r-- | usr.sbin/pstat/pstat.c | 51 |
2 files changed, 37 insertions, 28 deletions
diff --git a/usr.sbin/pstat/pstat.8 b/usr.sbin/pstat/pstat.8 index 41d9645a1a8a..011593cc8955 100644 --- a/usr.sbin/pstat/pstat.8 +++ b/usr.sbin/pstat/pstat.8 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)pstat.8 8.5 (Berkeley) 5/13/94 -.\" $Id: pstat.8,v 1.13 1997/03/11 13:00:38 peter Exp $ +.\" $Id: pstat.8,v 1.14 1997/08/30 20:18:48 peter Exp $ .\" .Dd May 13, 1994 .Dt PSTAT 8 @@ -47,6 +47,8 @@ .Pp .Nm swapinfo .Op Fl k +.Op Fl M Ar core +.Op Fl N Ar system .Sh DESCRIPTION .Nm Pstat displays open file entry, swap space utilization, @@ -55,7 +57,7 @@ If .Ar corefile is given, the information is sought there, otherwise in -.Pa /dev/kmem . +.Pa /dev/mem . The required namelist is taken from .Pa /kernel unless @@ -70,7 +72,7 @@ option is implied, and only the .Fl k option is legal. .Pp -Options are +The following options are available: .Bl -tag -width indent .It Fl n Print devices out by major/minor instead of name. @@ -78,7 +80,7 @@ Print devices out by major/minor instead of name. Print sizes in kilobytes, regardless of the setting of the BLOCKSIZE environment variable. .It Fl T -Prints the number of used and free slots in the several system tables +Print the number of used and free slots in the several system tables and is useful for checking to see how large system tables have become if the system is under heavy load. .It Fl f @@ -358,10 +360,10 @@ Same as present for backwards-compatibility. .El .Sh FILES -.Bl -tag -width /dev/kmemxxx -compact +.Bl -tag -width /dev/memxxx -compact .It Pa /kernel namelist -.It Pa /dev/kmem +.It Pa /dev/mem default source of tables .El .Sh SEE ALSO diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c index 576199b73385..83b6d21f4cad 100644 --- a/usr.sbin/pstat/pstat.c +++ b/usr.sbin/pstat/pstat.c @@ -32,13 +32,17 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1980, 1991, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)pstat.c 8.16 (Berkeley) 5/9/95"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include <sys/param.h> @@ -162,7 +166,7 @@ char *nlistf = NULL; char *memf = NULL; kvm_t *kd; -char *usage; +char *usagestr; struct { int m_flag; @@ -231,6 +235,7 @@ void ufs_header __P((void)); int ufs_print __P((struct vnode *)); void union_header __P((void)); int union_print __P((struct vnode *)); +static void usage __P((void)); void vnode_header __P((void)); void vnode_print __P((struct vnode *, struct vnode *)); void vnodemode __P((void)); @@ -240,8 +245,6 @@ main(argc, argv) int argc; char *argv[]; { - extern char *optarg; - extern int optind; int ch, i, quit, ret; int fileflag, swapflag, ttyflag, vnodeflag; char buf[_POSIX2_LINE_MAX],*opts; @@ -257,10 +260,10 @@ main(argc, argv) if (!strcmp(opts,"swapinfo")) { swapflag = 1; opts = "kM:N:"; - usage = "usage: swapinfo [-k] [-M core] [-N system]\n"; + usagestr = "swapinfo [-k] [-M core] [-N system]"; } else { opts = "TM:N:fiknstv"; - usage = "usage: pstat [-Tfknstv] [-M core] [-N system]\n"; + usagestr = "pstat [-Tfknstv] [-M core] [-N system]"; } while ((ch = getopt(argc, argv, opts)) != -1) @@ -294,8 +297,7 @@ main(argc, argv) vnodeflag = 1; break; default: - (void)fprintf(stderr, usage); - exit(1); + usage(); } argc -= optind; argv += optind; @@ -315,15 +317,13 @@ main(argc, argv) for (i = quit = 0; i <= NLMANDATORY; i++) if (!nl[i].n_value) { quit = 1; - warnx("undefined symbol: %s\n", nl[i].n_name); + warnx("undefined symbol: %s", nl[i].n_name); } if (quit) exit(1); } - if (!(fileflag | vnodeflag | ttyflag | swapflag | totalflag)) { - (void)fprintf(stderr, usage); - exit(1); - } + if (!(fileflag | vnodeflag | ttyflag | swapflag | totalflag)) + usage(); if (fileflag || totalflag) filemode(); if (vnodeflag || totalflag) @@ -335,6 +335,13 @@ main(argc, argv) exit (0); } +static void +usage() +{ + fprintf(stderr, "usage: %s\n", usagestr); + exit (1); +} + struct e_vnode { struct vnode *avnode; struct vnode vnode; @@ -603,7 +610,7 @@ getmnt(maddr) if (maddr == mt->maddr) return (&mt->mount); if ((mt = malloc(sizeof(struct mtab))) == NULL) - err(1, NULL); + errx(1, "malloc"); KGETRET(maddr, &mt->mount, sizeof(struct mount), "mount table"); mt->maddr = maddr; mt->next = mhead; @@ -621,7 +628,7 @@ mount_print(mp) #define ST mp->mnt_stat (void)printf("*** MOUNT %s %s on %s", ST.f_fstypename, ST.f_mntfromname, ST.f_mntonname); - if (flags = mp->mnt_flag) { + if ((flags = mp->mnt_flag)) { int i; const char *sep = " ("; @@ -659,7 +666,7 @@ loadvnodes(avnodes) if (sysctl(mib, 2, NULL, ©size, NULL, 0) == -1) err(1, "sysctl: KERN_VNODE"); if ((vnodebase = malloc(copysize)) == NULL) - err(1, NULL); + errx(1, "malloc"); if (sysctl(mib, 2, vnodebase, ©size, NULL, 0) == -1) err(1, "sysctl: KERN_VNODE"); if (copysize % sizeof(struct e_vnode)) @@ -687,7 +694,7 @@ kinfo_vnodes(avnodes) KGET(V_NUMV, numvnodes); if ((vbuf = malloc((numvnodes + 20) * (VPTRSZ + VNODESZ))) == NULL) - err(1, NULL); + errx(1, "malloc"); bp = vbuf; evbuf = vbuf + (numvnodes + 20) * (VPTRSZ + VNODESZ); KGET(V_MOUNTLIST, mountlist); @@ -723,7 +730,7 @@ ttymode() struct tty *tty; if ((tty = malloc(ttyspace * sizeof(*tty))) == NULL) - err(1, NULL); + errx(1, "malloc"); #if !defined(hp300) && !defined(mips) if (nl[SCONS].n_type != 0) { (void)printf("1 console\n"); @@ -799,7 +806,7 @@ ttytype(tty, name, type, number, indir) if (ntty > ttyspace) { ttyspace = ntty; if ((tty = realloc(tty, ttyspace * sizeof(*tty))) == 0) - err(1, NULL); + errx(1, "realloc"); } if (indir) { KGET(type, ttyaddr); @@ -990,7 +997,7 @@ getfiles(abuf, alen) * Add emulation of KINFO_FILE here. */ if (memf != NULL) - errx(1, "files on dead kernel, not implemented\n"); + errx(1, "files on dead kernel, not implemented"); mib[0] = CTL_KERN; mib[1] = KERN_FILE; @@ -999,7 +1006,7 @@ getfiles(abuf, alen) return (-1); } if ((buf = malloc(len)) == NULL) - err(1, NULL); + errx(1, "malloc"); if (sysctl(mib, 2, buf, &len, NULL, 0) == -1) { warn("sysctl: KERN_FILE"); return (-1); @@ -1032,7 +1039,7 @@ swapmode() KGET1(VM_SWAPLIST, &swaplist, sizeof swaplist, "swaplist"); if ((sw = malloc(nswdev * sizeof(*sw))) == NULL || (perdev = malloc(nswdev * sizeof(*perdev))) == NULL) - err(1, "malloc"); + errx(1, "malloc"); KGET1(VM_SWDEVT, &ptr, sizeof ptr, "swdevt"); KGET2(ptr, sw, nswdev * sizeof(*sw), "*swdevt"); |