Share gv_roughlength() between kernel and userland, as we will need it
there later.
This commit is contained in:
parent
9c83534dd8
commit
94175098f1
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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_ */
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user