Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <raven@themaw.net>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ian Kent and committed by
Linus Torvalds
9bf964c9 55f0d820

+29 -26
+29 -26
fs/autofs/inode.c
··· 124 124 {Opt_err, NULL} 125 125 }; 126 126 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) 130 130 { 131 131 char *p; 132 132 substring_t args[MAX_OPT_ARGS]; 133 133 int option; 134 + int pipefd = -1; 135 + kuid_t uid; 136 + kgid_t gid; 134 137 135 - *uid = current_uid(); 136 - *gid = current_gid(); 138 + root->i_uid = current_uid(); 139 + root->i_gid = current_gid(); 137 140 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; 140 143 141 - *pipefd = -1; 144 + sbi->pipefd = -1; 142 145 143 146 if (!options) 144 147 return 1; ··· 155 152 token = match_token(p, tokens, args); 156 153 switch (token) { 157 154 case Opt_fd: 158 - if (match_int(args, pipefd)) 155 + if (match_int(args, &pipefd)) 159 156 return 1; 157 + sbi->pipefd = pipefd; 160 158 break; 161 159 case Opt_uid: 162 160 if (match_int(args, &option)) 163 161 return 1; 164 - *uid = make_kuid(current_user_ns(), option); 165 - if (!uid_valid(*uid)) 162 + uid = make_kuid(current_user_ns(), option); 163 + if (!uid_valid(uid)) 166 164 return 1; 165 + root->i_uid = uid; 167 166 break; 168 167 case Opt_gid: 169 168 if (match_int(args, &option)) 170 169 return 1; 171 - *gid = make_kgid(current_user_ns(), option); 172 - if (!gid_valid(*gid)) 170 + gid = make_kgid(current_user_ns(), option); 171 + if (!gid_valid(gid)) 173 172 return 1; 173 + root->i_gid = gid; 174 174 break; 175 175 case Opt_pgrp: 176 176 if (match_int(args, &option)) ··· 184 178 case Opt_minproto: 185 179 if (match_int(args, &option)) 186 180 return 1; 187 - *minproto = option; 181 + sbi->min_proto = option; 188 182 break; 189 183 case Opt_maxproto: 190 184 if (match_int(args, &option)) 191 185 return 1; 192 - *maxproto = option; 186 + sbi->max_proto = option; 193 187 break; 194 188 case Opt_indirect: 195 - set_autofs_type_indirect(type); 189 + set_autofs_type_indirect(&sbi->type); 196 190 break; 197 191 case Opt_direct: 198 - set_autofs_type_direct(type); 192 + set_autofs_type_direct(&sbi->type); 199 193 break; 200 194 case Opt_offset: 201 - set_autofs_type_offset(type); 195 + set_autofs_type_offset(&sbi->type); 202 196 break; 203 197 default: 204 198 return 1; 205 199 } 206 200 } 207 - return (*pipefd < 0); 201 + return (sbi->pipefd < 0); 208 202 } 209 203 210 204 int autofs_fill_super(struct super_block *s, void *data, int silent) ··· 212 206 struct inode *root_inode; 213 207 struct dentry *root; 214 208 struct file *pipe; 215 - int pipefd; 216 209 struct autofs_sb_info *sbi; 217 210 struct autofs_info *ino; 218 211 int pgrp = 0; ··· 267 262 root->d_fsdata = ino; 268 263 269 264 /* Can this call block? */ 270 - if (parse_options(data, &pipefd, &root_inode->i_uid, &root_inode->i_gid, 271 - &pgrp, &pgrp_set, &sbi->type, &sbi->min_proto, 272 - &sbi->max_proto)) { 265 + if (parse_options(data, root_inode, &pgrp, &pgrp_set, sbi)) { 273 266 pr_err("called with bogus options\n"); 274 267 goto fail_dput; 275 268 } ··· 306 303 root_inode->i_fop = &autofs_root_operations; 307 304 root_inode->i_op = &autofs_dir_inode_operations; 308 305 309 - pr_debug("pipe fd = %d, pgrp = %u\n", pipefd, pid_nr(sbi->oz_pgrp)); 310 - pipe = fget(pipefd); 306 + pr_debug("pipe fd = %d, pgrp = %u\n", 307 + sbi->pipefd, pid_nr(sbi->oz_pgrp)); 308 + pipe = fget(sbi->pipefd); 311 309 312 310 if (!pipe) { 313 311 pr_err("could not open pipe file descriptor\n"); ··· 318 314 if (ret < 0) 319 315 goto fail_fput; 320 316 sbi->pipe = pipe; 321 - sbi->pipefd = pipefd; 322 317 sbi->catatonic = 0; 323 318 324 319 /*