Skip to content

Commit 9bf964c

Browse files
raven-autorvalds
authored andcommitted
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-net Signed-off-by: Ian Kent <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 55f0d82 commit 9bf964c

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

fs/autofs/inode.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,24 @@ static const match_table_t tokens = {
124124
{Opt_err, NULL}
125125
};
126126

127-
static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
128-
int *pgrp, bool *pgrp_set, unsigned int *type,
129-
int *minproto, int *maxproto)
127+
static int parse_options(char *options,
128+
struct inode *root, int *pgrp, bool *pgrp_set,
129+
struct autofs_sb_info *sbi)
130130
{
131131
char *p;
132132
substring_t args[MAX_OPT_ARGS];
133133
int option;
134+
int pipefd = -1;
135+
kuid_t uid;
136+
kgid_t gid;
134137

135-
*uid = current_uid();
136-
*gid = current_gid();
138+
root->i_uid = current_uid();
139+
root->i_gid = current_gid();
137140

138-
*minproto = AUTOFS_MIN_PROTO_VERSION;
139-
*maxproto = AUTOFS_MAX_PROTO_VERSION;
141+
sbi->min_proto = AUTOFS_MIN_PROTO_VERSION;
142+
sbi->max_proto = AUTOFS_MAX_PROTO_VERSION;
140143

141-
*pipefd = -1;
144+
sbi->pipefd = -1;
142145

143146
if (!options)
144147
return 1;
@@ -152,22 +155,25 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
152155
token = match_token(p, tokens, args);
153156
switch (token) {
154157
case Opt_fd:
155-
if (match_int(args, pipefd))
158+
if (match_int(args, &pipefd))
156159
return 1;
160+
sbi->pipefd = pipefd;
157161
break;
158162
case Opt_uid:
159163
if (match_int(args, &option))
160164
return 1;
161-
*uid = make_kuid(current_user_ns(), option);
162-
if (!uid_valid(*uid))
165+
uid = make_kuid(current_user_ns(), option);
166+
if (!uid_valid(uid))
163167
return 1;
168+
root->i_uid = uid;
164169
break;
165170
case Opt_gid:
166171
if (match_int(args, &option))
167172
return 1;
168-
*gid = make_kgid(current_user_ns(), option);
169-
if (!gid_valid(*gid))
173+
gid = make_kgid(current_user_ns(), option);
174+
if (!gid_valid(gid))
170175
return 1;
176+
root->i_gid = gid;
171177
break;
172178
case Opt_pgrp:
173179
if (match_int(args, &option))
@@ -178,35 +184,34 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
178184
case Opt_minproto:
179185
if (match_int(args, &option))
180186
return 1;
181-
*minproto = option;
187+
sbi->min_proto = option;
182188
break;
183189
case Opt_maxproto:
184190
if (match_int(args, &option))
185191
return 1;
186-
*maxproto = option;
192+
sbi->max_proto = option;
187193
break;
188194
case Opt_indirect:
189-
set_autofs_type_indirect(type);
195+
set_autofs_type_indirect(&sbi->type);
190196
break;
191197
case Opt_direct:
192-
set_autofs_type_direct(type);
198+
set_autofs_type_direct(&sbi->type);
193199
break;
194200
case Opt_offset:
195-
set_autofs_type_offset(type);
201+
set_autofs_type_offset(&sbi->type);
196202
break;
197203
default:
198204
return 1;
199205
}
200206
}
201-
return (*pipefd < 0);
207+
return (sbi->pipefd < 0);
202208
}
203209

204210
int autofs_fill_super(struct super_block *s, void *data, int silent)
205211
{
206212
struct inode *root_inode;
207213
struct dentry *root;
208214
struct file *pipe;
209-
int pipefd;
210215
struct autofs_sb_info *sbi;
211216
struct autofs_info *ino;
212217
int pgrp = 0;
@@ -262,9 +267,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
262267
root->d_fsdata = ino;
263268

264269
/* Can this call block? */
265-
if (parse_options(data, &pipefd, &root_inode->i_uid, &root_inode->i_gid,
266-
&pgrp, &pgrp_set, &sbi->type, &sbi->min_proto,
267-
&sbi->max_proto)) {
270+
if (parse_options(data, root_inode, &pgrp, &pgrp_set, sbi)) {
268271
pr_err("called with bogus options\n");
269272
goto fail_dput;
270273
}
@@ -303,8 +306,9 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
303306
root_inode->i_fop = &autofs_root_operations;
304307
root_inode->i_op = &autofs_dir_inode_operations;
305308

306-
pr_debug("pipe fd = %d, pgrp = %u\n", pipefd, pid_nr(sbi->oz_pgrp));
307-
pipe = fget(pipefd);
309+
pr_debug("pipe fd = %d, pgrp = %u\n",
310+
sbi->pipefd, pid_nr(sbi->oz_pgrp));
311+
pipe = fget(sbi->pipefd);
308312

309313
if (!pipe) {
310314
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)
314318
if (ret < 0)
315319
goto fail_fput;
316320
sbi->pipe = pipe;
317-
sbi->pipefd = pipefd;
318321
sbi->catatonic = 0;
319322

320323
/*

0 commit comments

Comments
 (0)