diff options
| author | Marcel Moolenaar <marcel@FreeBSD.org> | 2008-11-18 04:04:01 +0000 |
|---|---|---|
| committer | Marcel Moolenaar <marcel@FreeBSD.org> | 2008-11-18 04:04:01 +0000 |
| commit | 7f792cd7586b82bd1e8abd526963ca88413f3b5c (patch) | |
| tree | f29b2aceca0a9b58c5f9105ca9b1497c3fd113b9 | |
| parent | caab1f000cbe275d9e64be5f0e698455b6fdb360 (diff) | |
Notes
| -rw-r--r-- | sbin/geom/class/part/Makefile | 2 | ||||
| -rw-r--r-- | sbin/geom/class/part/geom_part.c | 18 |
2 files changed, 7 insertions, 13 deletions
diff --git a/sbin/geom/class/part/Makefile b/sbin/geom/class/part/Makefile index 0588646f09b7..36227162a1f4 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 4264992df9eb..c5f8ebba0bbe 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; + static char buf[5]; - sfxidx = 0; - sz = (long double)rawsz; - while (sfxidx < 4 && sz > 1099.0) { - sz /= 1000; - sfxidx++; - } - - sprintf(buf, "%.1Lf%s", sz, sfx[sfxidx]); + humanize_number(buf, sizeof(buf), rawsz, "", HN_AUTOSCALE, + HN_B | HN_NOSPACE | HN_DECIMAL); return (buf); } |
