aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2019-12-17 20:03:59 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2020-02-07 14:48:37 -0500
commit48ce73b1bef20331007b35de7ade8fe26cd55e84 (patch)
tree27cefdfd5e4f49a92d81e6a98f48b4f83a9c1639 /fs/nfs
parentfs_parse: fold fs_parameter_desc/fs_parameter_spec (diff)
downloadlinux-dev-48ce73b1bef20331007b35de7ade8fe26cd55e84.tar.xz
linux-dev-48ce73b1bef20331007b35de7ade8fe26cd55e84.zip
fs_parse: handle optional arguments sanely
Don't bother with "mixed" options that would allow both the form with and without argument (i.e. both -o foo and -o foo=bar). Rather than trying to shove both into a single fs_parameter_spec, allow having with-argument and no-argument specs with the same name and teach fs_parse to handle that. There are very few options of that sort, and they are actually easier to handle that way - callers end up with less postprocessing. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/fs_context.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
index 39f980a0ee48..c87cdedbdd0c 100644
--- a/fs/nfs/fs_context.c
+++ b/fs/nfs/fs_context.c
@@ -45,6 +45,7 @@ enum nfs_param {
Opt_cto,
Opt_fg,
Opt_fscache,
+ Opt_fscache_flag,
Opt_hard,
Opt_intr,
Opt_local_lock,
@@ -125,8 +126,8 @@ static const struct fs_parameter_spec nfs_fs_parameters[] = {
fsparam_string("clientaddr", Opt_clientaddr),
fsparam_flag_no("cto", Opt_cto),
fsparam_flag ("fg", Opt_fg),
- __fsparam(fs_param_is_string, "fsc", Opt_fscache,
- fs_param_neg_with_no|fs_param_v_optional, NULL),
+ fsparam_flag_no("fsc", Opt_fscache_flag),
+ fsparam_string("fsc", Opt_fscache),
fsparam_flag ("hard", Opt_hard),
__fsparam(fs_param_is_flag, "intr", Opt_intr,
fs_param_neg_with_no|fs_param_deprecated, NULL),
@@ -537,14 +538,19 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
else
ctx->flags &= ~NFS_MOUNT_NORESVPORT;
break;
- case Opt_fscache:
- kfree(ctx->fscache_uniq);
- ctx->fscache_uniq = param->string;
- param->string = NULL;
+ case Opt_fscache_flag:
if (result.negated)
ctx->options &= ~NFS_OPTION_FSCACHE;
else
ctx->options |= NFS_OPTION_FSCACHE;
+ kfree(ctx->fscache_uniq);
+ ctx->fscache_uniq = NULL;
+ break;
+ case Opt_fscache:
+ ctx->options |= NFS_OPTION_FSCACHE;
+ kfree(ctx->fscache_uniq);
+ ctx->fscache_uniq = param->string;
+ param->string = NULL;
break;
case Opt_migration:
if (result.negated)