mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +03:00
Add zfs_nicebytes() to print human-readable sizes
* Add zfs_nicebytes() to print human-readable sizes Some 'zfs', 'zpool' and 'zdb' output strings can be confusing to the user when no units are specified. This add a new zfs_nicenum_format "ZFS_NICENUM_BYTES" used to print bytes in their human-readable form. Additionally, update some test cases to use machine-parsable 'zfs get'. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes #2414 Closes #3185 Closes #3594 Closes #6032
This commit is contained in:
@@ -322,7 +322,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf,
|
||||
(void) snprintf(buf, len, "%llu",
|
||||
(u_longlong_t)intval);
|
||||
} else {
|
||||
(void) zfs_nicenum(intval, buf, len);
|
||||
(void) zfs_nicebytes(intval, buf, len);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1253,7 +1253,8 @@ zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot,
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
zfs_nicenum(SPA_MINDEVSIZE, buf, sizeof (buf));
|
||||
zfs_nicebytes(SPA_MINDEVSIZE, buf,
|
||||
sizeof (buf));
|
||||
|
||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||
"one or more devices is less than the "
|
||||
@@ -1390,7 +1391,8 @@ zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
zfs_nicenum(SPA_MINDEVSIZE, buf, sizeof (buf));
|
||||
zfs_nicebytes(SPA_MINDEVSIZE, buf,
|
||||
sizeof (buf));
|
||||
|
||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||
"device is less than the minimum "
|
||||
|
||||
Reference in New Issue
Block a user