Commit 9bf964c9 authored by Ian Kent's avatar Ian Kent Committed by Linus Torvalds

autofs: simplify parse_options() function call

The parse_options() function uses a long list of parameters, most of
which are present in the super block info structure already.

The mount parameters set in parse_options() options don't require
cleanup so using the super block info struct directly is simpler.

Link: http://lkml.kernel.org/r/154296972423.9889.9368859245676473329.stgit@pluto-themaw-netSigned-off-by: default avatarIan Kent <raven@themaw.net>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 55f0d820
...@@ -124,21 +124,24 @@ static const match_table_t tokens = { ...@@ -124,21 +124,24 @@ static const match_table_t tokens = {
{Opt_err, NULL} {Opt_err, NULL}
}; };
static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid, static int parse_options(char *options,
int *pgrp, bool *pgrp_set, unsigned int *type, struct inode *root, int *pgrp, bool *pgrp_set,
int *minproto, int *maxproto) struct autofs_sb_info *sbi)
{ {
char *p; char *p;
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
int option; int option;
int pipefd = -1;
kuid_t uid;
kgid_t gid;
*uid = current_uid(); root->i_uid = current_uid();
*gid = current_gid(); root->i_gid = current_gid();
*minproto = AUTOFS_MIN_PROTO_VERSION; sbi->min_proto = AUTOFS_MIN_PROTO_VERSION;
*maxproto = AUTOFS_MAX_PROTO_VERSION; sbi->max_proto = AUTOFS_MAX_PROTO_VERSION;
*pipefd = -1; sbi->pipefd = -1;
if (!options) if (!options)
return 1; return 1;
...@@ -152,22 +155,25 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid, ...@@ -152,22 +155,25 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
token = match_token(p, tokens, args); token = match_token(p, tokens, args);
switch (token) { switch (token) {
case Opt_fd: case Opt_fd:
if (match_int(args, pipefd)) if (match_int(args, &pipefd))
return 1; return 1;
sbi->pipefd = pipefd;
break; break;
case Opt_uid: case Opt_uid:
if (match_int(args, &option)) if (match_int(args, &option))
return 1; return 1;
*uid = make_kuid(current_user_ns(), option); uid = make_kuid(current_user_ns(), option);
if (!uid_valid(*uid)) if (!uid_valid(uid))
return 1; return 1;
root->i_uid = uid;
break; break;
case Opt_gid: case Opt_gid:
if (match_int(args, &option)) if (match_int(args, &option))
return 1; return 1;
*gid = make_kgid(current_user_ns(), option); gid = make_kgid(current_user_ns(), option);
if (!gid_valid(*gid)) if (!gid_valid(gid))
return 1; return 1;
root->i_gid = gid;
break; break;
case Opt_pgrp: case Opt_pgrp:
if (match_int(args, &option)) if (match_int(args, &option))
...@@ -178,27 +184,27 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid, ...@@ -178,27 +184,27 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
case Opt_minproto: case Opt_minproto:
if (match_int(args, &option)) if (match_int(args, &option))
return 1; return 1;
*minproto = option; sbi->min_proto = option;
break; break;
case Opt_maxproto: case Opt_maxproto:
if (match_int(args, &option)) if (match_int(args, &option))
return 1; return 1;
*maxproto = option; sbi->max_proto = option;
break; break;
case Opt_indirect: case Opt_indirect:
set_autofs_type_indirect(type); set_autofs_type_indirect(&sbi->type);
break; break;
case Opt_direct: case Opt_direct:
set_autofs_type_direct(type); set_autofs_type_direct(&sbi->type);
break; break;
case Opt_offset: case Opt_offset:
set_autofs_type_offset(type); set_autofs_type_offset(&sbi->type);
break; break;
default: default:
return 1; return 1;
} }
} }
return (*pipefd < 0); return (sbi->pipefd < 0);
} }
int autofs_fill_super(struct super_block *s, void *data, int silent) int autofs_fill_super(struct super_block *s, void *data, int silent)
...@@ -206,7 +212,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) ...@@ -206,7 +212,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
struct inode *root_inode; struct inode *root_inode;
struct dentry *root; struct dentry *root;
struct file *pipe; struct file *pipe;
int pipefd;
struct autofs_sb_info *sbi; struct autofs_sb_info *sbi;
struct autofs_info *ino; struct autofs_info *ino;
int pgrp = 0; int pgrp = 0;
...@@ -262,9 +267,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) ...@@ -262,9 +267,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
root->d_fsdata = ino; root->d_fsdata = ino;
/* Can this call block? */ /* Can this call block? */
if (parse_options(data, &pipefd, &root_inode->i_uid, &root_inode->i_gid, if (parse_options(data, root_inode, &pgrp, &pgrp_set, sbi)) {
&pgrp, &pgrp_set, &sbi->type, &sbi->min_proto,
&sbi->max_proto)) {
pr_err("called with bogus options\n"); pr_err("called with bogus options\n");
goto fail_dput; goto fail_dput;
} }
...@@ -303,8 +306,9 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) ...@@ -303,8 +306,9 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
root_inode->i_fop = &autofs_root_operations; root_inode->i_fop = &autofs_root_operations;
root_inode->i_op = &autofs_dir_inode_operations; root_inode->i_op = &autofs_dir_inode_operations;
pr_debug("pipe fd = %d, pgrp = %u\n", pipefd, pid_nr(sbi->oz_pgrp)); pr_debug("pipe fd = %d, pgrp = %u\n",
pipe = fget(pipefd); sbi->pipefd, pid_nr(sbi->oz_pgrp));
pipe = fget(sbi->pipefd);
if (!pipe) { if (!pipe) {
pr_err("could not open pipe file descriptor\n"); pr_err("could not open pipe file descriptor\n");
...@@ -314,7 +318,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) ...@@ -314,7 +318,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
if (ret < 0) if (ret < 0)
goto fail_fput; goto fail_fput;
sbi->pipe = pipe; sbi->pipe = pipe;
sbi->pipefd = pipefd;
sbi->catatonic = 0; sbi->catatonic = 0;
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment