[patch 2/3] Add match_string() for mount option parsing

From: Andreas Gruenbacher
Date: Wed Sep 06 2006 - 10:42:46 EST


The match_string() function allows to parse string constants in
mount options.

Signed-off-by: Andreas Gruenbacher <agruen@xxxxxxx>

Index: linux-2.6.18-rc6/include/linux/parser.h
===================================================================
--- linux-2.6.18-rc6.orig/include/linux/parser.h
+++ linux-2.6.18-rc6/include/linux/parser.h
@@ -26,6 +26,7 @@ typedef struct {
} substring_t;

int match_token(char *, match_table_t table, substring_t args[]);
+int match_string(substring_t *s, const char *str);
int match_int(substring_t *, int *result);
int match_octal(substring_t *, int *result);
int match_hex(substring_t *, int *result);
Index: linux-2.6.18-rc6/lib/parser.c
===================================================================
--- linux-2.6.18-rc6.orig/lib/parser.c
+++ linux-2.6.18-rc6/lib/parser.c
@@ -111,6 +111,19 @@ int match_token(char *s, match_table_t t
}

/**
+ * match_string: check for a particular parameter
+ * @s: substring to be scanned
+ * @str: string to scan for
+ *
+ * Description: Return if a &substring_t is equal to string @str.
+ */
+int match_string(substring_t *s, const char *str)
+{
+ return strlen(str) == s->to - s->from &&
+ !memcmp(str, s->from, s->to - s->from);
+}
+
+/**
* match_number: scan a number in the given base from a substring_t
* @s: substring to be scanned
* @result: resulting integer on success
@@ -213,6 +226,7 @@ char *match_strdup(substring_t *s)
}

EXPORT_SYMBOL(match_token);
+EXPORT_SYMBOL(match_string);
EXPORT_SYMBOL(match_int);
EXPORT_SYMBOL(match_octal);
EXPORT_SYMBOL(match_hex);

--
Andreas Gruenbacher <agruen@xxxxxxx>
SUSE Labs, SUSE LINUX Products GmbH / Novell Inc.

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