git: 0d16792c6e98 - main - geom_part: Restore the human readable format of size
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 20 Apr 2026 17:03:07 UTC
The branch main has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=0d16792c6e983005581ed0176ed81e7302582196
commit 0d16792c6e983005581ed0176ed81e7302582196
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2026-04-20 16:59:59 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2026-04-20 16:59:59 +0000
geom_part: Restore the human readable format of size
Prior to the change 4f809ffec69c, the sizes are formated by
humanize_number(3) with the flag HN_DECIMAL, which displays the result
using one decimal place when it is less than 10. That is more accurate
and useful. Add equivalent field modifier hn-decimal to xo_emit() to
restore the previous behavior.
Reported by: Mark Millard
Reviewed by: js
Fixes: 4f809ffec69c gpart: add libxo support for "show" subcommand + man page updates
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56514
---
lib/geom/part/geom_part.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/geom/part/geom_part.c b/lib/geom/part/geom_part.c
index 852eec2d790a..f5f23443e9f6 100644
--- a/lib/geom/part/geom_part.c
+++ b/lib/geom/part/geom_part.c
@@ -653,7 +653,7 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers)
secsz = pp->lg_sectorsize;
xo_open_instance("part");
xo_emit("=>{t:start/%*jd} {t:sectors/%*jd} "
- "{t:name/%*s} {:scheme} ({h:size/%jd})"
+ "{t:name/%*s} {:scheme} ({h,hn-decimal:size/%jd})"
"{t:state}\n",
wblocks, (intmax_t)first, wblocks, (intmax_t)(last - first + 1),
wname, gp->lg_name, scheme, (intmax_t)pp->lg_mediasize,
@@ -675,7 +675,7 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers)
xo_emit(" {t:start/%*jd} "
"{t:sectors/%*jd} "
"{P:/%*s} "
- "{ne:free}- free - ({h:size/%jd})\n",
+ "{ne:free}- free - ({h,hn-decimal:size/%jd})\n",
wblocks, (intmax_t)first,
wblocks, (intmax_t)(sector - first),
wname, "",
@@ -723,7 +723,7 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers)
}
if (idx)
xo_emit("]");
- xo_emit(" ({h:size/%jd})\n", (intmax_t)pp->lg_mediasize);
+ xo_emit(" ({h,hn-decimal:size/%jd})\n", (intmax_t)pp->lg_mediasize);
xo_close_instance(s);
first = end + 1;
}
@@ -732,7 +732,7 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers)
xo_open_instance("unallocated");
length = last - first + 1;
xo_emit(" {t:start/%*jd} {t:sectors/%*jd} "
- "{P:/%*s} {ne:free}- free - ({h:size/%jd})\n",
+ "{P:/%*s} {ne:free}- free - ({h,hn-decimal:size/%jd})\n",
wblocks, (intmax_t)first, wblocks, (intmax_t)length,
wname, "", "true", (intmax_t)length * secsz);
xo_close_instance("unallocated");