Skip to content

Commit 105afeb

Browse files
Yuri Pankovbehlendorf
authored andcommitted
Illumos #3098 zfs userspace/groupspace fail
3098 zfs userspace/groupspace fail without saying why when run as non-root Reviewed by: Eric Schrock <eric.schrock@delphix.com> Approved by: Richard Lowe <richlowe@richlowe.net> References: https://www.illumos.org/issues/3098 illumos/illumos-gate@70f56fa Ported-by: Tim Chase <tim@chase2k.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #1596
1 parent cb682a1 commit 105afeb

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

cmd/zfs/zfs_main.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,10 +2288,8 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
22882288
if (!cb->cb_sid2posix) {
22892289
e = directory_name_from_sid(NULL, sid, &name,
22902290
&classes);
2291-
if (e != NULL) {
2291+
if (e != NULL)
22922292
directory_error_free(e);
2293-
return (1);
2294-
}
22952293
if (name == NULL)
22962294
name = sid;
22972295
}
@@ -2543,7 +2541,7 @@ zfs_do_userspace(int argc, char **argv)
25432541
boolean_t prtnum = B_FALSE;
25442542
boolean_t parsable = B_FALSE;
25452543
boolean_t sid2posix = B_FALSE;
2546-
int error = 0;
2544+
int ret = 0;
25472545
int c;
25482546
zfs_sort_column_t *sortcol = NULL;
25492547
int types = USTYPE_PSX_USR | USTYPE_SMB_USR;
@@ -2688,18 +2686,19 @@ zfs_do_userspace(int argc, char **argv)
26882686
!(types & (USTYPE_PSX_GRP | USTYPE_SMB_GRP))))
26892687
continue;
26902688
cb.cb_prop = p;
2691-
error = zfs_userspace(zhp, p, userspace_cb, &cb);
2692-
if (error)
2693-
break;
2689+
if ((ret = zfs_userspace(zhp, p, userspace_cb, &cb)) != 0)
2690+
return (ret);
26942691
}
26952692

26962693
/* Sort the list */
2694+
if ((node = uu_avl_first(avl_tree)) == NULL)
2695+
return (0);
2696+
26972697
us_populated = B_TRUE;
2698+
26982699
listpool = uu_list_pool_create("tmplist", sizeof (us_node_t),
26992700
offsetof(us_node_t, usn_listnode), NULL, UU_DEFAULT);
27002701
list = uu_list_create(listpool, NULL, UU_DEFAULT);
2701-
2702-
node = uu_avl_first(avl_tree);
27032702
uu_list_node_init(node, &node->usn_listnode, listpool);
27042703

27052704
while (node != NULL) {
@@ -2740,7 +2739,7 @@ zfs_do_userspace(int argc, char **argv)
27402739
uu_avl_destroy(avl_tree);
27412740
uu_avl_pool_destroy(avl_pool);
27422741

2743-
return (error);
2742+
return (ret);
27442743
}
27452744

27462745
/*

lib/libzfs/libzfs_dataset.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
/*
2323
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24-
* Copyright (c) 2010 Nexenta Systems, Inc. All rights reserved.
2524
* Copyright (c) 2012 by Delphix. All rights reserved.
2625
* Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
2726
* Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
27+
* Copyright 2012 Nexenta Systems, Inc. All rights reserved.
2828
*/
2929

3030
#include <ctype.h>
@@ -4337,35 +4337,40 @@ zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type,
43374337
zfs_userspace_cb_t func, void *arg)
43384338
{
43394339
zfs_cmd_t zc = { "\0", "\0", "\0", "\0", 0 };
4340-
int error;
43414340
zfs_useracct_t buf[100];
4341+
libzfs_handle_t *hdl = zhp->zfs_hdl;
4342+
int ret;
43424343

43434344
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
43444345

43454346
zc.zc_objset_type = type;
43464347
zc.zc_nvlist_dst = (uintptr_t)buf;
43474348

4348-
/* CONSTCOND */
4349-
while (1) {
4349+
for (;;) {
43504350
zfs_useracct_t *zua = buf;
43514351

43524352
zc.zc_nvlist_dst_size = sizeof (buf);
4353-
error = ioctl(zhp->zfs_hdl->libzfs_fd,
4354-
ZFS_IOC_USERSPACE_MANY, &zc);
4355-
if (error || zc.zc_nvlist_dst_size == 0)
4353+
if (zfs_ioctl(hdl, ZFS_IOC_USERSPACE_MANY, &zc) != 0) {
4354+
char errbuf[ZFS_MAXNAMELEN + 32];
4355+
4356+
(void) snprintf(errbuf, sizeof (errbuf),
4357+
dgettext(TEXT_DOMAIN,
4358+
"cannot get used/quota for %s"), zc.zc_name);
4359+
return (zfs_standard_error_fmt(hdl, errno, errbuf));
4360+
}
4361+
if (zc.zc_nvlist_dst_size == 0)
43564362
break;
43574363

43584364
while (zc.zc_nvlist_dst_size > 0) {
4359-
error = func(arg, zua->zu_domain, zua->zu_rid,
4360-
zua->zu_space);
4361-
if (error != 0)
4362-
return (error);
4365+
if ((ret = func(arg, zua->zu_domain, zua->zu_rid,
4366+
zua->zu_space)) != 0)
4367+
return (ret);
43634368
zua++;
43644369
zc.zc_nvlist_dst_size -= sizeof (zfs_useracct_t);
43654370
}
43664371
}
43674372

4368-
return (error);
4373+
return (0);
43694374
}
43704375

43714376
int

0 commit comments

Comments
 (0)