libzfs: tokenise consistently with zfs and zpool
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12996
This commit is contained in:
parent
4695230021
commit
539d16c35e
|
@ -1749,14 +1749,10 @@ error:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
addlist(libzfs_handle_t *hdl, char *propname, zprop_list_t **listp,
|
addlist(libzfs_handle_t *hdl, const char *propname, zprop_list_t **listp,
|
||||||
zfs_type_t type)
|
zfs_type_t type)
|
||||||
{
|
{
|
||||||
int prop;
|
int prop = zprop_name_to_prop(propname, type);
|
||||||
zprop_list_t *entry;
|
|
||||||
|
|
||||||
prop = zprop_name_to_prop(propname, type);
|
|
||||||
|
|
||||||
if (prop != ZPROP_INVAL && !zprop_valid_for_type(prop, type, B_FALSE))
|
if (prop != ZPROP_INVAL && !zprop_valid_for_type(prop, type, B_FALSE))
|
||||||
prop = ZPROP_INVAL;
|
prop = ZPROP_INVAL;
|
||||||
|
|
||||||
|
@ -1776,7 +1772,8 @@ addlist(libzfs_handle_t *hdl, char *propname, zprop_list_t **listp,
|
||||||
dgettext(TEXT_DOMAIN, "bad property list")));
|
dgettext(TEXT_DOMAIN, "bad property list")));
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = zfs_alloc(hdl, sizeof (zprop_list_t));
|
zprop_list_t *entry = zfs_alloc(hdl, sizeof (*entry));
|
||||||
|
|
||||||
entry->pl_prop = prop;
|
entry->pl_prop = prop;
|
||||||
if (prop == ZPROP_INVAL) {
|
if (prop == ZPROP_INVAL) {
|
||||||
entry->pl_user_prop = zfs_strdup(hdl, propname);
|
entry->pl_user_prop = zfs_strdup(hdl, propname);
|
||||||
|
@ -1819,62 +1816,25 @@ zprop_get_list(libzfs_handle_t *hdl, char *props, zprop_list_t **listp,
|
||||||
"bad property list")));
|
"bad property list")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
for (char *p; (p = strsep(&props, ",")); )
|
||||||
* It would be nice to use getsubopt() here, but the inclusion of column
|
if (strcmp(p, "space") == 0) {
|
||||||
* aliases makes this more effort than it's worth.
|
static const char *const spaceprops[] = {
|
||||||
*/
|
|
||||||
while (*props != '\0') {
|
|
||||||
size_t len;
|
|
||||||
char *p;
|
|
||||||
char c;
|
|
||||||
|
|
||||||
if ((p = strchr(props, ',')) == NULL) {
|
|
||||||
len = strlen(props);
|
|
||||||
p = props + len;
|
|
||||||
} else {
|
|
||||||
len = p - props;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check for empty options.
|
|
||||||
*/
|
|
||||||
if (len == 0) {
|
|
||||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
|
||||||
"empty property name"));
|
|
||||||
return (zfs_error(hdl, EZFS_BADPROP,
|
|
||||||
dgettext(TEXT_DOMAIN, "bad property list")));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check all regular property names.
|
|
||||||
*/
|
|
||||||
c = props[len];
|
|
||||||
props[len] = '\0';
|
|
||||||
|
|
||||||
if (strcmp(props, "space") == 0) {
|
|
||||||
static char *spaceprops[] = {
|
|
||||||
"name", "avail", "used", "usedbysnapshots",
|
"name", "avail", "used", "usedbysnapshots",
|
||||||
"usedbydataset", "usedbyrefreservation",
|
"usedbydataset", "usedbyrefreservation",
|
||||||
"usedbychildren", NULL
|
"usedbychildren"
|
||||||
};
|
};
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; spaceprops[i]; i++) {
|
for (int i = 0; i < ARRAY_SIZE(spaceprops); i++) {
|
||||||
if (addlist(hdl, spaceprops[i], listp, type))
|
if (addlist(hdl, spaceprops[i], listp, type))
|
||||||
return (-1);
|
return (-1);
|
||||||
listp = &(*listp)->pl_next;
|
listp = &(*listp)->pl_next;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (addlist(hdl, props, listp, type))
|
if (addlist(hdl, p, listp, type))
|
||||||
return (-1);
|
return (-1);
|
||||||
listp = &(*listp)->pl_next;
|
listp = &(*listp)->pl_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
props = p;
|
|
||||||
if (c == ',')
|
|
||||||
props++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue