ChangeSet 1.1433.1.2, 2003/10/03 14:49:02-07:00, [EMAIL PROTECTED]

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


 drivers/usb/core/inode.c |  149 ++++++++++++++++++++++++-----------------------
 1 files changed, 79 insertions(+), 70 deletions(-)


diff -Nru a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
--- a/drivers/usb/core/inode.c  Fri Oct  3 16:44:25 2003
+++ b/drivers/usb/core/inode.c  Fri Oct  3 16:44:25 2003
@@ -38,6 +38,7 @@
 #include <linux/namei.h>
 #include <linux/usbdevice_fs.h>
 #include <linux/smp_lock.h>
+#include <linux/parser.h>
 #include <asm/byteorder.h>
 
 static struct super_operations usbfs_ops;
@@ -62,85 +63,93 @@
 static umode_t busmode = S_IXUGO | 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)
 {
-       char *curopt = NULL, *value;
+       char *p;
+       int option;
 
-       while ((curopt = strsep(&data, ",")) != NULL) {
-               if (!*curopt)
+       while ((p = strsep(&data, ",")) != NULL) {
+               substring_t args[MAX_OPT_ARGS];
+               int token;
+               if (!*p)
                        continue;
-               if ((value = strchr(curopt, '=')) != NULL)
-                       *value++ = 0;
-               if (!strcmp(curopt, "devuid")) {
-                       if (!value || !value[0])
-                               return -EINVAL;
-                       devuid = simple_strtoul(value, &value, 0);
-                       if (*value)
-                               return -EINVAL;
-               }
-               if (!strcmp(curopt, "devgid")) {
-                       if (!value || !value[0])
-                               return -EINVAL;
-                       devgid = simple_strtoul(value, &value, 0);
-                       if (*value)
-                               return -EINVAL;
-               }
-               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;
-               }
-               if (!strcmp(curopt, "listmode")) {
-                       if (!value || !value[0])
-                               return -EINVAL;
-                       listmode = simple_strtoul(value, &value, 0) & S_IRWXUGO;
-                       if (*value)
-                               return -EINVAL;
+
+               token = match_token(p, tokens, args);
+               switch (token) {
+               case Opt_devuid:
+                       if (match_int(&args[0], &option))
+                              return -EINVAL;
+                       devuid = option;
+                       break;
+               case Opt_devgid:
+                       if (match_int(&args[0], &option))
+                              return -EINVAL;
+                       devgid = option;
+                       break;
+               case Opt_devmode:
+                       if (match_octal(&args[0], &option))
+                               return -EINVAL;
+                       devmode = option & S_IRWXUGO;
+                       break;
+               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;
+                       busmode = option & S_IRWXUGO;
+                       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;
+                       listmode = option & S_IRWXUGO;
+                       break;
+               default:
+                       err("usbfs: unrecognised mount option \"%s\" "
+                           "or missing value\n", p);
+                       return -EINVAL;
                }
        }
 
        return 0;
 }
-
-
-/* --------------------------------------------------------------------- */
 
 static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t dev)
 {



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to