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] [4/15] autofs options parsing

diff -Naurp -X /home/rddunlap/doc/dontdiff-osdl linux-260-test4-pv/fs/autofs/inode.c linux-260-test4-fs/fs/autofs/inode.c
--- linux-260-test4-pv/fs/autofs/inode.c 2003-08-22 16:58:11.000000000 -0700
+++ linux-260-test4-fs/fs/autofs/inode.c 2003-08-27 11:19:07.000000000 -0700
@@ -14,6 +14,7 @@
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/file.h>
+#include <linux/parser.h>
#include <asm/bitops.h>
#include "autofs_i.h"
#include <linux/module.h>
@@ -45,9 +46,22 @@ static struct super_operations autofs_so
.statfs = simple_statfs,
};

+enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto};
+
+static match_table_t autofs_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;
@@ -57,55 +71,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, autofs_tokens, args);
+ switch (token) {
+ case Opt_fd:
+ *pipefd = match_int(&args[0]);
+ break;
+ case Opt_uid:
+ *uid = match_int(&args[0]);
+ break;
+ case Opt_gid:
+ *gid = match_int(&args[0]);
+ break;
+ case Opt_pgrp:
+ *pgrp = match_int(&args[0]);
+ break;
+ case Opt_minproto:
+ *minproto = match_int(&args[0]);
+ break;
+ case Opt_maxproto:
+ *maxproto = match_int(&args[0]);
+ break;
+ default:
return 1;
}
- else break;
}
return (*pipefd < 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.359 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site