Commit 61edcb8b authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] USB: convert usbfs to use new fs parser code.

parent 1c321b9f
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/usbdevice_fs.h> #include <linux/usbdevice_fs.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/parser.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
static struct super_operations usbfs_ops; static struct super_operations usbfs_ops;
...@@ -62,86 +63,94 @@ static umode_t devmode = S_IWUSR | S_IRUGO; ...@@ -62,86 +63,94 @@ static umode_t devmode = S_IWUSR | S_IRUGO;
static umode_t busmode = S_IXUGO | S_IRUGO; static umode_t busmode = S_IXUGO | S_IRUGO;
static umode_t listmode = S_IRUGO; static umode_t listmode = S_IRUGO;
enum {
Opt_devuid, Opt_devgid, Opt_devmode,
Opt_busuid, Opt_busgid, Opt_busmode,
Opt_listuid, Opt_listgid, Opt_listmode,
Opt_err,
};
static match_table_t tokens = {
{Opt_devuid, "devuid=%u"},
{Opt_devgid, "devgid=%u"},
{Opt_devmode, "devmode=%o"},
{Opt_busuid, "busuid=%u"},
{Opt_busgid, "busgid=%u"},
{Opt_busmode, "busmode=%o"},
{Opt_listuid, "listuid=%u"},
{Opt_listgid, "listgid=%u"},
{Opt_listmode, "listmode=%o"},
{Opt_err, NULL}
};
static int parse_options(struct super_block *s, char *data) static int parse_options(struct super_block *s, char *data)
{ {
char *curopt = NULL, *value; char *p;
int option;
while ((curopt = strsep(&data, ",")) != NULL) { while ((p = strsep(&data, ",")) != NULL) {
if (!*curopt) substring_t args[MAX_OPT_ARGS];
int token;
if (!*p)
continue; continue;
if ((value = strchr(curopt, '=')) != NULL)
*value++ = 0; token = match_token(p, tokens, args);
if (!strcmp(curopt, "devuid")) { switch (token) {
if (!value || !value[0]) case Opt_devuid:
return -EINVAL; if (match_int(&args[0], &option))
devuid = simple_strtoul(value, &value, 0); return -EINVAL;
if (*value) devuid = option;
return -EINVAL; break;
} case Opt_devgid:
if (!strcmp(curopt, "devgid")) { if (match_int(&args[0], &option))
if (!value || !value[0]) return -EINVAL;
return -EINVAL; devgid = option;
devgid = simple_strtoul(value, &value, 0); break;
if (*value) case Opt_devmode:
return -EINVAL; if (match_octal(&args[0], &option))
}
if (!strcmp(curopt, "devmode")) {
if (!value || !value[0])
return -EINVAL;
devmode = simple_strtoul(value, &value, 0) & S_IRWXUGO;
if (*value)
return -EINVAL;
}
if (!strcmp(curopt, "busuid")) {
if (!value || !value[0])
return -EINVAL;
busuid = simple_strtoul(value, &value, 0);
if (*value)
return -EINVAL;
}
if (!strcmp(curopt, "busgid")) {
if (!value || !value[0])
return -EINVAL;
busgid = simple_strtoul(value, &value, 0);
if (*value)
return -EINVAL;
}
if (!strcmp(curopt, "busmode")) {
if (!value || !value[0])
return -EINVAL;
busmode = simple_strtoul(value, &value, 0) & S_IRWXUGO;
if (*value)
return -EINVAL;
}
if (!strcmp(curopt, "listuid")) {
if (!value || !value[0])
return -EINVAL;
listuid = simple_strtoul(value, &value, 0);
if (*value)
return -EINVAL;
}
if (!strcmp(curopt, "listgid")) {
if (!value || !value[0])
return -EINVAL;
listgid = simple_strtoul(value, &value, 0);
if (*value)
return -EINVAL; return -EINVAL;
} devmode = option & S_IRWXUGO;
if (!strcmp(curopt, "listmode")) { break;
if (!value || !value[0]) case Opt_busuid:
if (match_int(&args[0], &option))
return -EINVAL;
busuid = option;
break;
case Opt_busgid:
if (match_int(&args[0], &option))
return -EINVAL;
busgid = option;
break;
case Opt_busmode:
if (match_octal(&args[0], &option))
return -EINVAL; return -EINVAL;
listmode = simple_strtoul(value, &value, 0) & S_IRWXUGO; busmode = option & S_IRWXUGO;
if (*value) break;
case Opt_listuid:
if (match_int(&args[0], &option))
return -EINVAL;
listuid = option;
break;
case Opt_listgid:
if (match_int(&args[0], &option))
return -EINVAL;
listgid = option;
break;
case Opt_listmode:
if (match_octal(&args[0], &option))
return -EINVAL; return -EINVAL;
listmode = option & S_IRWXUGO;
break;
default:
err("usbfs: unrecognised mount option \"%s\" "
"or missing value\n", p);
return -EINVAL;
} }
} }
return 0; return 0;
} }
/* --------------------------------------------------------------------- */
static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t dev) static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t dev)
{ {
struct inode *inode = new_inode(sb); struct inode *inode = new_inode(sb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment