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

Function zfs_check_clearable

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

* Removes properties from the given props list that fail permission checks * needed to clear them and to restore them in case of a receive error. For each * property, make sure we have both set and inherit permissions. * * Returns the first error encountered if any permission checks fail. If the * caller provides a non-NULL errlist, it also gives the complete list of names * of all the prope

Source from the content-addressed store, hash-verified

4625 * pointed at by errlist is NULL.
4626 */
4627static int
4628zfs_check_clearable(const char *dataset, nvlist_t *props, nvlist_t **errlist)
4629{
4630 zfs_cmd_t *zc;
4631 nvpair_t *pair, *next_pair;
4632 nvlist_t *errors;
4633 int err, rv = 0;
4634
4635 if (props == NULL)
4636 return (0);
4637
4638 VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0);
4639
4640 zc = kmem_alloc(sizeof (zfs_cmd_t), KM_SLEEP);
4641 (void) strlcpy(zc->zc_name, dataset, sizeof (zc->zc_name));
4642 pair = nvlist_next_nvpair(props, NULL);
4643 while (pair != NULL) {
4644 next_pair = nvlist_next_nvpair(props, pair);
4645
4646 (void) strlcpy(zc->zc_value, nvpair_name(pair),
4647 sizeof (zc->zc_value));
4648 if ((err = zfs_check_settable(dataset, pair, CRED())) != 0 ||
4649 (err = zfs_secpolicy_inherit_prop(zc, NULL, CRED())) != 0) {
4650 VERIFY(nvlist_remove_nvpair(props, pair) == 0);
4651 VERIFY(nvlist_add_int32(errors,
4652 zc->zc_value, err) == 0);
4653 }
4654 pair = next_pair;
4655 }
4656 kmem_free(zc, sizeof (zfs_cmd_t));
4657
4658 if ((pair = nvlist_next_nvpair(errors, NULL)) == NULL) {
4659 nvlist_free(errors);
4660 errors = NULL;
4661 } else {
4662 VERIFY(nvpair_value_int32(pair, &rv) == 0);
4663 }
4664
4665 if (errlist == NULL)
4666 nvlist_free(errors);
4667 else
4668 *errlist = errors;
4669
4670 return (rv);
4671}
4672
4673static boolean_t
4674propval_equals(nvpair_t *p1, nvpair_t *p2)

Callers 1

zfs_ioc_recv_implFunction · 0.85

Calls 11

nvlist_allocFunction · 0.85
zfs_check_settableFunction · 0.85
nvlist_remove_nvpairFunction · 0.85
nvlist_add_int32Function · 0.85
nvpair_value_int32Function · 0.85
strlcpyFunction · 0.50
nvlist_next_nvpairFunction · 0.50
nvpair_nameFunction · 0.50
kmem_freeFunction · 0.50
nvlist_freeFunction · 0.50

Tested by

no test coverage detected