aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhenlei Huang <zlei@FreeBSD.org>2026-04-20 16:59:59 +0000
committerZhenlei Huang <zlei@FreeBSD.org>2026-04-20 16:59:59 +0000
commit0d16792c6e983005581ed0176ed81e7302582196 (patch)
tree0c8f3b334bd456b82111ea3a35a688de9a706fb0
parentf49f61f19463c21125bb1215cf8e0530f52953e3 (diff)
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
-rw-r--r--lib/geom/part/geom_part.c8
1 files 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");