return zfs_remove_prop(zhp, nvl, propname);
}
+static int zfs_is_special_ldd_prop_param(char *name)
+{
+ int i;
+
+ for (i = 0; special_ldd_prop_params[i].zlpb_prop_name != NULL; i++)
+ if (!strcmp(name, special_ldd_prop_params[i].zlpb_prop_name))
+ return 1;
+
+ return 0;
+}
+
static int zfs_erase_allprops(zfs_handle_t *zhp)
{
- nvlist_t *nvl;
- nvpair_t *curr = NULL;
+ nvlist_t *props;
+ nvpair_t *nvp;
+ size_t str_size = 1024 * 1024;
+ char *strs, *cur;
+ int rc = 0;
- nvl = zfs_get_user_props(zhp);
- if (!nvl)
+ strs = malloc(str_size);
+ if (!strs)
+ return ENOMEM;
+ cur = strs;
+
+ props = zfs_get_user_props(zhp);
+ if (props == NULL) {
+ free(strs);
return ENOENT;
+ }
+ nvp = NULL;
+ while (nvp = nvlist_next_nvpair(props, nvp), nvp) {
+ if (strncmp(nvpair_name(nvp), LDD_PREFIX, strlen(LDD_PREFIX)))
+ continue;
- curr = nvlist_next_nvpair(nvl, curr);
- while (curr) {
- nvpair_t *next = nvlist_next_nvpair(nvl, curr);
+ if (zfs_is_special_ldd_prop_param(nvpair_name(nvp)))
+ continue;
- zfs_remove_prop(zhp, nvl, nvpair_name(curr));
- curr = next;
+ rc = snprintf(cur, str_size - (cur - strs), "%s",
+ nvpair_name(nvp));
+ if (rc != strlen(nvpair_name(nvp))) {
+ fprintf(stderr, "%s: zfs has too many properties to erase, please repeat\n",
+ progname);
+ rc = EINVAL;
+ break;
+ }
+ cur += strlen(cur) + 1;
+ }
+ cur = strs;
+ while ( cur < (strs + str_size) && strlen(cur) > 0) {
+ zfs_prop_inherit(zhp, cur, false);
+ cur += strlen(cur) + 1;
}
- return 0;
+ free(strs);
+ return rc;
}
/*
* ZFS on linux 0.7.0-rc5 commit 379ca9cf2beba802f096273e89e30914a2d6bafc
return ret;
}
-static int zfs_is_special_ldd_prop_param(char *name)
-{
- int i;
-
- for (i = 0; special_ldd_prop_params[i].zlpb_prop_name != NULL; i++)
- if (!strcmp(name, special_ldd_prop_params[i].zlpb_prop_name))
- return 1;
-
- return 0;
-}
-
static int zfs_get_prop_params(zfs_handle_t *zhp, char *param)
{
nvlist_t *props;
snprintf(str, len, " -o %s", mop->mo_mkfsopts);
if (mop->mo_device_kb)
snprintf(str, len, " -o quota=%llu",
- mop->mo_device_kb * 1024);
+ (unsigned long long)mop->mo_device_kb * 1024);
return str;
}