fs: fs_parser: remove fs_parameter_description name field
Subsystems (10)
PATCH 1/1 fs: fs_parser: remove fs_parameter_description name field
There doesn't seem to be a strong reason to have another copy of the filesystem name string in the fs_parameter_description structure; it's easy enough to get the name from the fs_type, and using it instead ensures consistency across messages (for example, vfs_parse_fs_param() already uses fc->fs_type->name for the error messages, because it doesn't have the fs_parameter_description).
---
If I'm missing a reason for the separate copy of the string, feel free to nak...
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -1
@@ -2047,7 +2047,6 @@ static const struct fs_parameter_spec rdt_param_specs[] = { };static const struct fs_parameter_description rdt_fs_parameters = { - .name ="rdt" , .specs = rdt_param_specs, };
fs/afs/super.c +0 -1
@@ -90,7 +90,6 @@ static const struct fs_parameter_enum afs_param_enums[] = { };static const struct fs_parameter_description afs_fs_parameters = { - .name ="kAFS" , .specs = afs_param_specs, .enums = afs_param_enums, };
fs/filesystems.c +2 -1
@@ -74,7 +74,8 @@ int register_filesystem(struct file_system_type * fs)int res =0 ;struct file_system_type ** p; -if (fs->parameters && !fs_validate_description (fs->parameters)) +if (fs->parameters && + !fs_validate_description (fs->name, fs->parameters))return -EINVAL ;BUG_ON (strchr (fs->name,'.' ));
fs/fs_parser.c +6 -11
@@ -111,7 +111,7 @@ int fs_parse(struct fs_context *fc,if (p->flags & fs_param_deprecated)warnf (fc,"%s: Deprecated parameter '%s'" , - desc->name, param->key); + fc->fs_type->name, param->key);if (result->negated) goto okay;
@@ -147,7 +147,7 @@ int fs_parse(struct fs_context *fc,if (param->type != fs_value_is_flag && (param->type != fs_value_is_string || result->has_value))return invalf (fc,"%s: Unexpected value for '%s'" , - desc->name, param->key); + fc->fs_type->name, param->key); result->boolean = true; goto okay;
@@ -223,7 +223,8 @@ int fs_parse(struct fs_context *fc,return p->opt; bad_value: -return invalf (fc,"%s: Bad value for '%s'" , desc->name, param->key); +return invalf (fc,"%s: Bad value for '%s'" , + fc->fs_type->name, param->key); unknown_parameter:return -ENOPARAM ; }
@@ -343,22 +344,16 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size,* fs_validate_description - Validate a parameter description * @desc: The parameter description to validate. */ -bool fs_validate_description (const struct fs_parameter_description *desc) +bool fs_validate_description (const char *name, +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;pr_notice ("*** VALIDATE %s ***\n" , name); -if (!name[0 ]) { -pr_err ("VALIDATE Parser: No name\n" ); - name ="Unknown" ; - good = false; - } -if (desc->specs) {for (param = desc->specs; param->name; param++) {enum fs_parameter_type t = param->type;
fs/hugetlbfs/inode.c +0 -1
@@ -85,7 +85,6 @@ static const struct fs_parameter_spec hugetlb_param_specs[] = { };static const struct fs_parameter_description hugetlb_fs_parameters = { - .name ="hugetlbfs" , .specs = hugetlb_param_specs, };
fs/proc/root.c +0 -1
@@ -48,7 +48,6 @@ static const struct fs_parameter_spec proc_param_specs[] = { };static const struct fs_parameter_description proc_fs_parameters = { - .name ="proc" , .specs = proc_param_specs, };
include/linux/fs_parser.h +4 -3
@@ -62,7 +62,6 @@ struct fs_parameter_enum { };struct fs_parameter_description { -const char name[16 ];/* Name for logging purposes */ const struct fs_parameter_spec *specs;/* List of param specifications */ const struct fs_parameter_enum *enums;/* Enum values */ };
@@ -97,12 +96,14 @@ extern int __lookup_constant(const struct constant_table tbl[], size_t tbl_size,#ifdef CONFIG_VALIDATE_FS_PARSER extern bool validate_constant_table (const struct constant_table *tbl,size_t tbl_size,int low,int high,int special); -extern bool fs_validate_description (const struct fs_parameter_description *desc); +extern bool fs_validate_description (const char *name, +const struct fs_parameter_description *desc);#else static inline bool validate_constant_table (const struct constant_table *tbl,size_t tbl_size,int low,int high,int special) {return true; } -static inline bool fs_validate_description (const struct fs_parameter_description *desc) +static inline bool fs_validate_description (const char *name, +const struct fs_parameter_description *desc) {return true; }#endif
kernel/cgroup/cgroup-v1.c +0 -1
@@ -918,7 +918,6 @@ static const struct fs_parameter_spec cgroup1_param_specs[] = { };const struct fs_parameter_description cgroup1_fs_parameters = { - .name ="cgroup1" , .specs = cgroup1_param_specs, };
kernel/cgroup/cgroup.c +0 -1
@@ -1826,7 +1826,6 @@ static const struct fs_parameter_spec cgroup2_param_specs[] = { };static const struct fs_parameter_description cgroup2_fs_parameters = { - .name ="cgroup2" , .specs = cgroup2_param_specs, };
security/selinux/hooks.c +1 -2
@@ -2820,7 +2820,6 @@ static const struct fs_parameter_spec selinux_param_specs[] = { };static const struct fs_parameter_description selinux_fs_parameters = { - .name ="SELinux" , .specs = selinux_param_specs, };
@@ -7021,7 +7020,7 @@ static __init int selinux_init(void)else pr_debug ("SELinux: Starting in permissive mode\n" ); -fs_validate_description (&selinux_fs_parameters); +fs_validate_description ("selinux" , &selinux_fs_parameters);return 0 ; }
security/smack/smack_lsm.c +0 -1
@@ -690,7 +690,6 @@ static const struct fs_parameter_spec smack_param_specs[] = { };static const struct fs_parameter_description smack_fs_parameters = { - .name ="smack" , .specs = smack_param_specs, };
David Howells
maintainerQuoted 8 lines · Eric Sandeen
There doesn't seem to be a strong reason to have another copy of the filesystem name string in the
fs_parameter_descriptionstructure; it's easy enough to get the name from thefs_type, and using it instead ensures consistency across messages (for example,vfs_parse_fs_param()already usesfc->fs_type->namefor the error messages, because it doesn't have thefs_parameter_description).Signed-off-by Eric Sandeen <[email protected]>
It was put there for fs_validate_description() to use. That checks both filesystem and LSM parameter descriptions.
We could pass a name in to that function instead.
David
Quoted 9 lines · David Howells
Quoted 7 lines · Eric Sandeen
There doesn't seem to be a strong reason to have another copy of the filesystem name string in the
fs_parameter_descriptionstructure; it's easy enough to get the name from thefs_type, and using it instead ensures consistency across messages (for example,vfs_parse_fs_param()already usesfc->fs_type->namefor the error messages, because it doesn't have thefs_parameter_description).
Quoted 6 lines
Quoted 1 line
Signed-off-by Eric Sandeen <[email protected]>It was put there for
fs_validate_description()to use. That checks both filesystem and LSM parameter descriptions.We could pass a name in to that function instead.
My patch does exactly that, right?
fs/filesystems.c +2 -1
@@ -74,7 +74,8 @@ int register_filesystem(struct file_system_type * fs)int res =0 ;struct file_system_type ** p; -if (fs->parameters && !fs_validate_description (fs->parameters)) +if (fs->parameters && + !fs_validate_description (fs->name, fs->parameters))return -EINVAL ;
....
@@ -7021,7 +7020,7 @@ static __init int selinux_init(void)
else
pr_debug("SELinux: Starting in permissive mode\n");
- fs_validate_description(&selinux_fs_parameters);
+ fs_validate_description("selinux", &selinux_fs_parameters);
return 0;
David Howells
maintainerQuoted 1 line · Eric Sandeen
My patch does exactly that, right?
Sorry, I missed that. Distracted by Linus.
David
Quoted 8 lines · Eric Sandeen
There doesn't seem to be a strong reason to have another copy of the filesystem name string in the
fs_parameter_descriptionstructure; it's easy enough to get the name from thefs_type, and using it instead ensures consistency across messages (for example,vfs_parse_fs_param()already usesfc->fs_type->namefor the error messages, because it doesn't have thefs_parameter_description).Signed-off-by Eric Sandeen <[email protected]>
Al, can you add this to your branch?
David