qubes-linux-kernel/patches.suse/parser-match_string.diff

56 lines
1.5 KiB
Diff
Raw Normal View History

From: Andreas Gruenbacher <agruen@suse.de>
Subject: Add match_string() for mount option parsing
References: FATE301275
Patch-mainline: no
The match_string() function allows to parse string constants in
mount options.
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
---
include/linux/parser.h | 1 +
lib/parser.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
--- a/include/linux/parser.h
+++ b/include/linux/parser.h
@@ -26,6 +26,7 @@ typedef struct {
} substring_t;
int match_token(char *, const 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);
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -114,6 +114,19 @@ int match_token(char *s, const match_tab
}
/**
+ * 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
@@ -224,6 +237,7 @@ char *match_strdup(const substring_t *s)
}
EXPORT_SYMBOL(match_token);
+EXPORT_SYMBOL(match_string);
EXPORT_SYMBOL(match_int);
EXPORT_SYMBOL(match_octal);
EXPORT_SYMBOL(match_hex);