if (*key) {
struct fs_parameter param = {
.key = key,
- .type = fs_value_is_string,
+ .type = fs_value_is_flag,
};
char *value = strchr(key, '=');
size_t v_len = 0;
continue;
*value++ = 0;
v_len = strlen(value);
- }
-
-
- if (v_len > 0) {
param.string = kmemdup_nul(value, v_len,
GFP_KERNEL);
if (!param.string)
return -ENOMEM;
+ param.type = fs_value_is_string;
}
param.size = v_len;
struct fs_parameter param = {
.key = key,
- .type = fs_value_is_string,
+ .type = fs_value_is_flag,
.size = v_size,
};
- if (v_size > 0) {
+ if (value) {
param.string = kmemdup_nul(value, v_size, GFP_KERNEL);
if (!param.string)
return -ENOMEM;
+ param.type = fs_value_is_string;
}
ret = vfs_parse_fs_param(fc, ¶m);
const struct fs_parameter_enum *e;
int ret = -ENOPARAM, b;
- result->has_value = !!param->string;
result->negated = false;
result->uint_64 = 0;
* "xxx" takes the "no"-form negative - but only if there
* wasn't an value.
*/
- if (result->has_value)
+ if (param->type != fs_value_is_flag)
goto unknown_parameter;
if (param->key[0] != 'n' || param->key[1] != 'o' || !param->key[2])
goto unknown_parameter;
case fs_param_is_u64:
case fs_param_is_enum:
case fs_param_is_string:
- if (param->type != fs_value_is_string)
- goto bad_value;
- if (!result->has_value) {
+ if (param->type == fs_value_is_string) {
+ if (p->flags & fs_param_v_optional)
+ break;
+ if (!*param->string)
+ goto bad_value;
+ break;
+ }
+ if (param->type == fs_value_is_flag) {
if (p->flags & fs_param_v_optional)
goto okay;
- goto bad_value;
}
- /* Fall through */
+ goto bad_value;
default:
break;
}
*/
switch (p->type) {
case fs_param_is_flag:
- if (param->type != fs_value_is_flag &&
- (param->type != fs_value_is_string || result->has_value))
+ if (param->type != fs_value_is_flag)
return invalf(fc, "%s: Unexpected value for '%s'",
desc->name, param->key);
result->boolean = true;
case fs_param_is_fd: {
switch (param->type) {
case fs_value_is_string:
- if (!result->has_value)
- goto bad_value;
-
ret = kstrtouint(param->string, 0, &result->uint_32);
break;
case fs_value_is_file:
*/
struct fs_parse_result {
bool negated; /* T if param was "noxxx" */
- bool has_value; /* T if value supplied to param */
union {
bool boolean; /* For spec_bool */
int int_32; /* For spec_s32/spec_enum */