diff options
author | наб <[email protected]> | 2020-11-13 23:38:29 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2020-11-16 09:26:20 -0800 |
commit | e6c59cd171bf141eae232db2f4c33ff79d5862c3 (patch) | |
tree | c6651f4ca4b134376d3c75ef947014dff2910982 /cmd/zpool | |
parent | fd654e412e48751e402a993594a39d336868e4c4 (diff) |
zpool: correctly align columns with -p
zpool_expand_proplist() now ignores pl_fixed if its new literal
argument is true. The rest is a consequence of needing to pass
that down.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiao?=~Dska <[email protected]>
Closes #11202
Diffstat (limited to 'cmd/zpool')
-rw-r--r-- | cmd/zpool/zpool_iter.c | 16 | ||||
-rw-r--r-- | cmd/zpool/zpool_main.c | 39 | ||||
-rw-r--r-- | cmd/zpool/zpool_util.h | 4 |
3 files changed, 35 insertions, 24 deletions
diff --git a/cmd/zpool/zpool_iter.c b/cmd/zpool/zpool_iter.c index 5f3153bca..d70d26669 100644 --- a/cmd/zpool/zpool_iter.c +++ b/cmd/zpool/zpool_iter.c @@ -56,6 +56,7 @@ typedef struct zpool_node { struct zpool_list { boolean_t zl_findall; + boolean_t zl_literal; uu_avl_t *zl_avl; uu_avl_pool_t *zl_pool; zprop_list_t **zl_proplist; @@ -88,7 +89,9 @@ add_pool(zpool_handle_t *zhp, void *data) uu_avl_node_init(node, &node->zn_avlnode, zlp->zl_pool); if (uu_avl_find(zlp->zl_avl, node, NULL, &idx) == NULL) { if (zlp->zl_proplist && - zpool_expand_proplist(zhp, zlp->zl_proplist) != 0) { + zpool_expand_proplist(zhp, zlp->zl_proplist, + zlp->zl_literal) + != 0) { zpool_close(zhp); free(node); return (-1); @@ -110,7 +113,8 @@ add_pool(zpool_handle_t *zhp, void *data) * line. */ zpool_list_t * -pool_list_get(int argc, char **argv, zprop_list_t **proplist, int *err) +pool_list_get(int argc, char **argv, zprop_list_t **proplist, + boolean_t literal, int *err) { zpool_list_t *zlp; @@ -128,6 +132,8 @@ pool_list_get(int argc, char **argv, zprop_list_t **proplist, int *err) zlp->zl_proplist = proplist; + zlp->zl_literal = literal; + if (argc == 0) { (void) zpool_iter(g_zfs, add_pool, zlp); zlp->zl_findall = B_TRUE; @@ -242,12 +248,12 @@ pool_list_count(zpool_list_t *zlp) */ int for_each_pool(int argc, char **argv, boolean_t unavail, - zprop_list_t **proplist, zpool_iter_f func, void *data) + zprop_list_t **proplist, boolean_t literal, zpool_iter_f func, void *data) { zpool_list_t *list; int ret = 0; - if ((list = pool_list_get(argc, argv, proplist, &ret)) == NULL) + if ((list = pool_list_get(argc, argv, proplist, literal, &ret)) == NULL) return (1); if (pool_list_iter(list, unavail, func, data) != 0) @@ -711,7 +717,7 @@ all_pools_for_each_vdev_run(int argc, char **argv, char *cmd, vcdl->g_zfs = g_zfs; /* Gather our list of all vdevs in all pools */ - for_each_pool(argc, argv, B_TRUE, NULL, + for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE, all_pools_for_each_vdev_gather_cb, vcdl); /* Run command on all vdevs in all pools */ diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index d6a890fcc..85c9abdf2 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -1762,7 +1762,7 @@ zpool_do_export(int argc, char **argv) } return (for_each_pool(argc, argv, B_TRUE, NULL, - zpool_export_one, &cb)); + B_FALSE, zpool_export_one, &cb)); } /* check arguments */ @@ -1771,7 +1771,8 @@ zpool_do_export(int argc, char **argv) usage(B_FALSE); } - ret = for_each_pool(argc, argv, B_TRUE, NULL, zpool_export_one, &cb); + ret = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE, zpool_export_one, + &cb); return (ret); } @@ -3613,7 +3614,8 @@ zpool_do_sync(int argc, char **argv) argv += optind; /* if argc == 0 we will execute zpool_sync_one on all pools */ - ret = for_each_pool(argc, argv, B_FALSE, NULL, zpool_sync_one, &force); + ret = for_each_pool(argc, argv, B_FALSE, NULL, B_FALSE, zpool_sync_one, + &force); return (ret); } @@ -4958,7 +4960,7 @@ are_vdevs_in_pool(int argc, char **argv, char *pool_name, /* Is this name a vdev in our pools? */ ret = for_each_pool(pool_count, &pool_name, B_TRUE, NULL, - is_vdev, cb); + B_FALSE, is_vdev, cb); if (!ret) { /* No match */ break; @@ -4986,7 +4988,8 @@ is_pool_cb(zpool_handle_t *zhp, void *data) static int is_pool(char *name) { - return (for_each_pool(0, NULL, B_TRUE, NULL, is_pool_cb, name)); + return (for_each_pool(0, NULL, B_TRUE, NULL, B_FALSE, is_pool_cb, + name)); } /* Are all our argv[] strings pool names? If so return 1, 0 otherwise. */ @@ -5438,7 +5441,7 @@ zpool_do_iostat(int argc, char **argv) * Construct the list of all interesting pools. */ ret = 0; - if ((list = pool_list_get(argc, argv, NULL, &ret)) == NULL) + if ((list = pool_list_get(argc, argv, NULL, parsable, &ret)) == NULL) return (1); if (pool_list_count(list) == 0 && argc != 0) { @@ -6112,7 +6115,7 @@ zpool_do_list(int argc, char **argv) for (;;) { if ((list = pool_list_get(argc, argv, &cb.cb_proplist, - &ret)) == NULL) + cb.cb_literal, &ret)) == NULL) return (1); if (pool_list_count(list) == 0) @@ -6864,7 +6867,7 @@ zpool_do_reopen(int argc, char **argv) argv += optind; /* if argc == 0 we will execute zpool_reopen_one on all pools */ - ret = for_each_pool(argc, argv, B_TRUE, NULL, zpool_reopen_one, + ret = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE, zpool_reopen_one, &scrub_restart); return (ret); @@ -6994,12 +6997,13 @@ zpool_do_scrub(int argc, char **argv) usage(B_FALSE); } - error = for_each_pool(argc, argv, B_TRUE, NULL, scrub_callback, &cb); + error = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE, + scrub_callback, &cb); if (wait && !error) { zpool_wait_activity_t act = ZPOOL_WAIT_SCRUB; - error = for_each_pool(argc, argv, B_TRUE, NULL, wait_callback, - &act); + error = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE, + wait_callback, &act); } return (error); @@ -7037,7 +7041,8 @@ zpool_do_resilver(int argc, char **argv) usage(B_FALSE); } - return (for_each_pool(argc, argv, B_TRUE, NULL, scrub_callback, &cb)); + return (for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE, + scrub_callback, &cb)); } /* @@ -8431,7 +8436,7 @@ zpool_do_status(int argc, char **argv) cb.vcdl = all_pools_for_each_vdev_run(argc, argv, cmd, NULL, NULL, 0, 0); - ret = for_each_pool(argc, argv, B_TRUE, NULL, + ret = for_each_pool(argc, argv, B_TRUE, NULL, cb.cb_literal, status_callback, &cb); if (cb.vcdl != NULL) @@ -8950,7 +8955,7 @@ zpool_do_upgrade(int argc, char **argv) (void) printf(gettext("\n")); } } else { - ret = for_each_pool(argc, argv, B_FALSE, NULL, + ret = for_each_pool(argc, argv, B_FALSE, NULL, B_FALSE, upgrade_one, &cb); } @@ -9139,7 +9144,7 @@ zpool_do_history(int argc, char **argv) argc -= optind; argv += optind; - ret = for_each_pool(argc, argv, B_FALSE, NULL, get_history_one, + ret = for_each_pool(argc, argv, B_FALSE, NULL, B_FALSE, get_history_one, &cbdata); if (argc == 0 && cbdata.first == B_TRUE) { @@ -9702,7 +9707,7 @@ zpool_do_get(int argc, char **argv) cb.cb_proplist = &fake_name; } - ret = for_each_pool(argc, argv, B_TRUE, &cb.cb_proplist, + ret = for_each_pool(argc, argv, B_TRUE, &cb.cb_proplist, cb.cb_literal, get_callback, &cb); if (cb.cb_proplist == &fake_name) @@ -9772,7 +9777,7 @@ zpool_do_set(int argc, char **argv) *(cb.cb_value) = '\0'; cb.cb_value++; - error = for_each_pool(argc - 2, argv + 2, B_TRUE, NULL, + error = for_each_pool(argc - 2, argv + 2, B_TRUE, NULL, B_FALSE, set_callback, &cb); return (error); diff --git a/cmd/zpool/zpool_util.h b/cmd/zpool/zpool_util.h index 265aa5895..abaa22d78 100644 --- a/cmd/zpool/zpool_util.h +++ b/cmd/zpool/zpool_util.h @@ -64,7 +64,7 @@ nvlist_t *split_mirror_vdev(zpool_handle_t *zhp, char *newname, * Pool list functions */ int for_each_pool(int, char **, boolean_t unavail, zprop_list_t **, - zpool_iter_f, void *); + boolean_t, zpool_iter_f, void *); /* Vdev list functions */ typedef int (*pool_vdev_iter_f)(zpool_handle_t *, nvlist_t *, void *); @@ -72,7 +72,7 @@ int for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data); typedef struct zpool_list zpool_list_t; -zpool_list_t *pool_list_get(int, char **, zprop_list_t **, int *); +zpool_list_t *pool_list_get(int, char **, zprop_list_t **, boolean_t, int *); void pool_list_update(zpool_list_t *); int pool_list_iter(zpool_list_t *, int unavail, zpool_iter_f, void *); void pool_list_free(zpool_list_t *); |