From: "Randy.Dunlap" <rddunlap@osdl.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: fsdev <linux-fsdevel@vger.kernel.org>
Subject: [CFT] [5/15] autofs4 options parsing
Date: Fri, 5 Sep 2003 11:55:20 -0700 [thread overview]
Message-ID: <20030905115520.1d8a9ea7.rddunlap@osdl.org> (raw)
diff -Naurp -X /home/rddunlap/doc/dontdiff-osdl linux-260-test4-pv/fs/autofs4/inode.c linux-260-test4-fs/fs/autofs4/inode.c
--- linux-260-test4-pv/fs/autofs4/inode.c 2003-08-22 16:58:08.000000000 -0700
+++ linux-260-test4-fs/fs/autofs4/inode.c 2003-08-27 11:19:07.000000000 -0700
@@ -14,6 +14,7 @@
#include <linux/slab.h>
#include <linux/file.h>
#include <linux/pagemap.h>
+#include <linux/parser.h>
#include <asm/bitops.h>
#include "autofs_i.h"
#include <linux/module.h>
@@ -94,10 +95,23 @@ static struct super_operations autofs4_s
.statfs = simple_statfs,
};
+enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto};
+
+static match_table_t tokens = {
+ {Opt_fd, "fd=%d"},
+ {Opt_uid, "uid=%d"},
+ {Opt_gid, "gid=%d"},
+ {Opt_pgrp, "pgrp=%d"},
+ {Opt_minproto, "minproto=%d"},
+ {Opt_maxproto, "maxproto=%d"},
+ {Opt_err, NULL}
+};
+
static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid,
pid_t *pgrp, int *minproto, int *maxproto)
{
- char *this_char, *value;
+ char *p;
+ substring_t args[MAX_OPT_ARGS];
*uid = current->uid;
*gid = current->gid;
@@ -108,55 +122,37 @@ static int parse_options(char *options,
*pipefd = -1;
- if ( !options ) return 1;
- while ((this_char = strsep(&options,",")) != NULL) {
- if (!*this_char)
+ if (!options)
+ return 1;
+
+ while ((p = strsep(&options, ",")) != NULL) {
+ int token;
+ if (!*p)
continue;
- if ((value = strchr(this_char,'=')) != NULL)
- *value++ = 0;
- if (!strcmp(this_char,"fd")) {
- if (!value || !*value)
- return 1;
- *pipefd = simple_strtoul(value,&value,0);
- if (*value)
- return 1;
- }
- else if (!strcmp(this_char,"uid")) {
- if (!value || !*value)
- return 1;
- *uid = simple_strtoul(value,&value,0);
- if (*value)
- return 1;
- }
- else if (!strcmp(this_char,"gid")) {
- if (!value || !*value)
- return 1;
- *gid = simple_strtoul(value,&value,0);
- if (*value)
- return 1;
- }
- else if (!strcmp(this_char,"pgrp")) {
- if (!value || !*value)
- return 1;
- *pgrp = simple_strtoul(value,&value,0);
- if (*value)
- return 1;
- }
- else if (!strcmp(this_char,"minproto")) {
- if (!value || !*value)
- return 1;
- *minproto = simple_strtoul(value,&value,0);
- if (*value)
- return 1;
- }
- else if (!strcmp(this_char,"maxproto")) {
- if (!value || !*value)
- return 1;
- *maxproto = simple_strtoul(value,&value,0);
- if (*value)
+
+ token = match_token(p, tokens, args);
+ switch (token) {
+ case Opt_fd:
+ *pipefd = match_int(args);
+ break;
+ case Opt_uid:
+ *uid = match_int(args);
+ break;
+ case Opt_gid:
+ *gid = match_int(args);
+ break;
+ case Opt_pgrp:
+ *pgrp = match_int(args);
+ break;
+ case Opt_minproto:
+ *minproto = match_int(args);
+ break;
+ case Opt_maxproto:
+ *maxproto = match_int(args);
+ break;
+ default:
return 1;
}
- else break;
}
return (*pipefd < 0);
}
--
~Randy
reply other threads:[~2003-09-05 19:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030905115520.1d8a9ea7.rddunlap@osdl.org \
--to=rddunlap@osdl.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®