summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sbin/geom/class/part/Makefile2
-rw-r--r--sbin/geom/class/part/geom_part.c18
2 files changed, 7 insertions, 13 deletions
diff --git a/sbin/geom/class/part/Makefile b/sbin/geom/class/part/Makefile
index 0588646..3622716 100644
--- a/sbin/geom/class/part/Makefile
+++ b/sbin/geom/class/part/Makefile
@@ -4,6 +4,8 @@
CLASS= part
+LDADD= -lutil
+
WARNS?= 4
.include <bsd.lib.mk>
diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c
index 4264992..c5f8ebb 100644
--- a/sbin/geom/class/part/geom_part.c
+++ b/sbin/geom/class/part/geom_part.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <fcntl.h>
#include <libgeom.h>
+#include <libutil.h>
#include <paths.h>
#include <stdint.h>
#include <stdio.h>
@@ -203,21 +204,12 @@ find_provider(struct ggeom *gp, unsigned long long minsector)
}
static const char *
-fmtsize(long double rawsz)
+fmtsize(int64_t rawsz)
{
- static char buf[32];
- static const char *sfx[] = { "B", "KB", "MB", "GB", "TB" };
- long double sz;
- int sfxidx;
-
- sfxidx = 0;
- sz = (long double)rawsz;
- while (sfxidx < 4 && sz > 1099.0) {
- sz /= 1000;
- sfxidx++;
- }
+ static char buf[5];
- sprintf(buf, "%.1Lf%s", sz, sfx[sfxidx]);
+ humanize_number(buf, sizeof(buf), rawsz, "", HN_AUTOSCALE,
+ HN_B | HN_NOSPACE | HN_DECIMAL);
return (buf);
}
OpenPOWER on IntegriCloud