From: "Randy.Dunlap" <rddunlap@osdl.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: linux-fsdevel@vger.kernel.org
Subject: [CFT] [2/15] adfs options parsing
Date: Fri, 5 Sep 2003 11:51:22 -0700 [thread overview]
Message-ID: <20030905115122.2c0d0cfc.rddunlap@osdl.org> (raw)
diff -Naurp -X /home/rddunlap/doc/dontdiff-osdl linux-260-test4-pv/fs/adfs/super.c linux-260-test4-fs/fs/adfs/super.c
--- linux-260-test4-pv/fs/adfs/super.c 2003-08-22 16:50:52.000000000 -0700
+++ linux-260-test4-fs/fs/adfs/super.c 2003-09-03 14:20:04.000000000 -0700
@@ -19,6 +19,7 @@
#include <linux/init.h>
#include <linux/buffer_head.h>
#include <linux/vfs.h>
+#include <linux/parser.h>
#include <asm/bitops.h>
#include <asm/uaccess.h>
@@ -134,51 +135,48 @@ static void adfs_put_super(struct super_
sb->s_fs_info = NULL;
}
+enum {Opt_uid, Opt_gid, Opt_ownmask, Opt_othmask, Opt_err};
+
+static match_table_t tokens = {
+ {Opt_uid, "uid=%u"},
+ {Opt_gid, "gid=%u"},
+ {Opt_ownmask, "ownmask=%o"},
+ {Opt_othmask, "othmask=%o"},
+ {Opt_err, NULL}
+};
+
static int parse_options(struct super_block *sb, char *options)
{
- char *value, *opt;
+ char *p;
struct adfs_sb_info *asb = ADFS_SB(sb);
if (!options)
return 0;
- while ((opt = strsep(&options, ",")) != NULL) {
- if (!*opt)
+ while ((p = strsep(&options, ",")) != NULL) {
+ substring_t args[MAX_OPT_ARGS];
+ int token;
+ if (!*p)
continue;
- value = strchr(opt, '=');
- if (value)
- *value++ = '\0';
- if (!strcmp(opt, "uid")) { /* owner of all files */
- if (!value || !*value)
- return -EINVAL;
- asb->s_uid = simple_strtoul(value, &value, 0);
- if (*value)
- return -EINVAL;
- } else
- if (!strcmp(opt, "gid")) { /* group owner of all files */
- if (!value || !*value)
- return -EINVAL;
- asb->s_gid = simple_strtoul(value, &value, 0);
- if (*value)
- return -EINVAL;
- } else
- if (!strcmp(opt, "ownmask")) { /* owner permission mask */
- if (!value || !*value)
- return -EINVAL;
- asb->s_owner_mask = simple_strtoul(value, &value, 8);
- if (*value)
- return -EINVAL;
- } else
- if (!strcmp(opt, "othmask")) { /* others permission mask */
- if (!value || !*value)
- return -EINVAL;
- asb->s_other_mask = simple_strtoul(value, &value, 8);
- if (*value)
+ token = match_token(p, tokens, args);
+ switch (token) {
+ case Opt_uid:
+ asb->s_uid = match_int(args);
+ break;
+ case Opt_gid:
+ asb->s_gid = match_int(args);
+ break;
+ case Opt_ownmask:
+ asb->s_owner_mask = match_octal(args);
+ break;
+ case Opt_othmask:
+ asb->s_other_mask = match_octal(args);
+ break;
+ default:
+ printk("ADFS-fs: unrecognised mount option \"%s\" "
+ "or missing value\n", p);
return -EINVAL;
- } else { /* eh? say again. */
- printk("ADFS-fs: unrecognised mount option %s\n", opt);
- return -EINVAL;
}
}
return 0;
--
~Randy
reply other threads:[~2003-09-05 19:19 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=20030905115122.2c0d0cfc.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®