1 From: Andreas Gruenbacher <agruen@suse.de>
2 Subject: Add match_string() for mount option parsing
6 The match_string() function allows to parse string constants in
9 Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
12 include/linux/parser.h | 1 +
13 lib/parser.c | 14 ++++++++++++++
14 2 files changed, 15 insertions(+)
16 --- a/include/linux/parser.h
17 +++ b/include/linux/parser.h
18 @@ -26,6 +26,7 @@ typedef struct {
21 int match_token(char *, match_table_t table, substring_t args[]);
22 +int match_string(substring_t *s, const char *str);
23 int match_int(substring_t *, int *result);
24 int match_octal(substring_t *, int *result);
25 int match_hex(substring_t *, int *result);
28 @@ -111,6 +111,19 @@ int match_token(char *s, match_table_t t
32 + * match_string: check for a particular parameter
33 + * @s: substring to be scanned
34 + * @str: string to scan for
36 + * Description: Return if a &substring_t is equal to string @str.
38 +int match_string(substring_t *s, const char *str)
40 + return strlen(str) == s->to - s->from &&
41 + !memcmp(str, s->from, s->to - s->from);
45 * match_number: scan a number in the given base from a substring_t
46 * @s: substring to be scanned
47 * @result: resulting integer on success
48 @@ -221,6 +234,7 @@ char *match_strdup(const substring_t *s)
51 EXPORT_SYMBOL(match_token);
52 +EXPORT_SYMBOL(match_string);
53 EXPORT_SYMBOL(match_int);
54 EXPORT_SYMBOL(match_octal);
55 EXPORT_SYMBOL(match_hex);