aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/zfs_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/zfs/zfs_ioctl.c')
-rw-r--r--module/zfs/zfs_ioctl.c279
1 files changed, 139 insertions, 140 deletions
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
index b12205e68..269680597 100644
--- a/module/zfs/zfs_ioctl.c
+++ b/module/zfs/zfs_ioctl.c
@@ -25,10 +25,9 @@
* Portions Copyright 2012 Pawel Jakub Dawidek <[email protected]>
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 201i3 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -376,7 +375,7 @@ zfs_secpolicy_read(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
zone_dataset_visible(zc->zc_name, NULL))
return (0);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
static int
@@ -390,7 +389,7 @@ zfs_dozonecheck_impl(const char *dataset, uint64_t zoned, cred_t *cr)
*/
if (!INGLOBALZONE(curproc) &&
!zone_dataset_visible(dataset, &writable))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
if (INGLOBALZONE(curproc)) {
/*
@@ -398,17 +397,17 @@ zfs_dozonecheck_impl(const char *dataset, uint64_t zoned, cred_t *cr)
* global zone.
*/
if (secpolicy_zfs(cr) && zoned)
- return (EPERM);
+ return (SET_ERROR(EPERM));
} else {
/*
* If we are in a local zone, the 'zoned' property must be set.
*/
if (!zoned)
- return (EPERM);
+ return (SET_ERROR(EPERM));
/* must be writable by this zone */
if (!writable)
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
return (0);
}
@@ -419,7 +418,7 @@ zfs_dozonecheck(const char *dataset, cred_t *cr)
uint64_t zoned;
if (dsl_prop_get_integer(dataset, "zoned", &zoned, NULL))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
return (zfs_dozonecheck_impl(dataset, zoned, cr));
}
@@ -430,7 +429,7 @@ zfs_dozonecheck_ds(const char *dataset, dsl_dataset_t *ds, cred_t *cr)
uint64_t zoned;
if (dsl_prop_get_int_ds(ds, "zoned", &zoned))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
return (zfs_dozonecheck_impl(dataset, zoned, cr));
}
@@ -494,14 +493,14 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
error = dsl_prop_get(name, zfs_prop_to_name(ZFS_PROP_MLSLABEL),
1, sizeof (ds_hexsl), &ds_hexsl, NULL);
if (error != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (strcasecmp(strval, ZFS_MLSLABEL_DEFAULT) == 0)
new_default = TRUE;
/* The label must be translatable */
if (!new_default && (hexstr_to_label(strval, &new_sl) != 0))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* In a non-global zone, disallow attempts to set a label that
@@ -510,7 +509,7 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
*/
if (!INGLOBALZONE(curproc)) {
if (new_default || !blequal(&new_sl, CR_SL(CRED())))
- return (EPERM);
+ return (SET_ERROR(EPERM));
return (0);
}
@@ -521,10 +520,10 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
*/
if (dsl_prop_get_integer(name,
zfs_prop_to_name(ZFS_PROP_ZONED), &zoned, NULL))
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (!zoned) {
if (zfs_check_global_label(name, strval) != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
/*
@@ -544,7 +543,7 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
error = dmu_objset_own(name, DMU_OST_ZFS, B_TRUE,
setsl_tag, &os);
if (error != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
dmu_objset_disown(os, setsl_tag);
@@ -554,7 +553,7 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
}
if (hexstr_to_label(strval, &new_sl) != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (blstrictdom(&ds_sl, &new_sl))
needed_priv = PRIV_FILE_DOWNGRADE_SL;
@@ -592,7 +591,7 @@ zfs_secpolicy_setprop(const char *dsname, zfs_prop_t prop, nvpair_t *propval,
* Disallow setting of 'zoned' from within a local zone.
*/
if (!INGLOBALZONE(curproc))
- return (EPERM);
+ return (SET_ERROR(EPERM));
break;
case ZFS_PROP_QUOTA:
@@ -606,15 +605,15 @@ zfs_secpolicy_setprop(const char *dsname, zfs_prop_t prop, nvpair_t *propval,
*/
if (dsl_prop_get_integer(dsname, "zoned", &zoned,
setpoint))
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (!zoned || strlen(dsname) <= strlen(setpoint))
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
break;
case ZFS_PROP_MLSLABEL:
if (!is_system_labeled())
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (nvpair_value_string(propval, &strval) == 0) {
int err;
@@ -669,7 +668,7 @@ zfs_secpolicy_send(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
*/
cp = strchr(zc->zc_name, '@');
if (cp == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
if (error != 0)
return (error);
@@ -716,7 +715,7 @@ zfs_secpolicy_deleg_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
(strcmp((char *)refstr_value(vp->v_vfsp->vfs_resource),
zc->zc_name) != 0)) {
VN_RELE(vp);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
VN_RELE(vp);
@@ -730,7 +729,7 @@ zfs_secpolicy_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
#ifdef HAVE_SMB_SHARE
if (!INGLOBALZONE(curproc))
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (secpolicy_nfs(cr) == 0) {
return (0);
@@ -738,7 +737,7 @@ zfs_secpolicy_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
return (zfs_secpolicy_deleg_share(zc, innvl, cr));
}
#else
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
#endif /* HAVE_SMB_SHARE */
}
@@ -747,7 +746,7 @@ zfs_secpolicy_smb_acl(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
#ifdef HAVE_SMB_SHARE
if (!INGLOBALZONE(curproc))
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (secpolicy_smb(cr) == 0) {
return (0);
@@ -755,7 +754,7 @@ zfs_secpolicy_smb_acl(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
return (zfs_secpolicy_deleg_share(zc, innvl, cr));
}
#else
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
#endif /* HAVE_SMB_SHARE */
}
@@ -774,7 +773,7 @@ zfs_get_parent(const char *datasetname, char *parent, int parentsize)
} else {
cp = strrchr(parent, '/');
if (cp == NULL)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
cp[0] = '\0';
}
@@ -813,7 +812,7 @@ zfs_secpolicy_destroy_snaps(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
int error = 0;
if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
pair = nextpair) {
dsl_pool_t *dp;
@@ -971,14 +970,14 @@ zfs_secpolicy_snapshot(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
nvpair_t *pair;
if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
pair = nvlist_next_nvpair(snaps, pair)) {
char *name = nvpair_name(pair);
char *atp = strchr(name, '@');
if (atp == NULL) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
*atp = '\0';
@@ -999,7 +998,7 @@ zfs_secpolicy_log_history(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
* to log to.
*/
if (tsd_get(zfs_allow_log_key) == NULL)
- return (EPERM);
+ return (SET_ERROR(EPERM));
return (0);
}
@@ -1036,7 +1035,7 @@ static int
zfs_secpolicy_config(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
if (secpolicy_sys_config(cr, B_FALSE) != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
return (0);
}
@@ -1075,7 +1074,7 @@ zfs_secpolicy_inherit_prop(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
if (prop == ZPROP_INVAL) {
if (!zfs_prop_user(zc->zc_value))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
return (zfs_secpolicy_write_perms(zc->zc_name,
ZFS_DELEG_PERM_USERPROP, cr));
} else {
@@ -1092,7 +1091,7 @@ zfs_secpolicy_userspace_one(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
return (err);
if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (zc->zc_value[0] == 0) {
/*
@@ -1121,7 +1120,7 @@ zfs_secpolicy_userspace_many(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
return (err);
if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
return (zfs_secpolicy_write_perms(zc->zc_name,
userquota_perms[zc->zc_objset_type], cr));
@@ -1145,7 +1144,7 @@ zfs_secpolicy_hold(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
error = nvlist_lookup_nvlist(innvl, "holds", &holds);
if (error != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL;
pair = nvlist_next_nvpair(holds, pair)) {
@@ -1223,7 +1222,7 @@ get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp)
* Read in and unpack the user-supplied nvlist.
*/
if (size == 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
packed = kmem_alloc(size, KM_SLEEP | KM_NODEBUG);
@@ -1262,7 +1261,7 @@ nvlist_smush(nvlist_t *errors, size_t max)
int n = 0;
if (max < 1024)
- return (ENOMEM);
+ return (SET_ERROR(ENOMEM));
fnvlist_add_int32(errors, ZPROP_N_MORE_ERRORS, 0);
more_errors = nvlist_prev_nvpair(errors, NULL);
@@ -1293,12 +1292,12 @@ put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl)
size = fnvlist_size(nvl);
if (size > zc->zc_nvlist_dst_size) {
- error = ENOMEM;
+ error = SET_ERROR(ENOMEM);
} else {
packed = fnvlist_pack(nvl, &size);
if (ddi_copyout(packed, (void *)(uintptr_t)zc->zc_nvlist_dst,
size, zc->zc_iflags) != 0)
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
fnvlist_pack_free(packed, size);
}
@@ -1318,7 +1317,7 @@ get_zfs_sb(const char *dsname, zfs_sb_t **zsbp)
return (error);
if (dmu_objset_type(os) != DMU_OST_ZFS) {
dmu_objset_rele(os, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
mutex_enter(&os->os_user_ptr_lock);
@@ -1326,7 +1325,7 @@ get_zfs_sb(const char *dsname, zfs_sb_t **zsbp)
if (*zsbp && (*zsbp)->z_sb) {
atomic_inc(&((*zsbp)->z_sb->s_active));
} else {
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
}
mutex_exit(&os->os_user_ptr_lock);
dmu_objset_rele(os, FTAG);
@@ -1356,7 +1355,7 @@ zfs_sb_hold(const char *name, void *tag, zfs_sb_t **zsbp, boolean_t writer)
* objset from the zfsvfs.
*/
rrw_exit(&(*zsbp)->z_teardown_lock, tag);
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
}
return (error);
@@ -1401,7 +1400,7 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
(void) nvlist_lookup_uint64(props,
zpool_prop_to_name(ZPOOL_PROP_VERSION), &version);
if (!SPA_VERSION_IS_SUPPORTED(version)) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto pool_props_bad;
}
(void) nvlist_lookup_nvlist(props, ZPOOL_ROOTFS_PROPS, &nvl);
@@ -1470,7 +1469,7 @@ zfs_ioc_pool_import(zfs_cmd_t *zc)
if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, &guid) != 0 ||
guid != zc->zc_guid)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
else
error = spa_import(zc->zc_name, config, props, zc->zc_cookie);
@@ -1510,7 +1509,7 @@ zfs_ioc_pool_configs(zfs_cmd_t *zc)
int error;
if ((configs = spa_all_configs(&zc->zc_cookie)) == NULL)
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
error = put_nvlist(zc, configs);
@@ -1574,7 +1573,7 @@ zfs_ioc_pool_tryimport(zfs_cmd_t *zc)
nvlist_free(tryconfig);
if (config == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = put_nvlist(zc, config);
nvlist_free(config);
@@ -1632,7 +1631,7 @@ zfs_ioc_pool_upgrade(zfs_cmd_t *zc)
if (zc->zc_cookie < spa_version(spa) ||
!SPA_VERSION_IS_SUPPORTED(zc->zc_cookie)) {
spa_close(spa, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
spa_upgrade(spa, zc->zc_cookie);
@@ -1650,14 +1649,14 @@ zfs_ioc_pool_get_history(zfs_cmd_t *zc)
int error;
if ((size = zc->zc_history_len) == 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
return (error);
if (spa_version(spa) < SPA_VERSION_ZPOOL_HISTORY) {
spa_close(spa, FTAG);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
hist_buf = vmem_alloc(size, KM_SLEEP);
@@ -1712,7 +1711,7 @@ zfs_ioc_obj_to_path(zfs_cmd_t *zc)
return (error);
if (dmu_objset_type(os) != DMU_OST_ZFS) {
dmu_objset_rele(os, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
error = zfs_obj_to_path(os, zc->zc_obj, zc->zc_value,
sizeof (zc->zc_value));
@@ -1741,7 +1740,7 @@ zfs_ioc_obj_to_stats(zfs_cmd_t *zc)
return (error);
if (dmu_objset_type(os) != DMU_OST_ZFS) {
dmu_objset_rele(os, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
error = zfs_obj_to_stats(os, zc->zc_obj, &zc->zc_stat, zc->zc_value,
sizeof (zc->zc_value));
@@ -1783,7 +1782,7 @@ zfs_ioc_vdev_add(zfs_cmd_t *zc)
if (spa_bootfs(spa) != 0 && nl2cache == 0 && nspares == 0) {
nvlist_free(config);
spa_close(spa, FTAG);
- return (EDOM);
+ return (SET_ERROR(EDOM));
}
if (error == 0) {
@@ -1849,7 +1848,7 @@ zfs_ioc_vdev_set_state(zfs_cmd_t *zc)
break;
default:
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
}
zc->zc_cookie = newstate;
spa_close(spa, FTAG);
@@ -2044,7 +2043,7 @@ zfs_ioc_objset_recvd_props(zfs_cmd_t *zc)
* SPA_VERSION_RECVD_PROPS.
*/
if (!dsl_prop_get_hasrecvd(zc->zc_name))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (zc->zc_nvlist_dst != 0 &&
(error = dsl_prop_get_received(zc->zc_name, &nv)) == 0) {
@@ -2110,7 +2109,7 @@ zfs_ioc_objset_zplprops(zfs_cmd_t *zc)
err = put_nvlist(zc, nv);
nvlist_free(nv);
} else {
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
}
dmu_objset_rele(os, FTAG);
return (err);
@@ -2157,7 +2156,7 @@ zfs_ioc_dataset_list_next(zfs_cmd_t *zc)
top:
if ((error = dmu_objset_hold(zc->zc_name, FTAG, &os))) {
if (error == ENOENT)
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
return (error);
}
@@ -2171,7 +2170,7 @@ top:
sizeof (zc->zc_name) - (p - zc->zc_name), p,
NULL, &zc->zc_cookie);
if (error == ENOENT)
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
} while (error == 0 && dataset_name_hidden(zc->zc_name));
dmu_objset_rele(os, FTAG);
@@ -2219,7 +2218,7 @@ zfs_ioc_snapshot_list_next(zfs_cmd_t *zc)
*/
if (strlcat(zc->zc_name, "@", sizeof (zc->zc_name)) >= MAXNAMELEN) {
dmu_objset_rele(os, FTAG);
- return (ESRCH);
+ return (SET_ERROR(ESRCH));
}
error = dmu_snapshot_list_next(os,
@@ -2241,7 +2240,7 @@ zfs_ioc_snapshot_list_next(zfs_cmd_t *zc)
dsl_dataset_rele(ds, FTAG);
}
} else if (error == ENOENT) {
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
}
dmu_objset_rele(os, FTAG);
@@ -2270,7 +2269,7 @@ zfs_prop_set_userquota(const char *dsname, nvpair_t *pair)
VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
if (nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
&pair) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -2280,7 +2279,7 @@ zfs_prop_set_userquota(const char *dsname, nvpair_t *pair)
if ((dash = strchr(propname, '-')) == NULL ||
nvpair_value_uint64_array(pair, &valary, &vallen) != 0 ||
vallen != 3)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
domain = dash + 1;
type = valary[0];
@@ -2446,25 +2445,25 @@ retry:
attrs = fnvpair_value_nvlist(pair);
if (nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
&propval) != 0)
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
}
/* Validate value type */
if (err == 0 && prop == ZPROP_INVAL) {
if (zfs_prop_user(propname)) {
if (nvpair_type(propval) != DATA_TYPE_STRING)
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
} else if (zfs_prop_userquota(propname)) {
if (nvpair_type(propval) !=
DATA_TYPE_UINT64_ARRAY)
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
} else {
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
}
} else if (err == 0) {
if (nvpair_type(propval) == DATA_TYPE_STRING) {
if (zfs_prop_get_type(prop) != PROP_TYPE_STRING)
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
} else if (nvpair_type(propval) == DATA_TYPE_UINT64) {
const char *unused;
@@ -2474,19 +2473,19 @@ retry:
case PROP_TYPE_NUMBER:
break;
case PROP_TYPE_STRING:
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
break;
case PROP_TYPE_INDEX:
if (zfs_prop_index_to_string(prop,
intval, &unused) != 0)
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
break;
default:
cmn_err(CE_PANIC,
"unknown property type");
}
} else {
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
}
}
@@ -2583,18 +2582,18 @@ zfs_check_userprops(const char *fsname, nvlist_t *nvl)
if (!zfs_prop_user(propname) ||
nvpair_type(pair) != DATA_TYPE_STRING)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if ((error = zfs_secpolicy_write_perms(fsname,
ZFS_DELEG_PERM_USERPROP, CRED())))
return (error);
if (strlen(propname) >= ZAP_MAXNAMELEN)
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
VERIFY(nvpair_value_string(pair, &valstr) == 0);
if (strlen(valstr) >= ZAP_MAXVALUELEN)
- return (E2BIG);
+ return (SET_ERROR(E2BIG));
}
return (0);
}
@@ -2714,12 +2713,12 @@ zfs_ioc_inherit_prop(zfs_cmd_t *zc)
*/
if (prop == ZPROP_INVAL) {
if (!zfs_prop_user(propname))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
type = PROP_TYPE_STRING;
} else if (prop == ZFS_PROP_VOLSIZE ||
prop == ZFS_PROP_VERSION) {
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
} else {
type = zfs_prop_get_type(prop);
}
@@ -2736,7 +2735,7 @@ zfs_ioc_inherit_prop(zfs_cmd_t *zc)
break;
default:
nvlist_free(dummy);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
pair = nvlist_next_nvpair(dummy, NULL);
@@ -2752,7 +2751,7 @@ zfs_ioc_inherit_prop(zfs_cmd_t *zc)
* they are not considered inheritable.
*/
if (prop != ZPROP_INVAL && !zfs_prop_inheritable(prop))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/* property name has been validated by zfs_secpolicy_inherit_prop() */
@@ -2829,7 +2828,7 @@ zfs_ioc_pool_get_props(zfs_cmd_t *zc)
if (error == 0 && zc->zc_nvlist_dst != 0)
error = put_nvlist(zc, nvp);
else
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
nvlist_free(nvp);
return (error);
@@ -2882,7 +2881,7 @@ zfs_ioc_set_fsacl(zfs_cmd_t *zc)
*/
if ((error = zfs_deleg_verify_nvlist(fsaclnv)) != 0) {
nvlist_free(fsaclnv);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -3005,7 +3004,7 @@ zfs_fill_zplprops_impl(objset_t *os, uint64_t zplver,
(zplver < ZPL_VERSION_NORMALIZATION &&
(norm != ZFS_PROP_UNDEFINED || u8 != ZFS_PROP_UNDEFINED ||
sense != ZFS_PROP_UNDEFINED)))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
/*
* Put the version in the zplprops
@@ -3120,7 +3119,7 @@ zfs_ioc_create(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
boolean_t is_insensitive = B_FALSE;
if (nvlist_lookup_int32(innvl, "type", &type32) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
type = type32;
(void) nvlist_lookup_nvlist(innvl, "props", &nvprops);
@@ -3139,26 +3138,26 @@ zfs_ioc_create(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
}
if (strchr(fsname, '@') ||
strchr(fsname, '%'))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
zct.zct_props = nvprops;
if (cbfunc == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (type == DMU_OST_ZVOL) {
uint64_t volsize, volblocksize;
if (nvprops == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (nvlist_lookup_uint64(nvprops,
zfs_prop_to_name(ZFS_PROP_VOLSIZE), &volsize) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if ((error = nvlist_lookup_uint64(nvprops,
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE),
&volblocksize)) != 0 && error != ENOENT)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (error != 0)
volblocksize = zfs_prop_default_numeric(
@@ -3221,15 +3220,15 @@ zfs_ioc_clone(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
char *origin_name;
if (nvlist_lookup_string(innvl, "origin", &origin_name) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
(void) nvlist_lookup_nvlist(innvl, "props", &nvprops);
if (strchr(fsname, '@') ||
strchr(fsname, '%'))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (dataset_namecheck(origin_name, NULL, NULL) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = dmu_objset_clone(fsname, origin_name);
if (error != 0)
return (error);
@@ -3268,10 +3267,10 @@ zfs_ioc_snapshot(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
if (!nvlist_empty(props) &&
zfs_earlier_version(poolname, SPA_VERSION_SNAP_PROPS))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
poollen = strlen(poolname);
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
pair = nvlist_next_nvpair(snaps, pair)) {
@@ -3283,21 +3282,21 @@ zfs_ioc_snapshot(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
* contain only valid characters.
*/
if (cp == NULL || snapshot_namecheck(cp + 1, NULL, NULL) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* The snap must be in the specified pool.
*/
if (strncmp(name, poolname, poollen) != 0 ||
(name[poollen] != '/' && name[poollen] != '@'))
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
/* This must be the only snap of this fs. */
for (pair2 = nvlist_next_nvpair(snaps, pair);
pair2 != NULL; pair2 = nvlist_next_nvpair(snaps, pair2)) {
if (strncmp(name, nvpair_name(pair2), cp - name + 1)
== 0) {
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
}
}
}
@@ -3334,12 +3333,12 @@ zfs_ioc_log_history(const char *unused, nvlist_t *innvl, nvlist_t *outnvl)
if (nvlist_lookup_string(innvl, "message", &message) != 0) {
spa_close(spa, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (spa_version(spa) < SPA_VERSION_ZPOOL_HISTORY) {
spa_close(spa, FTAG);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
error = spa_history_log(spa, message);
@@ -3432,7 +3431,7 @@ zfs_ioc_destroy_snaps(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
boolean_t defer;
if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
defer = nvlist_exists(innvl, "defer");
poollen = strlen(poolname);
@@ -3445,7 +3444,7 @@ zfs_ioc_destroy_snaps(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
*/
if (strncmp(name, poolname, poollen) != 0 ||
(name[poollen] != '/' && name[poollen] != '@'))
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
zfs_unmount_snap(name);
(void) zvol_remove_minor(name);
@@ -3536,13 +3535,13 @@ zfs_ioc_rename(zfs_cmd_t *zc)
zc->zc_value[sizeof (zc->zc_value) - 1] = '\0';
if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
strchr(zc->zc_value, '%'))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
at = strchr(zc->zc_name, '@');
if (at != NULL) {
/* snaps must be in same fs */
if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1))
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
*at = '\0';
if (zc->zc_objset_type == DMU_OST_ZFS) {
int error = dmu_objset_find(zc->zc_name,
@@ -3595,7 +3594,7 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
perm = ZFS_DELEG_PERM_GROUPQUOTA;
} else {
/* USERUSED and GROUPUSED are read-only */
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if ((err = zfs_secpolicy_write_perms(dsname, perm, cr)))
@@ -3603,11 +3602,11 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
return (0);
}
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (issnap)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
/*
@@ -3636,13 +3635,13 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
intval <= ZIO_COMPRESS_GZIP_9 &&
zfs_earlier_version(dsname,
SPA_VERSION_GZIP_COMPRESSION)) {
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if (intval == ZIO_COMPRESS_ZLE &&
zfs_earlier_version(dsname,
SPA_VERSION_ZLE_COMPRESSION))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (intval == ZIO_COMPRESS_LZ4) {
zfeature_info_t *feature =
@@ -3655,7 +3654,7 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
if (!spa_feature_is_enabled(spa, feature)) {
spa_close(spa, FTAG);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
spa_close(spa, FTAG);
}
@@ -3669,24 +3668,24 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
*/
if (zfs_is_bootfs(dsname) &&
!BOOTFS_COMPRESS_VALID(intval)) {
- return (ERANGE);
+ return (SET_ERROR(ERANGE));
}
}
break;
case ZFS_PROP_COPIES:
if (zfs_earlier_version(dsname, SPA_VERSION_DITTO_BLOCKS))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
break;
case ZFS_PROP_DEDUP:
if (zfs_earlier_version(dsname, SPA_VERSION_DEDUP))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
break;
case ZFS_PROP_SHARESMB:
if (zpl_earlier_version(dsname, ZPL_VERSION_FUID))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
break;
case ZFS_PROP_ACLINHERIT:
@@ -3695,7 +3694,7 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
if (intval == ZFS_ACL_PASSTHROUGH_X &&
zfs_earlier_version(dsname,
SPA_VERSION_PASSTHROUGH_X))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
break;
default:
@@ -3718,7 +3717,7 @@ zfs_prop_activate_feature_check(void *arg, dmu_tx_t *tx)
if (!spa_feature_is_active(spa, feature))
return (0);
else
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
/*
@@ -3926,7 +3925,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
strchr(zc->zc_value, '@') == NULL ||
strchr(zc->zc_value, '%'))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
(void) strcpy(tofs, zc->zc_value);
tosnap = strchr(tofs, '@');
@@ -3941,7 +3940,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
fp = getf(fd);
if (fp == NULL) {
nvlist_free(props);
- return (EBADF);
+ return (SET_ERROR(EBADF));
}
VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0);
@@ -4010,7 +4009,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
* Caller made zc->zc_nvlist_dst less than the minimum expected
* size or supplied an invalid address.
*/
- props_error = EINVAL;
+ props_error = SET_ERROR(EINVAL);
}
off = fp->f_offset;
@@ -4172,7 +4171,7 @@ zfs_ioc_send(zfs_cmd_t *zc)
} else {
file_t *fp = getf(zc->zc_cookie);
if (fp == NULL)
- return (EBADF);
+ return (SET_ERROR(EBADF));
off = fp->f_offset;
error = dmu_send_obj(zc->zc_name, zc->zc_sendobj,
@@ -4230,7 +4229,7 @@ zfs_ioc_send_progress(zfs_cmd_t *zc)
if (dsp != NULL)
zc->zc_cookie = *(dsp->dsa_off);
else
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
mutex_exit(&ds->ds_sendstream_lock);
dsl_dataset_rele(ds, FTAG);
@@ -4308,7 +4307,7 @@ zfs_ioc_clear(zfs_cmd_t *zc)
spa = spa_lookup(zc->zc_name);
if (spa == NULL) {
mutex_exit(&spa_namespace_lock);
- return (EIO);
+ return (SET_ERROR(EIO));
}
if (spa_get_log_state(spa) == SPA_LOG_MISSING) {
/* we need to let spa_open/spa_load clear the chains */
@@ -4324,7 +4323,7 @@ zfs_ioc_clear(zfs_cmd_t *zc)
nvlist_t *config = NULL;
if (zc->zc_nvlist_src == 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if ((error = get_nvlist(zc->zc_nvlist_src,
zc->zc_nvlist_src_size, zc->zc_iflags, &policy)) == 0) {
@@ -4353,7 +4352,7 @@ zfs_ioc_clear(zfs_cmd_t *zc)
if (vd == NULL) {
(void) spa_vdev_state_exit(spa, NULL, ENODEV);
spa_close(spa, FTAG);
- return (ENODEV);
+ return (SET_ERROR(ENODEV));
}
}
@@ -4365,7 +4364,7 @@ zfs_ioc_clear(zfs_cmd_t *zc)
* Resume any suspended I/Os.
*/
if (zio_resume(spa) != 0)
- error = EIO;
+ error = SET_ERROR(EIO);
spa_close(spa, FTAG);
@@ -4442,7 +4441,7 @@ zfs_ioc_userspace_one(zfs_cmd_t *zc)
int error;
if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = zfs_sb_hold(zc->zc_name, FTAG, &zsb, B_FALSE);
if (error != 0)
@@ -4475,7 +4474,7 @@ zfs_ioc_userspace_many(zfs_cmd_t *zc)
void *buf;
if (bufsize <= 0)
- return (ENOMEM);
+ return (SET_ERROR(ENOMEM));
error = zfs_sb_hold(zc->zc_name, FTAG, &zsb, B_FALSE);
if (error != 0)
@@ -4541,7 +4540,7 @@ zfs_ioc_userspace_upgrade(zfs_cmd_t *zc)
static int
zfs_ioc_share(zfs_cmd_t *zc)
{
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
}
ace_t full_access[] = {
@@ -4626,7 +4625,7 @@ zfs_ioc_diff(zfs_cmd_t *zc)
fp = getf(zc->zc_cookie);
if (fp == NULL)
- return (EBADF);
+ return (SET_ERROR(EBADF));
off = fp->f_offset;
@@ -4688,7 +4687,7 @@ zfs_ioc_smb_acl(zfs_cmd_t *zc)
(strcmp((char *)refstr_value(vp->v_vfsp->vfs_resource),
zc->zc_name) != 0)) {
VN_RELE(vp);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
dzp = VTOZ(vp);
@@ -4778,7 +4777,7 @@ zfs_ioc_smb_acl(zfs_cmd_t *zc)
break;
default:
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
@@ -4789,7 +4788,7 @@ zfs_ioc_smb_acl(zfs_cmd_t *zc)
return (error);
#else
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
#endif /* HAVE_SMB_SHARE */
}
@@ -4815,7 +4814,7 @@ zfs_ioc_hold(const char *pool, nvlist_t *args, nvlist_t *errlist)
error = nvlist_lookup_nvlist(args, "holds", &holds);
if (error != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (nvlist_lookup_int32(args, "cleanup_fd", &cleanup_fd) == 0) {
error = zfs_onexit_fd_hold(cleanup_fd, &minor);
@@ -4995,7 +4994,7 @@ zfs_ioc_space_snaps(const char *lastsnap, nvlist_t *innvl, nvlist_t *outnvl)
uint64_t used, comp, uncomp;
if (nvlist_lookup_string(innvl, "firstsnap", &firstsnap) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = dsl_pool_hold(lastsnap, FTAG, &dp);
if (error != 0)
@@ -5043,12 +5042,12 @@ zfs_ioc_send_new(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
error = nvlist_lookup_int32(innvl, "fd", &fd);
if (error != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
(void) nvlist_lookup_string(innvl, "fromsnap", &fromname);
if ((fp = getf(fd)) == NULL)
- return (EBADF);
+ return (SET_ERROR(EBADF));
off = fp->f_offset;
error = dmu_send(snapname, fromname, fd, fp->f_vnode, &off);
@@ -5427,9 +5426,9 @@ pool_status_check(const char *name, zfs_ioc_namecheck_t type,
error = spa_open(name, &spa, FTAG);
if (error == 0) {
if ((check & POOL_CHECK_SUSPENDED) && spa_suspended(spa))
- error = EAGAIN;
+ error = SET_ERROR(EAGAIN);
else if ((check & POOL_CHECK_READONLY) && !spa_writeable(spa))
- error = EROFS;
+ error = SET_ERROR(EROFS);
spa_close(spa, FTAG);
}
return (error);
@@ -5511,7 +5510,7 @@ zfsdev_state_init(struct file *filp)
minor = zfsdev_minor_alloc();
if (minor == 0)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
zs = kmem_zalloc( sizeof(zfsdev_state_t), KM_SLEEP);
@@ -5581,14 +5580,14 @@ zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
vecnum = cmd - ZFS_IOC_FIRST;
if (vecnum >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0]))
- return (-EINVAL);
+ return (-SET_ERROR(EINVAL));
vec = &zfs_ioc_vec[vecnum];
zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP | KM_NODEBUG);
error = ddi_copyin((void *)arg, zc, sizeof (zfs_cmd_t), flag);
if (error != 0) {
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
goto out;
}
@@ -5608,7 +5607,7 @@ zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
switch (vec->zvec_namecheck) {
case POOL_NAME:
if (pool_namecheck(zc->zc_name, NULL, NULL) != 0)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
else
error = pool_status_check(zc->zc_name,
vec->zvec_namecheck, vec->zvec_pool_check);
@@ -5616,7 +5615,7 @@ zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
case DATASET_NAME:
if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
else
error = pool_status_check(zc->zc_name,
vec->zvec_namecheck, vec->zvec_pool_check);
@@ -5696,7 +5695,7 @@ out:
nvlist_free(innvl);
rc = ddi_copyout(zc, (void *)arg, sizeof (zfs_cmd_t), flag);
if (error == 0 && rc != 0)
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
if (error == 0 && vec->zvec_allow_log) {
char *s = tsd_get(zfs_allow_log_key);
if (s != NULL)