From nobody Thu Sep 7 20:28:47 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RhW6R4T7cz4sslL; Thu, 7 Sep 2023 20:28:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RhW6R3QtPz4Zpt; Thu, 7 Sep 2023 20:28:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694118527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TcdYLOl9nv2ErV6uHtDE/gWh7ad0RyvtO8Z/QAIHMBU=; b=iLNdppr4W5Uldjr7Rz2WZVv70ukS4G2+KLr5NcqR+nG1MkYDq3kVjcZmCyJHe9lcnBV6mj LwoIchgCTuz7UN5bOpr7Vy5XlLMGWK5eX6fkrMopbLtqRXmLy5C9FEDKj6efw0fXy6Crmf s1dxf9Ul6nzwxYdXLpVs1IluMWKHjwnDczWlqf7eJzWAUZzCVNZ9iAtJhltNNS39tYtKJW 1uvuEOzXf3bwGm2JbbHeQHlvOm9um9/rzkp/ycdvVGoVwq4wdQyrZiGEd1rBbf1YB79uXX uxlwIcZzcDx9Mz2113CQ+jAhUTBXhgQ9q5xJCPhuPlDw3BKezj0WLKSTdofhWQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694118527; a=rsa-sha256; cv=none; b=bZmlwk24q7jn8HtGmXsVGg/h5IYXvW3OtoNFYUkA16e4se1p6hIoqE+WBJpROGKCFGc7+2 dnzjaINO/5tWi8z4G6pNr36Pwk74ImK35KC8byD/TewSM5PI40S31OfXqYNq9M0DuqCdGE ETKjDbuc3xBeDZlLWNVolpf+bFSDeFwHPXLHTxxwvYqWqjfwahBz7Gtv6J+X0X1VcVV0mz uNpx0XbC8lPjQ5iLdUg6XFCqvjxoYGmdRiePhqnD6mWJixxzJFjymk2Vs/zOOOeTMQmKLA ifZSCsFPcDHziVEiJkNiNzzL6MqlvVUsDiqkfBE0YkCX1DB2SdIuLWzOTw4+Zg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694118527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TcdYLOl9nv2ErV6uHtDE/gWh7ad0RyvtO8Z/QAIHMBU=; b=wdZamb+j3Exq6AbeNpjM8s7QJfZhWjX46hgHVDIMyovYVj2WrSOcYI1aRR79zTw8EazFxQ 4auhWvYtJ5Pd64DYEFxToNErEeV/mRl4mxlx+hsATgx0EpCZoB3+CRbNimpejiC0/2I0U7 kmLGZHXJgNjd+pjSCNCMsttr4ufI2V23YH0fOwK+rmT+QWEETSAoB+ys/N/3qY3hx8GLMu HPd2/+83C1yVgP8FmGdblKfZC3HYwSo2w6TXb/evQVGG//pyyRSHLTQhijN1In2l/FTe5a PnqjHVvciStKLYIleBZJsAHizRIdBppO/l7b/9w6Vzed272JAkcAJcbAeIt/Bg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RhW6R2Fpjz57; Thu, 7 Sep 2023 20:28:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 387KSljE064635; Thu, 7 Sep 2023 20:28:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 387KSlIF064632; Thu, 7 Sep 2023 20:28:47 GMT (envelope-from git) Date: Thu, 7 Sep 2023 20:28:47 GMT Message-Id: <202309072028.387KSlIF064632@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: cbc42905e524 - stable/14 - iostat: getopt() / usage() cleanup. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: cbc42905e5245030920920f4d3fb31d1a5914a6f Auto-Submitted: auto-generated The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=cbc42905e5245030920920f4d3fb31d1a5914a6f commit cbc42905e5245030920920f4d3fb31d1a5914a6f Author: Dag-Erling Smørgrav AuthorDate: 2023-08-29 17:23:23 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2023-09-07 20:28:30 +0000 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) --- usr.sbin/iostat/iostat.8 | 40 +++++++++++++++++++--------------------- usr.sbin/iostat/iostat.c | 24 ++++++++++++------------ 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);