From c174c57d9d244a5eab7ccbb84ae730653d1ff5a1 Mon Sep 17 00:00:00 2001 From: le Date: Mon, 15 Nov 2004 12:30:59 +0000 Subject: Share gv_roughlength() between kernel and userland, as we will need it there later. --- sys/geom/vinum/geom_vinum.h | 1 - sys/geom/vinum/geom_vinum_share.c | 35 +++++++++++++++++++++++++++++++++++ sys/geom/vinum/geom_vinum_share.h | 1 + sys/geom/vinum/geom_vinum_subr.c | 35 ----------------------------------- 4 files changed, 36 insertions(+), 36 deletions(-) (limited to 'sys') diff --git a/sys/geom/vinum/geom_vinum.h b/sys/geom/vinum/geom_vinum.h index ddbf5cf..de48c7d 100644 --- a/sys/geom/vinum/geom_vinum.h +++ b/sys/geom/vinum/geom_vinum.h @@ -73,7 +73,6 @@ void gv_kill_plex_thread(struct gv_plex *); void gv_kill_vol_thread(struct gv_volume *); int gv_object_type(struct gv_softc *, char *); void gv_parse_config(struct gv_softc *, u_char *, int); -const char *gv_roughlength(off_t, int); int gv_sd_to_drive(struct gv_softc *, struct gv_drive *, struct gv_sd *, char *, int); int gv_sd_to_plex(struct gv_plex *, struct gv_sd *, int); diff --git a/sys/geom/vinum/geom_vinum_share.c b/sys/geom/vinum/geom_vinum_share.c index 2b572c3..1219f0e 100644 --- a/sys/geom/vinum/geom_vinum_share.c +++ b/sys/geom/vinum/geom_vinum_share.c @@ -650,3 +650,38 @@ gv_new_sd(int max, char *token[]) return (s); } + +/* + * Take a size in bytes and return a pointer to a string which represents the + * size best. If lj is != 0, return left justified, otherwise in a fixed 10 + * character field suitable for columnar printing. + * + * Note this uses a static string: it's only intended to be used immediately + * for printing. + */ +const char * +gv_roughlength(off_t bytes, int lj) +{ + static char desc[16]; + + /* Gigabytes. */ + if (bytes > (off_t)MEGABYTE * 10000) + snprintf(desc, sizeof(desc), lj ? "%jd GB" : "%10jd GB", + bytes / GIGABYTE); + + /* Megabytes. */ + else if (bytes > KILOBYTE * 10000) + snprintf(desc, sizeof(desc), lj ? "%jd MB" : "%10jd MB", + bytes / MEGABYTE); + + /* Kilobytes. */ + else if (bytes > 10000) + snprintf(desc, sizeof(desc), lj ? "%jd kB" : "%10jd kB", + bytes / KILOBYTE); + + /* Bytes. */ + else + snprintf(desc, sizeof(desc), lj ? "%jd B" : "%10jd B", bytes); + + return (desc); +} diff --git a/sys/geom/vinum/geom_vinum_share.h b/sys/geom/vinum/geom_vinum_share.h index 177e971..f15f45d 100644 --- a/sys/geom/vinum/geom_vinum_share.h +++ b/sys/geom/vinum/geom_vinum_share.h @@ -58,5 +58,6 @@ const char *gv_plexorg_short(int); const char *gv_plexstate(int); const char *gv_sdstate(int); const char *gv_volstate(int); +const char *gv_roughlength(off_t, int); #endif /* _GEOM_VINUM_SHARE_H_ */ diff --git a/sys/geom/vinum/geom_vinum_subr.c b/sys/geom/vinum/geom_vinum_subr.c index 1821cfd..0df59c3 100644 --- a/sys/geom/vinum/geom_vinum_subr.c +++ b/sys/geom/vinum/geom_vinum_subr.c @@ -235,41 +235,6 @@ gv_format_config(struct gv_softc *sc, struct sbuf *sb, int ondisk, char *prefix) return; } -/* - * Take a size in bytes and return a pointer to a string which represents the - * size best. If lj is != 0, return left justified, otherwise in a fixed 10 - * character field suitable for columnar printing. - * - * Note this uses a static string: it's only intended to be used immediately - * for printing. - */ -const char * -gv_roughlength(off_t bytes, int lj) -{ - static char desc[16]; - - /* Gigabytes. */ - if (bytes > (off_t)MEGABYTE * 10000) - snprintf(desc, sizeof(desc), lj ? "%jd GB" : "%10jd GB", - bytes / GIGABYTE); - - /* Megabytes. */ - else if (bytes > KILOBYTE * 10000) - snprintf(desc, sizeof(desc), lj ? "%jd MB" : "%10jd MB", - bytes / MEGABYTE); - - /* Kilobytes. */ - else if (bytes > 10000) - snprintf(desc, sizeof(desc), lj ? "%jd kB" : "%10jd kB", - bytes / KILOBYTE); - - /* Bytes. */ - else - snprintf(desc, sizeof(desc), lj ? "%jd B" : "%10jd B", bytes); - - return (desc); -} - int gv_sd_to_plex(struct gv_plex *p, struct gv_sd *s, int check) { -- cgit v1.1