diff --git a/WHATS_NEW b/WHATS_NEW index b6eb113e9..f94f21cfe 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.00.17 - ============================= + Suppress decimal point when using units of sectors/bytes. Additional kernel target checks before pvmove & snapshot creation. Version 2.00.16 - 24 May 2004 diff --git a/lib/display/display.c b/lib/display/display.c index 5e5012f6e..39588300e 100644 --- a/lib/display/display.c +++ b/lib/display/display.c @@ -134,7 +134,7 @@ alloc_policy_t get_alloc_from_string(const char *str) const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl) { int s; - int suffix = 1; + int suffix = 1, precision; uint64_t byte = UINT64_C(0); uint64_t units = UINT64_C(1024); char *size_buf = NULL; @@ -182,8 +182,18 @@ const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl) s++, byte /= units; } - snprintf(size_buf, SIZE_BUF - 1, "%.2f%s", (float) size / byte, - suffix ? size_str[s][sl] : ""); + /* FIXME Make precision configurable */ + switch(toupper((int) cmd->current_settings.unit_type)) { + case 'B': + case 'S': + precision = 0; + break; + default: + precision = 2; + } + + snprintf(size_buf, SIZE_BUF - 1, "%.*f%s", precision, + (float) size / byte, suffix ? size_str[s][sl] : ""); return size_buf; }