linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [CFT] [13/15] proc options parsing
@ 2003-09-05 19:00 Randy.Dunlap
  0 siblings, 0 replies; only message in thread
From: Randy.Dunlap @ 2003-09-05 19:00 UTC (permalink / raw)
  To: lkml; +Cc: fsdev


diff -Naurp -X /home/rddunlap/doc/dontdiff-osdl linux-260-test4-pv/fs/proc/inode.c linux-260-test4-fs/fs/proc/inode.c
--- linux-260-test4-pv/fs/proc/inode.c	2003-08-22 16:59:37.000000000 -0700
+++ linux-260-test4-fs/fs/proc/inode.c	2003-08-27 11:19:07.000000000 -0700
@@ -14,6 +14,7 @@
 #include <linux/limits.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/parser.h>
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 
@@ -136,34 +137,42 @@ static struct super_operations proc_sops
 	.statfs		= simple_statfs,
 };
 
+enum {
+	Opt_uid, Opt_gid, Opt_err
+};
+
+static match_table_t tokens = {
+	{Opt_uid, "uid=%u"},
+	{Opt_gid, "gid=%u"},
+	{Opt_err, NULL}
+};
+
 static int parse_options(char *options,uid_t *uid,gid_t *gid)
 {
-	char *this_char,*value;
+	char *p;
 
 	*uid = current->uid;
 	*gid = current->gid;
 	if (!options)
 		return 1;
-	while ((this_char = strsep(&options,",")) != NULL) {
-		if (!*this_char)
+
+	while ((p = strsep(&options, ",")) != NULL) {
+		substring_t args[MAX_OPT_ARGS];
+		int token;
+		if (!*p)
 			continue;
-		if ((value = strchr(this_char,'=')) != NULL)
-			*value++ = 0;
-		if (!strcmp(this_char,"uid")) {
-			if (!value || !*value)
-				return 0;
-			*uid = simple_strtoul(value,&value,0);
-			if (*value)
-				return 0;
-		}
-		else if (!strcmp(this_char,"gid")) {
-			if (!value || !*value)
-				return 0;
-			*gid = simple_strtoul(value,&value,0);
-			if (*value)
+
+		token = match_token(p, tokens, args);
+		switch (token) {
+			case Opt_uid:
+				*uid = match_int(args);
+				break;
+			case Opt_gid:
+				*gid = match_int(args);
+				break;
+			default:
 				return 0;
 		}
-		else return 1;
 	}
 	return 1;
 }


--
~Randy

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-09-05 19:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-05 19:00 [CFT] [13/15] proc options parsing Randy.Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).