summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--utils/mount/parse_opt.c24
-rw-r--r--utils/mount/parse_opt.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/utils/mount/parse_opt.c b/utils/mount/parse_opt.c
index 342e210..7ba61c4 100644
--- a/utils/mount/parse_opt.c
+++ b/utils/mount/parse_opt.c
@@ -410,6 +410,30 @@ po_found_t po_contains(struct mount_options *options, char *keyword)
}
/**
+ * po_contains_prefix - check for presence of an option matching a prefix
+ * @options: pointer to mount options
+ * @prefix: pointer to prefix to match against a keyword
+ * @keyword: pointer to a C string containing the option keyword if found
+ *
+ * On success, *keyword contains the pointer of the matching option's keyword.
+ */
+po_found_t po_contains_prefix(struct mount_options *options,
+ const char *prefix, char **keyword)
+{
+ struct mount_option *option;
+
+ if (options && prefix) {
+ for (option = options->head; option; option = option->next)
+ if (strncmp(option->keyword, prefix, strlen(prefix)) == 0) {
+ *keyword = option->keyword;
+ return PO_FOUND;
+ }
+ }
+
+ return PO_NOT_FOUND;
+}
+
+/**
* po_get - return the value of the rightmost instance of an option
* @options: pointer to mount options
* @keyword: pointer to a C string containing option keyword for which to search
diff --git a/utils/mount/parse_opt.h b/utils/mount/parse_opt.h
index 5037207..0745e0f 100644
--- a/utils/mount/parse_opt.h
+++ b/utils/mount/parse_opt.h
@@ -45,6 +45,8 @@ po_return_t po_join(struct mount_options *, char **);
po_return_t po_append(struct mount_options *, char *);
po_found_t po_contains(struct mount_options *, char *);
+po_found_t po_contains_prefix(struct mount_options *options,
+ const char *prefix, char **keyword);
char * po_get(struct mount_options *, char *);
po_found_t po_get_numeric(struct mount_options *,
char *, long *);