Date: Tue, 22 Mar 2011 05:50:55 +0000 (UTC) From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r219861 - stable/8/sbin/geom/class/part Message-ID: <201103220550.p2M5otlc047106@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ae Date: Tue Mar 22 05:50:55 2011 New Revision: 219861 URL: http://svn.freebsd.org/changeset/base/219861 Log: MFC r219415 (adapted for stable/8): Add -p option to `gpart show` command to show provider's names of partitions instead of partition's indexes. This may be useful with GPT partitioning scheme or EBR without GEOM_PART_EBR_COMPAT option. MFC r219416: It is better to sometimes have not aligned columns than often have wrapped lines. Modified: stable/8/sbin/geom/class/part/geom_part.c stable/8/sbin/geom/class/part/gpart.8 Directory Properties: stable/8/sbin/geom/class/part/ (props changed) Modified: stable/8/sbin/geom/class/part/geom_part.c ============================================================================== --- stable/8/sbin/geom/class/part/geom_part.c Tue Mar 22 05:47:48 2011 (r219860) +++ stable/8/sbin/geom/class/part/geom_part.c Tue Mar 22 05:50:55 2011 (r219861) @@ -83,7 +83,7 @@ static void gpart_bootcode(struct gctl_r static void *gpart_bootfile_read(const char *, ssize_t *); static void gpart_issue(struct gctl_req *, unsigned int); static void gpart_show(struct gctl_req *, unsigned int); -static void gpart_show_geom(struct ggeom *, const char *); +static void gpart_show_geom(struct ggeom *, const char *, int); static int gpart_show_hasopt(struct gctl_req *, const char *, const char *); static void gpart_write_partcode(struct ggeom *, int, void *, ssize_t); static void gpart_write_partcode_vtoc8(struct ggeom *, int, void *); @@ -151,8 +151,9 @@ struct g_command PUBSYM(class_commands)[ { "show", 0, gpart_show, { { 'l', "show_label", NULL, G_TYPE_BOOL }, { 'r', "show_rawtype", NULL, G_TYPE_BOOL }, + { 'p', "show_providers", NULL, G_TYPE_BOOL }, G_OPT_SENTINEL }, - NULL, "[-lr] [geom ...]" + NULL, "[-lrp] [geom ...]" }, { "undo", 0, gpart_issue, G_NULL_OPTS, "geom", NULL }, { "unset", 0, gpart_issue, { @@ -541,13 +542,13 @@ done: } static void -gpart_show_geom(struct ggeom *gp, const char *element) +gpart_show_geom(struct ggeom *gp, const char *element, int show_providers) { struct gprovider *pp; const char *s, *scheme; off_t first, last, sector, end; off_t length, secsz; - int idx, wblocks, wname; + int idx, wblocks, wname, wmax; scheme = find_geomcfg(gp, "scheme"); s = find_geomcfg(gp, "first"); @@ -558,7 +559,15 @@ gpart_show_geom(struct ggeom *gp, const s = find_geomcfg(gp, "state"); if (s != NULL && *s != 'C') s = NULL; - wname = strlen(gp->lg_name); + wmax = strlen(gp->lg_name); + if (show_providers) { + LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { + wname = strlen(pp->lg_name); + if (wname > wmax) + wmax = wname; + } + } + wname = wmax; pp = LIST_FIRST(&gp->lg_consumer)->lg_provider; secsz = pp->lg_sectorsize; printf("=>%*jd %*jd %*s %s (%s)%s\n", @@ -592,10 +601,18 @@ gpart_show_geom(struct ggeom *gp, const (intmax_t)(sector - first), wname, "", fmtsize((sector - first) * secsz)); } - printf(" %*jd %*jd %*d %s %s (%s)\n", - wblocks, (intmax_t)sector, wblocks, (intmax_t)length, - wname, idx, find_provcfg(pp, element), - fmtattrib(pp), fmtsize(pp->lg_mediasize)); + if (show_providers) { + printf(" %*jd %*jd %*s %s %s (%s)\n", + wblocks, (intmax_t)sector, wblocks, + (intmax_t)length, wname, pp->lg_name, + find_provcfg(pp, element), fmtattrib(pp), + fmtsize(pp->lg_mediasize)); + } else + printf(" %*jd %*jd %*d %s %s (%s)\n", + wblocks, (intmax_t)sector, wblocks, + (intmax_t)length, wname, idx, + find_provcfg(pp, element), fmtattrib(pp), + fmtsize(pp->lg_mediasize)); first = end + 1; } if (first <= last) { @@ -628,7 +645,7 @@ gpart_show(struct gctl_req *req, unsigne struct gclass *classp; struct ggeom *gp; const char *element, *name; - int error, i, nargs; + int error, i, nargs, show_providers; element = NULL; if (gpart_show_hasopt(req, "show_label", element)) @@ -649,19 +666,20 @@ gpart_show(struct gctl_req *req, unsigne geom_deletetree(&mesh); errx(EXIT_FAILURE, "Class %s not found.", name); } + show_providers = gctl_get_int(req, "show_providers"); nargs = gctl_get_int(req, "nargs"); if (nargs > 0) { for (i = 0; i < nargs; i++) { name = gctl_get_ascii(req, "arg%d", i); gp = find_geom(classp, name); if (gp != NULL) - gpart_show_geom(gp, element); + gpart_show_geom(gp, element, show_providers); else errx(EXIT_FAILURE, "No such geom: %s.", name); } } else { LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { - gpart_show_geom(gp, element); + gpart_show_geom(gp, element, show_providers); } } geom_deletetree(&mesh); Modified: stable/8/sbin/geom/class/part/gpart.8 ============================================================================== --- stable/8/sbin/geom/class/part/gpart.8 Tue Mar 22 05:47:48 2011 (r219860) +++ stable/8/sbin/geom/class/part/gpart.8 Tue Mar 22 05:50:55 2011 (r219861) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 28, 2011 +.Dd March 9, 2011 .Dt GPART 8 .Os .Sh NAME @@ -162,7 +162,7 @@ utility: .\" ==== SHOW ==== .Nm .Cm show -.Op Fl lr +.Op Fl lrp .Op Ar geom ... .\" ==== UNDO ==== .Nm @@ -468,6 +468,8 @@ Additional options include: .It Fl l For partition schemes that support partition labels print them instead of partition type. +.It Fl p +Show provider names instead of partition indexes. .It Fl r Show raw partition type instead of symbolic name. .El
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103220550.p2M5otlc047106>