]>
Commit | Line | Data |
---|---|---|
6a930a95 BS |
1 | From: Andreas Gruenbacher <agruen@suse.de> |
2 | Subject: Add match_string() for mount option parsing | |
3 | References: FATE301275 | |
4 | Patch-mainline: no | |
5 | ||
6 | The match_string() function allows to parse string constants in | |
7 | mount options. | |
8 | ||
9 | Signed-off-by: Andreas Gruenbacher <agruen@suse.de> | |
10 | ||
11 | --- | |
12 | include/linux/parser.h | 1 + | |
13 | lib/parser.c | 14 ++++++++++++++ | |
14 | 2 files changed, 15 insertions(+) | |
15 | ||
16 | --- a/include/linux/parser.h | |
17 | +++ b/include/linux/parser.h | |
18 | @@ -26,6 +26,7 @@ typedef struct { | |
19 | } substring_t; | |
20 | ||
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); | |
26 | --- a/lib/parser.c | |
27 | +++ b/lib/parser.c | |
28 | @@ -111,6 +111,19 @@ int match_token(char *s, match_table_t t | |
29 | } | |
30 | ||
31 | /** | |
32 | + * match_string: check for a particular parameter | |
33 | + * @s: substring to be scanned | |
34 | + * @str: string to scan for | |
35 | + * | |
36 | + * Description: Return if a &substring_t is equal to string @str. | |
37 | + */ | |
38 | +int match_string(substring_t *s, const char *str) | |
39 | +{ | |
40 | + return strlen(str) == s->to - s->from && | |
41 | + !memcmp(str, s->from, s->to - s->from); | |
42 | +} | |
43 | + | |
44 | +/** | |
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) | |
49 | } | |
50 | ||
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); |