aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2023-08-29 17:23:23 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2023-09-07 20:28:30 +0000
commitcbc42905e5245030920920f4d3fb31d1a5914a6f (patch)
tree23b5680a21d1f721451489c81ab8c7e04a99f2e8
parentf41c23ee5b347c422f79630345af8a22bc9a5190 (diff)
downloadsrc-cbc42905e5245030920920f4d3fb31d1a5914a6f.tar.gz
src-cbc42905e5245030920920f4d3fb31d1a5914a6f.zip
iostat: getopt() / usage() cleanup.
MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D41636 (cherry picked from commit 09c45b089d2f90ec04153a1b4621dd6bec142959) Approved by: re (gjb)
-rw-r--r--usr.sbin/iostat/iostat.840
-rw-r--r--usr.sbin/iostat/iostat.c24
2 files changed, 31 insertions, 33 deletions
diff --git a/usr.sbin/iostat/iostat.8 b/usr.sbin/iostat/iostat.8
index 17b73f0932c7..863f8ab8466c 100644
--- a/usr.sbin/iostat/iostat.8
+++ b/usr.sbin/iostat/iostat.8
@@ -54,7 +54,7 @@
.\"
.\" @(#)iostat.8 8.1 (Berkeley) 6/6/93
.\"
-.Dd May 22, 2015
+.Dd August 29, 2023
.Dt IOSTAT 8
.Os
.Sh NAME
@@ -64,7 +64,7 @@
statistics
.Sh SYNOPSIS
.Nm
-.Op Fl CdhIKoTxz?\&
+.Op Fl CdhIKoTxz
.Op Fl c Ar count
.Op Fl M Ar core
.Op Fl n Ar devs
@@ -90,6 +90,13 @@ averaged over that time.
.Pp
The options are as follows:
.Bl -tag -width flag
+.It Fl C
+Display CPU statistics.
+This is on by default, unless
+.Fl d
+or
+.Fl x
+is specified.
.It Fl c
Repeat the display
.Ar count
@@ -102,13 +109,6 @@ is specified.
With
.Fl w
the default repeat count is infinity, otherwise it is 1.
-.It Fl C
-Display CPU statistics.
-This is on by default, unless
-.Fl d
-or
-.Fl x
-is specified.
.It Fl d
Display only device statistics.
If this flag is turned on, only device statistics will be displayed, unless
@@ -136,6 +136,9 @@ then the device native block size.
Extract values associated with the name list from the specified core
instead of the default
.Dq Pa /dev/kmem .
+.It Fl N
+Extract the name list from the specified system instead of the default
+.Dq Pa /boot/kernel/kernel .
.It Fl n
Display up to
.Ar devs
@@ -145,9 +148,6 @@ The
utility will display fewer devices if there are not
.Ar devs
devices present.
-.It Fl N
-Extract the name list from the specified system instead of the default
-.Dq Pa /boot/kernel/kernel .
.It Fl o
Display old-style
.Nm
@@ -158,6 +158,13 @@ If
.Fl I
is specified, total blocks/sectors, total transfers, and
milliseconds per seek are displayed.
+.It Fl T
+Display TTY statistics.
+This is on by default, unless
+.Fl d
+or
+.Fl x
+is specified.
.It Fl t
Specify which types of devices to display.
There are three different categories of devices:
@@ -228,13 +235,6 @@ argument will be included in the
.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
-Display TTY statistics.
-This is on by default, unless
-.Fl d
-or
-.Fl x
-is specified.
.It Fl w
Pause
.Ar wait
@@ -267,8 +267,6 @@ is also specified to enable the display of CPU or TTY statistics.
If
.Fl x
is specified, omit lines for devices with no activity.
-.It Fl ?\&
-Display a usage statement and exit.
.El
.Pp
The
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index 17013b433917..d4f7a2519a1b 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -168,7 +168,7 @@ usage(void)
* This isn't mentioned in the man page, or the usage statement,
* but it is supported.
*/
- fprintf(stderr, "usage: iostat [-CdhIKoTxz?] [-c count] [-M core]"
+ fprintf(stderr, "usage: iostat [-CdhIKoTxz] [-c count] [-M core]"
" [-n devs] [-N system]\n"
"\t [-t type,if,pass] [-w wait] [drives]\n");
exit(1);
@@ -198,17 +198,17 @@ main(int argc, char **argv)
matches = NULL;
maxshowdevs = 3;
- while ((c = getopt(argc, argv, "c:CdhIKM:n:N:ot:Tw:xz?")) != -1) {
- switch(c) {
+ while ((c = getopt(argc, argv, "Cc:dhIKM:N:n:oTt:w:xz")) != -1) {
+ switch (c) {
+ case 'C':
+ Cflag++;
+ break;
case 'c':
cflag++;
count = atoi(optarg);
if (count < 1)
errx(1, "count %d is < 1", count);
break;
- case 'C':
- Cflag++;
- break;
case 'd':
dflag++;
break;
@@ -224,6 +224,9 @@ main(int argc, char **argv)
case 'M':
memf = optarg;
break;
+ case 'N':
+ nlistf = optarg;
+ break;
case 'n':
nflag++;
maxshowdevs = atoi(optarg);
@@ -231,20 +234,17 @@ main(int argc, char **argv)
errx(1, "number of devices %d is < 0",
maxshowdevs);
break;
- case 'N':
- nlistf = optarg;
- break;
case 'o':
oflag++;
break;
+ case 'T':
+ Tflag++;
+ break;
case 't':
if (devstat_buildmatch(optarg, &matches,
&num_matches) != 0)
errx(1, "%s", devstat_errbuf);
break;
- case 'T':
- Tflag++;
- break;
case 'w':
wflag++;
f = atof(optarg);