From nobody Tue Mar 19 06:55:37 2024 X-Original-To: dev-commits-src-branches@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 4TzMtf182cz5Dh8l; Tue, 19 Mar 2024 06:55:38 +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 4TzMtf0dbpz4DVD; Tue, 19 Mar 2024 06:55:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710831338; 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=Je0Id6lOrvGyDgiiZRFwPRkD5Ut1H9XZ2AqMAtCAoK0=; b=bDi725sIZdbrOWs3mhaUBU/l425HP0dZEziUmKPNXuio4D2iHW8ThkDggPBk0daqe/Y9KE shfPHmtNw3nSF000tCnjXpgsUWIfixyKrqWTDk7dPPLxXDBmYES6LEiZ551bgjOKtQ5Ny6 YhZwNgO9q1wVsZl2QzwOlzxvDQndRPq2OQaJBlH+Oz2c6ee/lFsJwrEx9AQ151uYkTLY0a szjnCgTHbariZfLN+r+7YTDmu5xMIqBfi9FQndMeia7O3jEOPaSzOYNlb8DfM4s7vZfoc2 DpWX+JtB7sRo2zv6ltY70K4lk7jTvlhGLmcJRiolFdJXCj4UiihYxq62PxDegw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710831338; a=rsa-sha256; cv=none; b=h6tmS6lUmgibP7XgIG/glpOkAAQ6MWVnXz4v0nF01buyLOhEtlqXZ5maroe5aCqx6+uT61 MMB9SH3C3vs5jLRf7He7/dcEQZNaqN5B3aVDQqEIcm0d+uvKTeZ5e4O2APBMoatJN8LDfc 5Z1uWbN0NPgbjWqPLFrGmW+cVrAj2SkP0bp6YNlBLgYrxClyDIkXl3cM51Q6vV+Vk/0QYM QkkvetuogBPrkfm0WePp4amIj8ekDm08meVHvMAMuqrsH95mJFIYubVyrnf5aKEgOGhECr cBG3CEPYK3yICEZneHPiE3Ahz4Amyd8DZkRlq107eZ/QCHCh+jCuouBPuFKJ1Q== 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=1710831338; 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=Je0Id6lOrvGyDgiiZRFwPRkD5Ut1H9XZ2AqMAtCAoK0=; b=rTOEjxh0t07Q7qSbBkIYaUHbX1jJeG61HFZwZtV+uln5b4ti2GeOO5qff2tCEvKuyUunET MHvdzISJ/CvU0orjB0sQ3eNwnCCkUvbyOYM+Yhn9wyYEHWo3mO2mVbHUMrKWL2QVq7yJ2n lS52itMrbOWnOZNsL06WkLj9q7Y9E4MR48hlOTePnoxxtyw7z5tw7f4b9gyENtMCEZ2T7I 4vF5dRMa+vLKla9AXEUEHxtFg7+/JgDKN46NqfIHA6JkgZJNN12enl/DTY+zEM69TLusVT GJuKCR8YaUPg50L6QG686j5CAkyc0esQOog6aSKYHz0+LwcFj6GVHWyjDyHimw== 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 4TzMtd6vhVzx9Q; Tue, 19 Mar 2024 06:55:37 +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 42J6tbj1023968; Tue, 19 Mar 2024 06:55:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42J6tbH4023965; Tue, 19 Mar 2024 06:55:37 GMT (envelope-from git) Date: Tue, 19 Mar 2024 06:55:37 GMT Message-Id: <202403190655.42J6tbH4023965@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Eugene Grosbein Subject: git: 947d9b023137 - stable/14 - MFC: diskinfo(8): introduce new option -l List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 947d9b023137c18d9982509a6575310ea99b2b70 Auto-Submitted: auto-generated The branch stable/14 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=947d9b023137c18d9982509a6575310ea99b2b70 commit 947d9b023137c18d9982509a6575310ea99b2b70 Author: Eugene Grosbein AuthorDate: 2024-03-05 17:23:41 +0000 Commit: Eugene Grosbein CommitDate: 2024-03-19 06:54:18 +0000 MFC: diskinfo(8): introduce new option -l In modes -p or -s, add an option -l to start each line with a device name separated with a tab. Update the manual page. Add an example to list names with corresponding serial numbers: diskinfo -ls /dev/da? (cherry picked from commit e333110d1de748e50051d1305b5438d1bc54eeb4) --- usr.sbin/diskinfo/diskinfo.8 | 23 ++++++++++++++++++++--- usr.sbin/diskinfo/diskinfo.c | 15 ++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/usr.sbin/diskinfo/diskinfo.8 b/usr.sbin/diskinfo/diskinfo.8 index 72fd1df4eb08..970bafd4f8e5 100644 --- a/usr.sbin/diskinfo/diskinfo.8 +++ b/usr.sbin/diskinfo/diskinfo.8 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd July 4, 2017 +.Dd March 5, 2024 .Dt DISKINFO 8 .Os .Sh NAME @@ -38,10 +38,12 @@ .Op Fl citSvw .Ar disk ... .Nm -.Op Fl p +.Op Fl l +.Fl p .Ar disk ... .Nm -.Op Fl s +.Op Fl l +.Fl s .Ar disk ... .Sh DESCRIPTION The @@ -57,6 +59,13 @@ Print fields one per line with a descriptive comment. Perform a simple measurement of the I/O read command overhead. .It Fl i Perform a simple IOPS benchmark. +.It Fl l +In case of +.Fl p +or +.Fl s +modes prepend each line of an output with a device name using a tab +character as a separator. .It Fl p Return the physical path of the disk. This is a string that identifies the physical path to the disk in the @@ -80,6 +89,14 @@ with the following fields: device name, sectorsize, media size in bytes, media size in sectors, stripe size, stripe offset, firmware cylinders, firmware heads, and firmware sectors. The last three fields are only present if the information is available. +.Sh EXAMPLES +List first ten (at most) +.Xr da 4 +devices with corresponding serial numbers: +.Pp +.Dl diskinfo -ls /dev/da? +.Sh SEE ALSO +.Xr da 4 .Sh HISTORY The .Nm diff --git a/usr.sbin/diskinfo/diskinfo.c b/usr.sbin/diskinfo/diskinfo.c index 4cc4517a1f26..f091d0ccfbea 100644 --- a/usr.sbin/diskinfo/diskinfo.c +++ b/usr.sbin/diskinfo/diskinfo.c @@ -58,11 +58,14 @@ static void usage(void) { - fprintf(stderr, "usage: diskinfo [-cipsStvw] disk ...\n"); + fprintf(stderr, "usage: diskinfo [-ciStvw] disk ...\n" + " diskinfo [-l] -p disk ...\n" + " diskinfo [-l] -s disk ...\n" + ); exit (1); } -static int opt_c, opt_i, opt_p, opt_s, opt_S, opt_t, opt_v, opt_w; +static int opt_c, opt_i, opt_l, opt_p, opt_s, opt_S, opt_t, opt_v, opt_w; static bool candelete(int fd); static void speeddisk(int fd, off_t mediasize, u_int sectorsize); @@ -88,7 +91,7 @@ main(int argc, char **argv) u_int sectorsize, fwsectors, fwheads, zoned = 0, isreg; uint32_t zone_mode; - while ((ch = getopt(argc, argv, "cipsStvw")) != -1) { + while ((ch = getopt(argc, argv, "cilpsStvw")) != -1) { switch (ch) { case 'c': opt_c = 1; @@ -98,6 +101,9 @@ main(int argc, char **argv) opt_i = 1; opt_v = 1; break; + case 'l': + opt_l = 1; + break; case 'p': opt_p = 1; break; @@ -169,6 +175,9 @@ main(int argc, char **argv) goto out; } } else { + if (opt_l && (opt_p || opt_s)) { + printf("%s\t", argv[i]); + } if (opt_p) { if (ioctl(fd, DIOCGPHYSPATH, physpath) == 0) { printf("%s\n", physpath);