1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

Suppress decimal point when using units of sectors/bytes.

This commit is contained in:
Alasdair Kergon 2004-05-28 12:47:57 +00:00
parent abaf083ddc
commit 7d36b514d8
2 changed files with 14 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 2.00.17 - Version 2.00.17 -
============================= =============================
Suppress decimal point when using units of sectors/bytes.
Additional kernel target checks before pvmove & snapshot creation. Additional kernel target checks before pvmove & snapshot creation.
Version 2.00.16 - 24 May 2004 Version 2.00.16 - 24 May 2004

View File

@ -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) const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
{ {
int s; int s;
int suffix = 1; int suffix = 1, precision;
uint64_t byte = UINT64_C(0); uint64_t byte = UINT64_C(0);
uint64_t units = UINT64_C(1024); uint64_t units = UINT64_C(1024);
char *size_buf = NULL; 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; s++, byte /= units;
} }
snprintf(size_buf, SIZE_BUF - 1, "%.2f%s", (float) size / byte, /* FIXME Make precision configurable */
suffix ? size_str[s][sl] : ""); 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; return size_buf;
} }