From nobody Mon Jan 5 14:44:59 2026 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 4dlHBz5pp1z6MbKG for ; Mon, 05 Jan 2026 14:44:59 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dlHBz4w1yz3fYx for ; Mon, 05 Jan 2026 14:44:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767624299; 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=+9XdWutARWWuj1UuJWE50IVS1HcGxQL81wdfmAlyncQ=; b=xO6zQsCefHkoR0Kxrw5FG0nskW3VYATuMao6GAVw6z3dqv0WejCESu/aO4+l4+isrclbNj q5xkbKCpE23XENoK6rujMGlwQduLGzZb91DrXfi0dW9r/wmfOPLG6gb4iPazqD5jBfiLCy uuHWxnh16+tDN76P4CRu1gR0iN3N/EYZxNuGryggmRoP4V4Gj1Qnr4N/UYaymcXXup98el 6xPrFtmivmEbSqZwPN3iR1bfaFqzLAS6OGGtqhJDELPzewe9+gLrZoyjwFruAGyEgqwa5o eHkCiBISG9l05BZFnZkPafrPUH83ic6NgLBClNWY605BVNja8DibYKYbeoVNKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767624299; 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=+9XdWutARWWuj1UuJWE50IVS1HcGxQL81wdfmAlyncQ=; b=M6iWEDJRNRcjeqsjmgyKkJCDU+s/mUrLe/YUQfyuR1D7XUv/doE37pf8S2LbX/StjNcYBw 1yT7VOXUU7e9XKaJVaJ+A/+W1bWjjXrnvP6aWkvGMRnixPgjY9GC+DiZUBOV/3jKGy7UtE DHzEstvXdU50jz1laMRP6/055Wtbh4p81hEpI8L/25VhVOTSxaR/gtfVUYIrZvHRW7MmW3 3Om64TfPkFhaRPl6qnYp6UDkGo7d6KMcLtHUTZnvZVjmn6p7EP25DSl7Br7Knbdp14TIUe F1Nyst671yfm7D3/2tSkUQlzPfDsZfEaFuZVXLDtqevhFD4xKHxaYUpMQi+uCA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767624299; a=rsa-sha256; cv=none; b=kIG2fL3oPNbJqhOUbU5fw/R/JO2AQEgWK8GBlme9663yHZyJtfFN/zoWzOI/L4CNwSTTrD 5fLo8MS5W5x3OQ7B+3W0m+Bd/uru49+kvNh+WyH2Qgror+6Vj/QUuGo+6jTYfOMBnxw8Cn dzU5sRdA7vZ+Ddt5j7HVajMcXJ7K7D60ve+9VK6b+nshuiJwkx4464ouzJr2KVo1cxAlW4 ABCMnx3v13ETFd4DSMbL6i49zzc3TSQWwpF395So9zTjs/8Ln8a77d1fyGHXwdO/aadreI EERLdNjhSh9qHSLFTVbJNlAzZK/poPlfUMHfTjjLtUApR6/Ghzi5JV23MgspzQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dlHBz426Hz8sf for ; Mon, 05 Jan 2026 14:44:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 47643 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 05 Jan 2026 14:44:59 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Johan=?utf-8?Q? S=C3=B6llv?=ander Subject: git: 24808463c1f3 - stable/15 - gpart: add libxo support for "show" subcommand + man page updates 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: js X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 24808463c1f3514a53e20b7c99c2df50b48c4a47 Auto-Submitted: auto-generated Date: Mon, 05 Jan 2026 14:44:59 +0000 Message-Id: <695bce6b.47643.1a59956a@gitrepo.freebsd.org> The branch stable/15 has been updated by js: URL: https://cgit.FreeBSD.org/src/commit/?id=24808463c1f3514a53e20b7c99c2df50b48c4a47 commit 24808463c1f3514a53e20b7c99c2df50b48c4a47 Author: Johan Söllvander AuthorDate: 2025-12-18 15:06:09 +0000 Commit: Johan Söllvander CommitDate: 2026-01-05 14:40:49 +0000 gpart: add libxo support for "show" subcommand + man page updates Added libxo support to `gpart show`, also updated the man pages for geom and gpart to show where you can expect libxo formatted output. PR: 290629 Sponsored by: ConnectWise Reviewed by: asomers, mckusick, phil Approved by: asomers (mentor) Differential Revision: https://reviews.freebsd.org/D53950 (cherry picked from commit 4f809ffec69cd6ede3e7be9a5bc876b2e5931028) geom_part: Fix format string issues This fixes a segfault on i386 and armv7 and numerous style violations. PR: 292008 Fixes: 4f809ffec69c ("gpart: add libxo support for "show" subcommand + man page updates") Reviewed by: js Differential Revision: https://reviews.freebsd.org/D54393 (cherry picked from commit faff7013187b03f4240af6f52f608e7ebafe19f3) --- lib/geom/part/Makefile | 2 +- lib/geom/part/geom_part.c | 107 +++++++++++++++++++++++++++++++--------------- lib/geom/part/gpart.8 | 11 ++++- sbin/geom/core/geom.8 | 12 +++++- 4 files changed, 95 insertions(+), 37 deletions(-) diff --git a/lib/geom/part/Makefile b/lib/geom/part/Makefile index 58390e299d6f..4a273eca3a6d 100644 --- a/lib/geom/part/Makefile +++ b/lib/geom/part/Makefile @@ -2,6 +2,6 @@ PACKAGE=geom GEOM_CLASS= part -LIBADD= util +LIBADD= util xo .include diff --git a/lib/geom/part/geom_part.c b/lib/geom/part/geom_part.c index cbbc81d3cc60..852eec2d790a 100644 --- a/lib/geom/part/geom_part.c +++ b/lib/geom/part/geom_part.c @@ -47,6 +47,8 @@ #include #include +#include + #include "core/geom.h" #include "misc/subr.h" @@ -77,7 +79,6 @@ static int geom_is_withered(struct ggeom *); static const char *find_geomcfg(struct ggeom *, const char *); static const char *find_provcfg(struct gprovider *, const char *); static struct gprovider *find_provider(struct ggeom *, off_t); -static const char *fmtsize(int64_t); static int gpart_autofill(struct gctl_req *); static int gpart_autofill_resize(struct gctl_req *); static void gpart_bootcode(struct gctl_req *, unsigned int); @@ -283,16 +284,6 @@ find_provider(struct ggeom *gp, off_t minsector) return (bestpp); } -static const char * -fmtsize(int64_t rawsz) -{ - static char buf[5]; - - humanize_number(buf, sizeof(buf), rawsz, "", HN_AUTOSCALE, - HN_B | HN_NOSPACE | HN_DECIMAL); - return (buf); -} - static const char * fmtattrib(struct gprovider *pp) { @@ -622,6 +613,7 @@ static void gpart_show_geom(struct ggeom *gp, const char *element, int show_providers) { struct gprovider *pp; + struct gconfig *gc; const char *s, *scheme; off_t first, last, sector, end; off_t length, secsz; @@ -659,12 +651,15 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers) wname = wmax; pp = LIST_FIRST(&gp->lg_consumer)->lg_provider; secsz = pp->lg_sectorsize; - printf("=>%*jd %*jd %*s %s (%s)%s\n", + xo_open_instance("part"); + xo_emit("=>{t:start/%*jd} {t:sectors/%*jd} " + "{t:name/%*s} {:scheme} ({h:size/%jd})" + "{t:state}\n", wblocks, (intmax_t)first, wblocks, (intmax_t)(last - first + 1), - wname, gp->lg_name, - scheme, fmtsize(pp->lg_mediasize), + wname, gp->lg_name, scheme, (intmax_t)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 +671,75 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers) s = find_provcfg(pp, "index"); idx = atoi(s); if (first < sector) { - printf(" %*jd %*jd %*s - free - (%s)\n", - wblocks, (intmax_t)first, wblocks, - (intmax_t)(sector - first), wname, "", - fmtsize((sector - first) * secsz)); + xo_open_instance(s); + xo_emit(" {t:start/%*jd} " + "{t:sectors/%*jd} " + "{P:/%*s} " + "{ne:free}- free - ({h:size/%jd})\n", + wblocks, (intmax_t)first, + wblocks, (intmax_t)(sector - first), + wname, "", + "true", (intmax_t)(sector - first) * secsz); + xo_close_instance(s); } + xo_open_instance(s); + xo_emit(" {t:start/%*jd} {t:sectors/%*jd}", + wblocks, (intmax_t)sector, wblocks, (intmax_t)length); 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)); + xo_emit(" {t:name/%*s}{e:index/%d}", + wname, pp->lg_name, idx); + } else { + xo_emit(" {t:index/%*d}{e:name}", + wname, idx, pp->lg_name); + } + + if (strcmp(element, "label") == 0) { + xo_emit(" {:label}{e:type}{e:rawtype}", + find_provcfg(pp, element), + find_provcfg(pp, "type"), + find_provcfg(pp, "rawtype")); + } else if (strcmp(element, "type") == 0) { + xo_emit(" {:type}{e:label}{e:rawtype}", + find_provcfg(pp, element), + find_provcfg(pp, "label"), + find_provcfg(pp, "rawtype")); + } else { + xo_emit(" {:rawtype}{e:type}{e:label}", + find_provcfg(pp, element), + find_provcfg(pp, "type"), + find_provcfg(pp, "label")); + } + + idx = 0; + LIST_FOREACH(gc, &pp->lg_config, lg_config) { + if (strcmp(gc->lg_name, "attrib") != 0) + continue; + idx++; + if (idx == 1) + xo_emit(" ["); + else + xo_emit(","); + xo_emit("{l:attribute}", gc->lg_val); + } + if (idx) + xo_emit("]"); + xo_emit(" ({h:size/%jd})\n", (intmax_t)pp->lg_mediasize); + xo_close_instance(s); first = end + 1; } + if (first <= last) { + xo_open_instance("unallocated"); length = last - first + 1; - printf(" %*jd %*jd %*s - free - (%s)\n", + xo_emit(" {t:start/%*jd} {t:sectors/%*jd} " + "{P:/%*s} {ne:free}- free - ({h:size/%jd})\n", wblocks, (intmax_t)first, wblocks, (intmax_t)length, - wname, "", - fmtsize(length * secsz)); + wname, "", "true", (intmax_t)length * secsz); + xo_close_instance("unallocated"); } - printf("\n"); + xo_close_list("partitions"); + xo_close_instance("part"); + xo_emit("\n"); } static int @@ -752,6 +789,7 @@ gpart_show(struct gctl_req *req, unsigned int fl __unused) 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 +804,7 @@ gpart_show(struct gctl_req *req, unsigned int fl __unused) gpart_show_geom(gp, element, show_providers); } } + xo_close_list(name); geom_deletetree(&mesh); } @@ -1084,7 +1123,7 @@ gpart_bootfile_read(const char *bootfile, ssize_t *size) if (sb.st_size == 0) errx(EXIT_FAILURE, "%s: empty file", bootfile); if (*size > 0 && sb.st_size > *size) - errx(EXIT_FAILURE, "%s: file too big (%zu limit)", bootfile, + errx(EXIT_FAILURE, "%s: file too big (%zd limit)", bootfile, *size); *size = sb.st_size; diff --git a/lib/geom/part/gpart.8 b/lib/geom/part/gpart.8 index 2e11417f8494..97dd60182435 100644 --- a/lib/geom/part/gpart.8 +++ b/lib/geom/part/gpart.8 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 24, 2025 +.Dd December 4, 2025 .Dt GPART 8 .Os .Sh NAME @@ -112,6 +112,7 @@ .Ar geom .\" ==== SHOW ==== .Nm +.Op Fl -libxo .Cm show .Op Fl l | r .Op Fl p @@ -537,6 +538,13 @@ See .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 @@ -1519,6 +1527,7 @@ for details .El .Sh SEE ALSO .Xr geom 4 , +.Xr xo_options 7 , .Xr boot0cfg 8 , .Xr geom 8 , .Xr glabel 8 , diff --git a/sbin/geom/core/geom.8 b/sbin/geom/core/geom.8 index b864b3b238f5..29c6385da3f7 100644 --- a/sbin/geom/core/geom.8 +++ b/sbin/geom/core/geom.8 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd May 9, 2023 +.Dd December 4, 2025 .Dt GEOM 8 .Os .Sh NAME @@ -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 @@ Print detailed information about the geom which provides .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 @@ -205,6 +214,7 @@ geom md unload .Sh SEE ALSO .Xr libgeom 3 , .Xr geom 4 , +.Xr xo_options 7 , .Xr gcache 8 , .Xr gconcat 8 , .Xr geli 8 ,