From bc2d809387debb95d82f47185d446f328da4d147 Mon Sep 17 00:00:00 2001 From: Christer Ekholm Date: Mon, 16 May 2016 21:29:54 +0200 Subject: Make zpool list -vp print individual vdev sizes parsable. Add argument format to print_one_column(), and use it to call zfs_nicenum_format with, instead of just zfs_nicenum. Don't print "%" for fragmentation or capacity percent values. The calls to print_one_colum is made with ZFS_NICENUM_RAW if cb->cb_literal (zpool list called with -p), and ZFS_NICENUM_1024 if not. Also zpool_get_prop is modified to don't add "%" or "x" if literal. Signed-off-by: Christer Ekholm Signed-off-by: Brian Behlendorf Signed-off-by: Tony Hutter vs_space != 0); uint64_t cap; + enum zfs_nicenum_format format; + + if (cb->cb_literal) + format = ZFS_NICENUM_RAW; + else + format = ZFS_NICENUM_1024; if (scripted) (void) printf("\t%s", name); @@ -4341,19 +4355,21 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv, * to indicate that the value is valid. */ print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, scripted, - toplevel); + toplevel, format); print_one_column(ZPOOL_PROP_ALLOCATED, vs->vs_alloc, scripted, - toplevel); + toplevel, format); print_one_column(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc, - scripted, toplevel); + scripted, toplevel, format); print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, scripted, - B_TRUE); + B_TRUE, format); print_one_column(ZPOOL_PROP_FRAGMENTATION, vs->vs_fragmentation, scripted, - (vs->vs_fragmentation != ZFS_FRAG_INVALID && toplevel)); + (vs->vs_fragmentation != ZFS_FRAG_INVALID && toplevel), + format); cap = (vs->vs_space == 0) ? 0 : (vs->vs_alloc * 100 / vs->vs_space); - print_one_column(ZPOOL_PROP_CAPACITY, cap, scripted, toplevel); + print_one_column(ZPOOL_PROP_CAPACITY, cap, scripted, toplevel, + format); (void) printf("\n"); } -- cgit v1.2.3