X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fzfs%2Fzfs_main.c;h=5753ccea0d8e4a7c61ba4f4fac696cf80b30a9e1;hb=refs%2Fheads%2Frertzinger%2Ffeature-zpool-get--p;hp=9671c0c2a703fc6062d8e55b7e18e87ddc82406d;hpb=254255f735c4187f00df6d230b80cae508308f31;p=zfs.git diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 9671c0c..5753cce 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -66,6 +66,7 @@ #include "zfs_iter.h" #include "zfs_util.h" #include "zfs_comutil.h" +#include "libzfs_impl.h" libzfs_handle_t *g_zfs; @@ -2288,10 +2289,8 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space) if (!cb->cb_sid2posix) { e = directory_name_from_sid(NULL, sid, &name, &classes); - if (e != NULL) { + if (e != NULL) directory_error_free(e); - return (1); - } if (name == NULL) name = sid; } @@ -2543,7 +2542,7 @@ zfs_do_userspace(int argc, char **argv) boolean_t prtnum = B_FALSE; boolean_t parsable = B_FALSE; boolean_t sid2posix = B_FALSE; - int error = 0; + int ret = 0; int c; zfs_sort_column_t *sortcol = NULL; int types = USTYPE_PSX_USR | USTYPE_SMB_USR; @@ -2688,18 +2687,19 @@ zfs_do_userspace(int argc, char **argv) !(types & (USTYPE_PSX_GRP | USTYPE_SMB_GRP)))) continue; cb.cb_prop = p; - error = zfs_userspace(zhp, p, userspace_cb, &cb); - if (error) - break; + if ((ret = zfs_userspace(zhp, p, userspace_cb, &cb)) != 0) + return (ret); } /* Sort the list */ + if ((node = uu_avl_first(avl_tree)) == NULL) + return (0); + us_populated = B_TRUE; + listpool = uu_list_pool_create("tmplist", sizeof (us_node_t), offsetof(us_node_t, usn_listnode), NULL, UU_DEFAULT); list = uu_list_create(listpool, NULL, UU_DEFAULT); - - node = uu_avl_first(avl_tree); uu_list_node_init(node, &node->usn_listnode, listpool); while (node != NULL) { @@ -2740,7 +2740,7 @@ zfs_do_userspace(int argc, char **argv) uu_avl_destroy(avl_tree); uu_avl_pool_destroy(avl_pool); - return (error); + return (ret); } /* @@ -6344,12 +6344,6 @@ main(int argc, char **argv) opterr = 0; - if ((mnttab_file = fopen(MNTTAB, "r")) == NULL) { - (void) fprintf(stderr, gettext("internal error: unable to " - "open %s\n"), MNTTAB); - return (1); - } - /* * Make sure the user has specified some command. */ @@ -6388,6 +6382,8 @@ main(int argc, char **argv) if ((g_zfs = libzfs_init()) == NULL) return (1); + mnttab_file = g_zfs->libzfs_mnttab; + zpool_set_history_str("zfs", argc, argv, history_str); verify(zpool_stage_history(g_zfs, history_str) == 0); @@ -6412,8 +6408,6 @@ main(int argc, char **argv) } libzfs_fini(g_zfs); - (void) fclose(mnttab_file); - /* * The 'ZFS_ABORT' environment variable causes us to dump core on exit * for the purposes of running ::findleaks.