MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zfs_check_settable

Function zfs_check_settable

freebsd/contrib/openzfs/module/zfs/zfs_ioctl.c:4370–4611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4368}
4369
4370static int
4371zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
4372{
4373 const char *propname = nvpair_name(pair);
4374 boolean_t issnap = (strchr(dsname, '@') != NULL);
4375 zfs_prop_t prop = zfs_name_to_prop(propname);
4376 uint64_t intval, compval;
4377 int err;
4378
4379 if (prop == ZPROP_INVAL) {
4380 if (zfs_prop_user(propname)) {
4381 if ((err = zfs_secpolicy_write_perms(dsname,
4382 ZFS_DELEG_PERM_USERPROP, cr)))
4383 return (err);
4384 return (0);
4385 }
4386
4387 if (!issnap && zfs_prop_userquota(propname)) {
4388 const char *perm = NULL;
4389 const char *uq_prefix =
4390 zfs_userquota_prop_prefixes[ZFS_PROP_USERQUOTA];
4391 const char *gq_prefix =
4392 zfs_userquota_prop_prefixes[ZFS_PROP_GROUPQUOTA];
4393 const char *uiq_prefix =
4394 zfs_userquota_prop_prefixes[ZFS_PROP_USEROBJQUOTA];
4395 const char *giq_prefix =
4396 zfs_userquota_prop_prefixes[ZFS_PROP_GROUPOBJQUOTA];
4397 const char *pq_prefix =
4398 zfs_userquota_prop_prefixes[ZFS_PROP_PROJECTQUOTA];
4399 const char *piq_prefix = zfs_userquota_prop_prefixes[\
4400 ZFS_PROP_PROJECTOBJQUOTA];
4401
4402 if (strncmp(propname, uq_prefix,
4403 strlen(uq_prefix)) == 0) {
4404 perm = ZFS_DELEG_PERM_USERQUOTA;
4405 } else if (strncmp(propname, uiq_prefix,
4406 strlen(uiq_prefix)) == 0) {
4407 perm = ZFS_DELEG_PERM_USEROBJQUOTA;
4408 } else if (strncmp(propname, gq_prefix,
4409 strlen(gq_prefix)) == 0) {
4410 perm = ZFS_DELEG_PERM_GROUPQUOTA;
4411 } else if (strncmp(propname, giq_prefix,
4412 strlen(giq_prefix)) == 0) {
4413 perm = ZFS_DELEG_PERM_GROUPOBJQUOTA;
4414 } else if (strncmp(propname, pq_prefix,
4415 strlen(pq_prefix)) == 0) {
4416 perm = ZFS_DELEG_PERM_PROJECTQUOTA;
4417 } else if (strncmp(propname, piq_prefix,
4418 strlen(piq_prefix)) == 0) {
4419 perm = ZFS_DELEG_PERM_PROJECTOBJQUOTA;
4420 } else {
4421 /* {USER|GROUP|PROJECT}USED are read-only */
4422 return (SET_ERROR(EINVAL));
4423 }
4424
4425 if ((err = zfs_secpolicy_write_perms(dsname, perm, cr)))
4426 return (err);
4427 return (0);

Callers 2

zfs_set_prop_nvlistFunction · 0.85
zfs_check_clearableFunction · 0.85

Calls 15

strchrFunction · 0.85
zfs_name_to_propFunction · 0.85
zfs_prop_userFunction · 0.85
zfs_prop_userquotaFunction · 0.85
strncmpFunction · 0.85
nvpair_value_nvlistFunction · 0.85
nvlist_lookup_nvpairFunction · 0.85
nvpair_value_uint64Function · 0.85
zfs_earlier_versionFunction · 0.85
spa_openFunction · 0.85
spa_feature_is_enabledFunction · 0.85

Tested by

no test coverage detected