From c94b8307dba518acaa7da47985cd51401d5e495f Mon Sep 17 00:00:00 2001 From: Dmitry Morozovsky Date: Sat, 21 Jun 2008 15:04:42 +0000 Subject: [PATCH] Add -v (verbose) option to -l command, to show size and backing store of all md devices at one time. Approved by: phk MFC after: 2 weeks --- sbin/mdconfig/mdconfig.8 | 6 +++++- sbin/mdconfig/mdconfig.c | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sbin/mdconfig/mdconfig.8 b/sbin/mdconfig/mdconfig.8 index ba79b34d1371..28c17c5de9d0 100644 --- a/sbin/mdconfig/mdconfig.8 +++ b/sbin/mdconfig/mdconfig.8 @@ -41,7 +41,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 28, 2007 +.Dd June 21, 2008 .Dt MDCONFIG 8 .Os .Sh NAME @@ -65,6 +65,7 @@ .Nm .Fl l .Op Fl n +.Op Fl v .Op Fl u Ar unit .Sh DESCRIPTION The @@ -119,6 +120,9 @@ List configured devices. If given with .Fl u , display details about that particular device. +If +.Fl v +option specified, show all details. .It Fl n When printing md device names, print only the unit number without the md prefix. diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index 9142b477d505..d1abf6800fa3 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -59,7 +59,7 @@ usage() " [-s size] [-S sectorsize] [-u unit]\n" " [-x sectors/track] [-y heads/cyl]\n" " mdconfig -d -u unit\n" -" mdconfig -l [-n] [-u unit]\n"); +" mdconfig -l [-v] [-n] [-u unit]\n"); fprintf(stderr, "\t\ttype = {malloc, preload, vnode, swap}\n"); fprintf(stderr, "\t\toption = {cluster, compress, reserve}\n"); fprintf(stderr, "\t\tsize = %%d (512 byte blocks), %%db (B),\n"); @@ -71,7 +71,7 @@ usage() int main(int argc, char **argv) { - int ch, fd, i; + int ch, fd, i, vflag; char *p; int cmdline = 0; char *mdunit; @@ -80,9 +80,10 @@ main(int argc, char **argv) mdio.md_file = malloc(PATH_MAX); if (mdio.md_file == NULL) err(1, "could not allocate memory"); + vflag = 0; bzero(mdio.md_file, PATH_MAX); for (;;) { - ch = getopt(argc, argv, "ab:df:lno:s:S:t:u:x:y:"); + ch = getopt(argc, argv, "ab:df:lno:s:S:t:u:vx:y:"); if (ch == -1) break; switch (ch) { @@ -237,6 +238,11 @@ main(int argc, char **argv) mdunit = optarg; mdio.md_options &= ~MD_AUTOUNIT; break; + case 'v': + if (cmdline != 3) + usage(); + vflag = OPT_VERBOSE; + break; case 'x': if (cmdline != 2) usage(); @@ -282,7 +288,7 @@ main(int argc, char **argv) * Listing all devices. This is why we pass NULL * together with OPT_LIST. */ - md_list(NULL, OPT_LIST); + md_list(NULL, OPT_LIST | vflag); } else { return (md_query(mdunit)); } @@ -373,13 +379,13 @@ md_list(char *units, int opt) } } opt |= OPT_DONE; - if (opt & OPT_LIST) + if ((opt & OPT_LIST) && !(opt & OPT_VERBOSE)) printf(" "); else printf("\n"); } } - if ((opt & OPT_LIST) && (opt & OPT_DONE)) + if ((opt & OPT_LIST) && (opt & OPT_DONE) && !(opt & OPT_VERBOSE)) printf("\n"); /* XXX: Check if it's enough to clean everything. */ geom_stats_snapshot_free(sq);