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@70f56fa693 Ported-by: Tim Chase <tim@chase2k.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #1596
This commit is contained in:
parent
cb682a173a
commit
105afebb15
|
@ -2288,10 +2288,8 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
|
||||||
if (!cb->cb_sid2posix) {
|
if (!cb->cb_sid2posix) {
|
||||||
e = directory_name_from_sid(NULL, sid, &name,
|
e = directory_name_from_sid(NULL, sid, &name,
|
||||||
&classes);
|
&classes);
|
||||||
if (e != NULL) {
|
if (e != NULL)
|
||||||
directory_error_free(e);
|
directory_error_free(e);
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = sid;
|
name = sid;
|
||||||
}
|
}
|
||||||
|
@ -2543,7 +2541,7 @@ zfs_do_userspace(int argc, char **argv)
|
||||||
boolean_t prtnum = B_FALSE;
|
boolean_t prtnum = B_FALSE;
|
||||||
boolean_t parsable = B_FALSE;
|
boolean_t parsable = B_FALSE;
|
||||||
boolean_t sid2posix = B_FALSE;
|
boolean_t sid2posix = B_FALSE;
|
||||||
int error = 0;
|
int ret = 0;
|
||||||
int c;
|
int c;
|
||||||
zfs_sort_column_t *sortcol = NULL;
|
zfs_sort_column_t *sortcol = NULL;
|
||||||
int types = USTYPE_PSX_USR | USTYPE_SMB_USR;
|
int types = USTYPE_PSX_USR | USTYPE_SMB_USR;
|
||||||
|
@ -2688,18 +2686,19 @@ zfs_do_userspace(int argc, char **argv)
|
||||||
!(types & (USTYPE_PSX_GRP | USTYPE_SMB_GRP))))
|
!(types & (USTYPE_PSX_GRP | USTYPE_SMB_GRP))))
|
||||||
continue;
|
continue;
|
||||||
cb.cb_prop = p;
|
cb.cb_prop = p;
|
||||||
error = zfs_userspace(zhp, p, userspace_cb, &cb);
|
if ((ret = zfs_userspace(zhp, p, userspace_cb, &cb)) != 0)
|
||||||
if (error)
|
return (ret);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort the list */
|
/* Sort the list */
|
||||||
|
if ((node = uu_avl_first(avl_tree)) == NULL)
|
||||||
|
return (0);
|
||||||
|
|
||||||
us_populated = B_TRUE;
|
us_populated = B_TRUE;
|
||||||
|
|
||||||
listpool = uu_list_pool_create("tmplist", sizeof (us_node_t),
|
listpool = uu_list_pool_create("tmplist", sizeof (us_node_t),
|
||||||
offsetof(us_node_t, usn_listnode), NULL, UU_DEFAULT);
|
offsetof(us_node_t, usn_listnode), NULL, UU_DEFAULT);
|
||||||
list = uu_list_create(listpool, 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);
|
uu_list_node_init(node, &node->usn_listnode, listpool);
|
||||||
|
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
|
@ -2740,7 +2739,7 @@ zfs_do_userspace(int argc, char **argv)
|
||||||
uu_avl_destroy(avl_tree);
|
uu_avl_destroy(avl_tree);
|
||||||
uu_avl_pool_destroy(avl_pool);
|
uu_avl_pool_destroy(avl_pool);
|
||||||
|
|
||||||
return (error);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2010 Nexenta Systems, Inc. All rights reserved.
|
|
||||||
* Copyright (c) 2012 by Delphix. All rights reserved.
|
* Copyright (c) 2012 by Delphix. All rights reserved.
|
||||||
* Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
|
* Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
|
||||||
* Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
|
* Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
|
||||||
|
* Copyright 2012 Nexenta Systems, Inc. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -4337,35 +4337,40 @@ zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type,
|
||||||
zfs_userspace_cb_t func, void *arg)
|
zfs_userspace_cb_t func, void *arg)
|
||||||
{
|
{
|
||||||
zfs_cmd_t zc = { "\0", "\0", "\0", "\0", 0 };
|
zfs_cmd_t zc = { "\0", "\0", "\0", "\0", 0 };
|
||||||
int error;
|
|
||||||
zfs_useracct_t buf[100];
|
zfs_useracct_t buf[100];
|
||||||
|
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||||
|
int ret;
|
||||||
|
|
||||||
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
||||||
|
|
||||||
zc.zc_objset_type = type;
|
zc.zc_objset_type = type;
|
||||||
zc.zc_nvlist_dst = (uintptr_t)buf;
|
zc.zc_nvlist_dst = (uintptr_t)buf;
|
||||||
|
|
||||||
/* CONSTCOND */
|
for (;;) {
|
||||||
while (1) {
|
|
||||||
zfs_useracct_t *zua = buf;
|
zfs_useracct_t *zua = buf;
|
||||||
|
|
||||||
zc.zc_nvlist_dst_size = sizeof (buf);
|
zc.zc_nvlist_dst_size = sizeof (buf);
|
||||||
error = ioctl(zhp->zfs_hdl->libzfs_fd,
|
if (zfs_ioctl(hdl, ZFS_IOC_USERSPACE_MANY, &zc) != 0) {
|
||||||
ZFS_IOC_USERSPACE_MANY, &zc);
|
char errbuf[ZFS_MAXNAMELEN + 32];
|
||||||
if (error || zc.zc_nvlist_dst_size == 0)
|
|
||||||
|
(void) snprintf(errbuf, sizeof (errbuf),
|
||||||
|
dgettext(TEXT_DOMAIN,
|
||||||
|
"cannot get used/quota for %s"), zc.zc_name);
|
||||||
|
return (zfs_standard_error_fmt(hdl, errno, errbuf));
|
||||||
|
}
|
||||||
|
if (zc.zc_nvlist_dst_size == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
while (zc.zc_nvlist_dst_size > 0) {
|
while (zc.zc_nvlist_dst_size > 0) {
|
||||||
error = func(arg, zua->zu_domain, zua->zu_rid,
|
if ((ret = func(arg, zua->zu_domain, zua->zu_rid,
|
||||||
zua->zu_space);
|
zua->zu_space)) != 0)
|
||||||
if (error != 0)
|
return (ret);
|
||||||
return (error);
|
|
||||||
zua++;
|
zua++;
|
||||||
zc.zc_nvlist_dst_size -= sizeof (zfs_useracct_t);
|
zc.zc_nvlist_dst_size -= sizeof (zfs_useracct_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (error);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue