mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
autofs: refactor parse_options()
Seperate out parts of parse_options() that will match better the individual option processing used in the mount API to further simplify the upcoming conversion. Signed-off-by: Ian Kent <raven@themaw.net> Reviewed-by: Bill O'Donnell <bodonnel@redhat.com> Message-Id: <20230922041215.13675-6-raven@themaw.net> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
7efd93ea79
commit
9b2731666d
1 changed files with 72 additions and 64 deletions
|
@ -167,18 +167,84 @@ static int autofs_parse_fd(struct autofs_sb_info *sbi, int fd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_options(char *options,
|
static int autofs_parse_param(char *optstr, struct inode *root,
|
||||||
struct inode *root, int *pgrp, bool *pgrp_set,
|
int *pgrp, bool *pgrp_set,
|
||||||
struct autofs_sb_info *sbi)
|
struct autofs_sb_info *sbi)
|
||||||
{
|
{
|
||||||
char *p;
|
|
||||||
substring_t args[MAX_OPT_ARGS];
|
substring_t args[MAX_OPT_ARGS];
|
||||||
int option;
|
int option;
|
||||||
int pipefd = -1;
|
int pipefd = -1;
|
||||||
kuid_t uid;
|
kuid_t uid;
|
||||||
kgid_t gid;
|
kgid_t gid;
|
||||||
|
int token;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
token = match_token(optstr, tokens, args);
|
||||||
|
switch (token) {
|
||||||
|
case Opt_fd:
|
||||||
|
if (match_int(args, &pipefd))
|
||||||
|
return 1;
|
||||||
|
ret = autofs_parse_fd(sbi, pipefd);
|
||||||
|
if (ret)
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case Opt_uid:
|
||||||
|
if (match_int(args, &option))
|
||||||
|
return 1;
|
||||||
|
uid = make_kuid(current_user_ns(), option);
|
||||||
|
if (!uid_valid(uid))
|
||||||
|
return 1;
|
||||||
|
root->i_uid = uid;
|
||||||
|
break;
|
||||||
|
case Opt_gid:
|
||||||
|
if (match_int(args, &option))
|
||||||
|
return 1;
|
||||||
|
gid = make_kgid(current_user_ns(), option);
|
||||||
|
if (!gid_valid(gid))
|
||||||
|
return 1;
|
||||||
|
root->i_gid = gid;
|
||||||
|
break;
|
||||||
|
case Opt_pgrp:
|
||||||
|
if (match_int(args, &option))
|
||||||
|
return 1;
|
||||||
|
*pgrp = option;
|
||||||
|
*pgrp_set = true;
|
||||||
|
break;
|
||||||
|
case Opt_minproto:
|
||||||
|
if (match_int(args, &option))
|
||||||
|
return 1;
|
||||||
|
sbi->min_proto = option;
|
||||||
|
break;
|
||||||
|
case Opt_maxproto:
|
||||||
|
if (match_int(args, &option))
|
||||||
|
return 1;
|
||||||
|
sbi->max_proto = option;
|
||||||
|
break;
|
||||||
|
case Opt_indirect:
|
||||||
|
set_autofs_type_indirect(&sbi->type);
|
||||||
|
break;
|
||||||
|
case Opt_direct:
|
||||||
|
set_autofs_type_direct(&sbi->type);
|
||||||
|
break;
|
||||||
|
case Opt_offset:
|
||||||
|
set_autofs_type_offset(&sbi->type);
|
||||||
|
break;
|
||||||
|
case Opt_strictexpire:
|
||||||
|
sbi->flags |= AUTOFS_SBI_STRICTEXPIRE;
|
||||||
|
break;
|
||||||
|
case Opt_ignore:
|
||||||
|
sbi->flags |= AUTOFS_SBI_IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_options(char *options,
|
||||||
|
struct inode *root, int *pgrp, bool *pgrp_set,
|
||||||
|
struct autofs_sb_info *sbi)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
root->i_uid = current_uid();
|
root->i_uid = current_uid();
|
||||||
root->i_gid = current_gid();
|
root->i_gid = current_gid();
|
||||||
|
|
||||||
|
@ -186,71 +252,13 @@ static int parse_options(char *options,
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
while ((p = strsep(&options, ",")) != NULL) {
|
while ((p = strsep(&options, ",")) != NULL) {
|
||||||
int token;
|
|
||||||
|
|
||||||
if (!*p)
|
if (!*p)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
token = match_token(p, tokens, args);
|
if (autofs_parse_param(p, root, pgrp, pgrp_set, sbi))
|
||||||
switch (token) {
|
|
||||||
case Opt_fd:
|
|
||||||
if (match_int(args, &pipefd))
|
|
||||||
return 1;
|
|
||||||
ret = autofs_parse_fd(sbi, pipefd);
|
|
||||||
if (ret)
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
case Opt_uid:
|
|
||||||
if (match_int(args, &option))
|
|
||||||
return 1;
|
|
||||||
uid = make_kuid(current_user_ns(), option);
|
|
||||||
if (!uid_valid(uid))
|
|
||||||
return 1;
|
|
||||||
root->i_uid = uid;
|
|
||||||
break;
|
|
||||||
case Opt_gid:
|
|
||||||
if (match_int(args, &option))
|
|
||||||
return 1;
|
|
||||||
gid = make_kgid(current_user_ns(), option);
|
|
||||||
if (!gid_valid(gid))
|
|
||||||
return 1;
|
|
||||||
root->i_gid = gid;
|
|
||||||
break;
|
|
||||||
case Opt_pgrp:
|
|
||||||
if (match_int(args, &option))
|
|
||||||
return 1;
|
|
||||||
*pgrp = option;
|
|
||||||
*pgrp_set = true;
|
|
||||||
break;
|
|
||||||
case Opt_minproto:
|
|
||||||
if (match_int(args, &option))
|
|
||||||
return 1;
|
|
||||||
sbi->min_proto = option;
|
|
||||||
break;
|
|
||||||
case Opt_maxproto:
|
|
||||||
if (match_int(args, &option))
|
|
||||||
return 1;
|
|
||||||
sbi->max_proto = option;
|
|
||||||
break;
|
|
||||||
case Opt_indirect:
|
|
||||||
set_autofs_type_indirect(&sbi->type);
|
|
||||||
break;
|
|
||||||
case Opt_direct:
|
|
||||||
set_autofs_type_direct(&sbi->type);
|
|
||||||
break;
|
|
||||||
case Opt_offset:
|
|
||||||
set_autofs_type_offset(&sbi->type);
|
|
||||||
break;
|
|
||||||
case Opt_strictexpire:
|
|
||||||
sbi->flags |= AUTOFS_SBI_STRICTEXPIRE;
|
|
||||||
break;
|
|
||||||
case Opt_ignore:
|
|
||||||
sbi->flags |= AUTOFS_SBI_IGNORE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (sbi->pipefd < 0);
|
return (sbi->pipefd < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue