summaryrefslogtreecommitdiff
path: root/fs/fs_parser.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2019-09-06 22:12:08 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2020-02-07 00:12:50 -0500
commit2710c957a8ef4fb00f21acb306e3bd6bcf80c81f (patch)
treeda60d8ec6779b64cbc29ca2b161ed9b9c0b2834e /fs/fs_parser.c
parent0f89589a8c6f1033cb847a606517998efb0da8ee (diff)
downloadlwn-2710c957a8ef4fb00f21acb306e3bd6bcf80c81f.tar.gz
lwn-2710c957a8ef4fb00f21acb306e3bd6bcf80c81f.zip
fs_parse: get rid of ->enums
Don't do a single array; attach them to fsparam_enum() entry instead. And don't bother trying to embed the names into those - it actually loses memory, with no real speedup worth mentioning. Simplifies validation as well. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/fs_parser.c')
-rw-r--r--fs/fs_parser.c72
1 files changed, 9 insertions, 63 deletions
diff --git a/fs/fs_parser.c b/fs/fs_parser.c
index 07ae041b83a8..34275191697f 100644
--- a/fs/fs_parser.c
+++ b/fs/fs_parser.c
@@ -189,9 +189,8 @@ int fs_parse(struct fs_context *fc,
goto maybe_okay;
case fs_param_is_enum:
- for (e = desc->enums; e->name[0]; e++) {
- if (e->opt == p->opt &&
- strcmp(e->name, param->string) == 0) {
+ for (e = p->data; e->name; e++) {
+ if (strcmp(e->name, param->string) == 0) {
result->uint_32 = e->value;
goto okay;
}
@@ -359,10 +358,8 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size,
bool fs_validate_description(const struct fs_parameter_description *desc)
{
const struct fs_parameter_spec *param, *p2;
- const struct fs_parameter_enum *e;
const char *name = desc->name;
- unsigned int nr_params = 0;
- bool good = true, enums = false;
+ bool good = true;
pr_notice("*** VALIDATE %s ***\n", name);
@@ -383,7 +380,12 @@ bool fs_validate_description(const struct fs_parameter_description *desc)
name, param->name, t);
good = false;
} else if (t == fs_param_is_enum) {
- enums = true;
+ const struct fs_parameter_enum *e = param->data;
+ if (!e || !e->name) {
+ pr_err("VALIDATE %s: PARAM[%s] enum with no values\n",
+ name, param->name);
+ good = false;
+ }
}
/* Check for duplicate parameter names */
@@ -395,63 +397,7 @@ bool fs_validate_description(const struct fs_parameter_description *desc)
}
}
}
-
- nr_params = param - desc->specs;
- }
-
- if (desc->enums) {
- if (!nr_params) {
- pr_err("VALIDATE %s: Enum table but no parameters\n",
- name);
- good = false;
- goto no_enums;
- }
- if (!enums) {
- pr_err("VALIDATE %s: Enum table but no enum-type values\n",
- name);
- good = false;
- goto no_enums;
- }
-
- for (e = desc->enums; e->name[0]; e++) {
- /* Check that all entries in the enum table have at
- * least one parameter that uses them.
- */
- for (param = desc->specs; param->name; param++) {
- if (param->opt == e->opt &&
- param->type != fs_param_is_enum) {
- pr_err("VALIDATE %s: e[%tu] enum val for %s\n",
- name, e - desc->enums, param->name);
- good = false;
- }
- }
- }
-
- /* Check that all enum-type parameters have at least one enum
- * value in the enum table.
- */
- for (param = desc->specs; param->name; param++) {
- if (param->type != fs_param_is_enum)
- continue;
- for (e = desc->enums; e->name[0]; e++)
- if (e->opt == param->opt)
- break;
- if (!e->name[0]) {
- pr_err("VALIDATE %s: PARAM[%s] enum with no values\n",
- name, param->name);
- good = false;
- }
- }
- } else {
- if (enums) {
- pr_err("VALIDATE %s: enum-type values, but no enum table\n",
- name);
- good = false;
- goto no_enums;
- }
}
-
-no_enums:
return good;
}
#endif /* CONFIG_VALIDATE_FS_PARSER */