|
26 | 26 | #include <ctype.h>
|
27 | 27 | #include <math.h>
|
28 | 28 | #include <stdio.h>
|
| 29 | +#include <stdlib.h> |
29 | 30 | #include <libzutil.h>
|
30 | 31 | #include <string.h>
|
31 | 32 |
|
@@ -64,19 +65,22 @@ zfs_nicenum_format(uint64_t num, char *buf, size_t buflen,
|
64 | 65 | uint64_t n = num;
|
65 | 66 | int index = 0;
|
66 | 67 | const char *u;
|
67 |
| - const char *units[3][7] = { |
| 68 | + const char *units[5][7] = { |
68 | 69 | [ZFS_NICENUM_1024] = {"", "K", "M", "G", "T", "P", "E"},
|
69 | 70 | [ZFS_NICENUM_BYTES] = {"B", "K", "M", "G", "T", "P", "E"},
|
70 |
| - [ZFS_NICENUM_TIME] = {"ns", "us", "ms", "s", "?", "?", "?"} |
| 71 | + [ZFS_NICENUM_TIME] = {"ns", "us", "ms", "s", "?", "?", "?"}, |
| 72 | + [ZFS_NICENUM_BYTES_1000] = {"B", "K", "M", "G", "T", "P", "E"} |
71 | 73 | };
|
72 | 74 |
|
73 | 75 | const int units_len[] = {[ZFS_NICENUM_1024] = 6,
|
74 | 76 | [ZFS_NICENUM_BYTES] = 6,
|
75 |
| - [ZFS_NICENUM_TIME] = 4}; |
| 77 | + [ZFS_NICENUM_TIME] = 4, |
| 78 | + [ZFS_NICENUM_BYTES_1000] = 6}; |
76 | 79 |
|
77 | 80 | const int k_unit[] = { [ZFS_NICENUM_1024] = 1024,
|
78 | 81 | [ZFS_NICENUM_BYTES] = 1024,
|
79 |
| - [ZFS_NICENUM_TIME] = 1000}; |
| 82 | + [ZFS_NICENUM_TIME] = 1000, |
| 83 | + [ZFS_NICENUM_BYTES_1000] = 1000}; |
80 | 84 |
|
81 | 85 | double val;
|
82 | 86 |
|
@@ -180,5 +184,9 @@ zfs_niceraw(uint64_t num, char *buf, size_t buflen)
|
180 | 184 | void
|
181 | 185 | zfs_nicebytes(uint64_t num, char *buf, size_t buflen)
|
182 | 186 | {
|
183 |
| - zfs_nicenum_format(num, buf, buflen, ZFS_NICENUM_BYTES); |
| 187 | + if (getenv("ZFS_KB_IS_1000") != NULL) { |
| 188 | + zfs_nicenum_format(num, buf, buflen, ZFS_NICENUM_BYTES_1000); |
| 189 | + } else { |
| 190 | + zfs_nicenum_format(num, buf, buflen, ZFS_NICENUM_BYTES); |
| 191 | + } |
184 | 192 | }
|
0 commit comments