Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148890293
D53950.1789100389.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D53950.1789100389.diff
View Options
diff --git a/lib/geom/part/Makefile b/lib/geom/part/Makefile
--- a/lib/geom/part/Makefile
+++ b/lib/geom/part/Makefile
@@ -2,6 +2,6 @@
GEOM_CLASS= part
-LIBADD= util
+LIBADD= util xo
.include <bsd.lib.mk>
diff --git a/lib/geom/part/geom_part.c b/lib/geom/part/geom_part.c
--- a/lib/geom/part/geom_part.c
+++ b/lib/geom/part/geom_part.c
@@ -46,6 +46,7 @@
#include <string.h>
#include <strings.h>
#include <unistd.h>
+#include <libxo/xo.h>
#include "core/geom.h"
#include "misc/subr.h"
@@ -659,12 +660,14 @@
wname = wmax;
pp = LIST_FIRST(&gp->lg_consumer)->lg_provider;
secsz = pp->lg_sectorsize;
- printf("=>%*jd %*jd %*s %s (%s)%s\n",
- wblocks, (intmax_t)first, wblocks, (intmax_t)(last - first + 1),
- wname, gp->lg_name,
- scheme, fmtsize(pp->lg_mediasize),
- s ? " [CORRUPT]": "");
-
+ xo_open_instance("part");
+ xo_emit("=>{t:logical_starting_block/%*jd} {t:size_in_blocks/%*jd} {t:name/%*s} {:scheme} ({:size}){t:state}\n",
+ wblocks, (intmax_t)first, wblocks, (intmax_t)(last - first + 1),
+ wname, gp->lg_name,
+ scheme, fmtsize(pp->lg_mediasize),
+ s ? " [CORRUPT]": "");
+
+ xo_open_list("partitions");
while ((pp = find_provider(gp, first)) != NULL) {
s = find_provcfg(pp, "start");
sector = (off_t)strtoimax(s, NULL, 0);
@@ -676,33 +679,41 @@
s = find_provcfg(pp, "index");
idx = atoi(s);
if (first < sector) {
- printf(" %*jd %*jd %*s - free - (%s)\n",
+ xo_open_instance(s);
+ xo_emit(" {t:logical_starting_block/%*jd} {t:size_in_blocks/%*jd} {P:/%*s} {e:free}- free - ({:size})\n",
wblocks, (intmax_t)first, wblocks,
(intmax_t)(sector - first), wname, "",
- fmtsize((sector - first) * secsz));
+ "true", fmtsize((sector - first) * secsz));
+ xo_close_instance(s);
}
+ xo_open_instance(s);
if (show_providers) {
- printf(" %*jd %*jd %*s %s %s (%s)\n",
+ xo_emit(" {t:logical_starting_block/%*jd} {t:size_in_blocks/%*jd} {t:provider_name/%*s}{e:index/%d} {:type} {:attribute} ({:size})\n",
wblocks, (intmax_t)sector, wblocks,
(intmax_t)length, wname, pp->lg_name,
- find_provcfg(pp, element), fmtattrib(pp),
- fmtsize(pp->lg_mediasize));
+ idx, find_provcfg(pp, element),
+ fmtattrib(pp), fmtsize(pp->lg_mediasize));
} else
- printf(" %*jd %*jd %*d %s %s (%s)\n",
+ xo_emit(" {t:logical_starting_block/%*jd} {t:size_in_blocks/%*jd} {t:index/%*d}{e:provider_name} {:type} {:attribute} ({:size})\n",
wblocks, (intmax_t)sector, wblocks,
- (intmax_t)length, wname, idx,
+ (intmax_t)length, wname, idx, pp->lg_name,
find_provcfg(pp, element), fmtattrib(pp),
fmtsize(pp->lg_mediasize));
+ xo_close_instance(s);
first = end + 1;
}
+ xo_close_list("partitions");
+
if (first <= last) {
+ xo_open_container("unallocated");
length = last - first + 1;
- printf(" %*jd %*jd %*s - free - (%s)\n",
+ xo_emit(" {t:logical_starting_block/%*jd} {t:size_in_blocks/%*jd} {P:/%*s} - free - ({:size})\n",
wblocks, (intmax_t)first, wblocks, (intmax_t)length,
- wname, "",
- fmtsize(length * secsz));
+ wname, "", fmtsize(length * secsz));
+ xo_close_container("unallocated");
}
- printf("\n");
+ xo_close_instance("part");
+ xo_emit("\n");
}
static int
@@ -752,6 +763,7 @@
errx(EXIT_FAILURE, "Class %s not found.", name);
}
show_providers = gctl_get_int(req, "show_providers");
+ xo_open_list(name);
if (nargs > 0) {
for (i = 0; i < nargs; i++) {
name = gctl_get_ascii(req, "arg%d", i);
@@ -766,6 +778,7 @@
gpart_show_geom(gp, element, show_providers);
}
}
+ xo_close_list(name);
geom_deletetree(&mesh);
}
diff --git a/lib/geom/part/gpart.8 b/lib/geom/part/gpart.8
--- a/lib/geom/part/gpart.8
+++ b/lib/geom/part/gpart.8
@@ -112,6 +112,7 @@
.Ar geom
.\" ==== SHOW ====
.Nm
+.Op Fl -libxo
.Cm show
.Op Fl l | r
.Op Fl p
@@ -537,6 +538,13 @@
.It Cm unload
See
.Xr geom 8 .
+.It Fl -libxo
+Generate output via
+.Xr libxo 3
+in a selection of different human and machine readable formats.
+See
+.Xr xo_options 7
+for details on command line arguments.
.El
.Sh PARTITIONING SCHEMES
Several partitioning schemes are supported by the
diff --git a/sbin/geom/core/geom.8 b/sbin/geom/core/geom.8
--- a/sbin/geom/core/geom.8
+++ b/sbin/geom/core/geom.8
@@ -36,11 +36,13 @@
.Ar class
.Cm help
.Nm
+.Op Fl -libxo
.Ar class
.Cm list
.Op Fl a
.Op Ar name ...
.Nm
+.Op Fl -libxo
.Ar class
.Cm status
.Op Fl ags
@@ -118,6 +120,13 @@
.Ar provider-name .
.It Fl t
Display geoms hierarchy as a tree.
+.It Fl -libxo
+Generate output via
+.Xr libxo 3
+in a selection of different human and machine readable formats.
+See
+.Xr xo_options 7
+for details on command line arguments.
.El
.Pp
Class-specific commands are implemented as shared libraries which
@@ -220,6 +229,8 @@
.Xr gstripe 8 ,
.Xr gunion 8 ,
.Xr gvirstor 8
+.Xr libxo 3 ,
+.Xr xo_options 7 ,
.Sh HISTORY
The
.Nm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Sep 11, 4:19 AM (7 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29549452
Default Alt Text
D53950.1789100389.diff (4 KB)
Attached To
Mode
D53950: Add libxo support to `gpart show` and document libxo flags in geom and gpart man pages
Attached
Detach File
Event Timeline
Log In to Comment