lkml.org 
[lkml]   [2003]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[CFT] [2/15] adfs options parsing

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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.038 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site