Rework use of Nm.

Remove -? flag that was not working but documented. Make it work instead
but hide it in man page and usage string as others tools do.
Spelling.
Abort on allocation failure (with errx()).
This commit is contained in:
Philippe Charnier 2000-01-23 20:19:34 +00:00
parent e2b7d85745
commit 5d4a8fa90e
2 changed files with 39 additions and 31 deletions

View File

@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@ -59,6 +57,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)iostat.8 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
.Dd December 22, 1997
.Dt IOSTAT 8
@ -70,7 +69,7 @@
statistics
.Sh SYNOPSIS
.Nm iostat
.Op Fl CdhKIoT?
.Op Fl CdhKIoT
.Op Fl c Ar count
.Op Fl M Ar core
.Op Fl n Ar devs
@ -123,16 +122,16 @@ instead of the default
Display up to
.Ar devs
number of devices.
.Nm iostat
.Nm Iostat
will display fewer devices if there aren't
.Ar devs
devices present.
.It Fl N
Extract the name list from the specified system instead of the default
.Dq Pa /kernel .
.Pa /kernel .
.It Fl o
Display old-style
.Nm iostat
.Nm
device statistics. Sectors per second, transfers per second, and miliseconds
per seek are displayed. If
.Fl I
@ -203,7 +202,7 @@ all devices in the system are compared. Any device that fully matches
any
.Fl t
argument will be included in the
.Nm iostat
.Nm
output, up to the number of devices that can be displayed in
80 columns, or the maximum number of devices specified by the user.
.It Fl T
@ -217,8 +216,6 @@ seconds between each display.
If no repeat
.Ar count
is specified, the default is infinity.
.It Fl ?
Display a usage statement and exit.
.El
.Pp
.Nm Iostat
@ -233,27 +230,28 @@ characters written to terminals
.El
.It devices
Device operations. The header of the field is the device name and unit number.
.Nm iostat
.Nm Iostat
will display as many devices as will fit in a standard 80 column screen, or
the maximum number of devices in the system, whichever is smaller. If
.Fl n
is specified on the command line, iostat will display the smaller of the
requested number of devices, and the maximum number of devices in the system.
To force
.Nm iostat
.Nm
to display specific drives, their names may be supplied on the command
line.
.Nm iostat
.Nm Iostat
will not display more devices than will fit in an 80 column screen, unless
the
.Fl n
argument is given on the command line to specify a maximum number of
devices to display. If fewer devices are specified on the command line
than will fit in an 80 column screen, iostat will show only the specified
devices.
than will fit in an 80 column screen,
.Nm
will show only the specified devices.
.Pp
The standard
.Nm iostat
.Nm
device display shows the following statistics:
.Pp
.Bl -tag -width indent -compact
@ -266,7 +264,7 @@ megabytes per second
.El
.Pp
The standard
.Nm iostat
.Nm
device display, with the
.Fl I
flag specified, shows the following statistics:
@ -281,7 +279,7 @@ total number of megabytes transferred
.El
.Pp
The old-style
.Nm iostat
.Nm
display (using
.Fl o )
shows the following statistics:
@ -296,7 +294,7 @@ average milliseconds per transaction
.El
.Pp
The old-style
.Nm iostat
.Nm
display, with the
.Fl I
flag specified, shows the following statistics:
@ -326,9 +324,9 @@ average milliseconds per transaction
.Sh FILES
.Bl -tag -width /dev/kmem -compact
.It Pa /kernel
Default kernel namelist.
default kernel namelist
.It Pa /dev/kmem
Default memory file.
default memory file
.El
.Sh EXAMPLES
.Dl iostat -w 1 da0 da1 cd0
@ -353,7 +351,7 @@ to either Direct Access or CDROM devices.
.Pp
.Dl iostat -h -n 8 -w 1
.Pp
Display up to 8 devices with the most I/O every second ad inifitum.
Display up to 8 devices with the most I/O every second ad infinitum.
.Pp
.Dl iostat -dh -t da -w 1
.Pp
@ -387,7 +385,7 @@ The sections starting with ``Interpreting system activity'' in
.%T "Installing and Operating 4.3BSD" .
.Sh HISTORY
This version of
.Nm iostat
.Nm
first appeared in
.Fx 3.0 .
.Sh BUGS

View File

@ -24,8 +24,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Parts of this program are derived from the original FreeBSD iostat
@ -99,6 +97,10 @@
* SUCH DAMAGE.
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/types.h>
@ -155,9 +157,10 @@ usage(void)
* This isn't mentioned in the man page, or the usage statement,
* but it is supported.
*/
fprintf(stderr, "usage: iostat [-CdhIKoT?] [-c count] [-M core]"
" [-n devs] [-N system]\n"
"\t [-t type,if,pass] [-w wait] [drives]\n");
fprintf(stderr, "%s\n%s\n",
"usage: iostat [-CdhIKoT] [-c count] [-M core] [-n devs] [-N system]",
" [-t type,if,pass] [-w wait] [drives]");
exit(1);
}
int
@ -171,7 +174,6 @@ main(int argc, char **argv)
struct devstat_match *matches;
int num_matches = 0;
char errbuf[_POSIX2_LINE_MAX];
char *err_str;
kvm_t *kd;
int hz, stathz;
int headercount;
@ -185,7 +187,7 @@ main(int argc, char **argv)
matches = NULL;
maxshowdevs = 3;
while ((c = getopt(argc, argv, "c:CdhIKM:n:N:ot:Tw:?")) != -1) {
while ((c = getopt(argc, argv, "c:CdhIKM:n:N:ot:Tw:")) != -1) {
switch(c) {
case 'c':
cflag++;
@ -215,7 +217,7 @@ main(int argc, char **argv)
nflag++;
maxshowdevs = atoi(optarg);
if (maxshowdevs < 0)
errx(1, "number of devcies %d is < 0",
errx(1, "number of devices %d is < 0",
maxshowdevs);
break;
case 'N':
@ -239,9 +241,9 @@ main(int argc, char **argv)
if (waittime < 1)
errx(1, "wait time is < 1");
break;
case '?':
default:
usage();
exit(1);
break;
}
}
@ -288,7 +290,11 @@ main(int argc, char **argv)
err(1, "can't get number of devices");
cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
if (cur.dinfo == NULL)
errx(1, "malloc failed");
last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
if (last.dinfo == NULL)
errx(1, "malloc failed");
bzero(cur.dinfo, sizeof(struct devinfo));
bzero(last.dinfo, sizeof(struct devinfo));
@ -308,6 +314,8 @@ main(int argc, char **argv)
* they are in the list of devices we have now.
*/
specified_devices = (char **)malloc(sizeof(char *));
if (specified_devices == NULL)
errx(1, "malloc failed");
for (num_devices_specified = 0; *argv; ++argv) {
if (isdigit(**argv))
break;
@ -315,6 +323,8 @@ main(int argc, char **argv)
specified_devices = (char **)realloc(specified_devices,
sizeof(char *) *
num_devices_specified);
if (specified_devices == NULL)
errx(1, "malloc failed");
specified_devices[num_devices_specified - 1] = *argv;
}