summaryrefslogtreecommitdiffstats
path: root/mount/fstab.c
diff options
context:
space:
mode:
Diffstat (limited to 'mount/fstab.c')
-rw-r--r--mount/fstab.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/mount/fstab.c b/mount/fstab.c
index 26d3fc291..069a4084c 100644
--- a/mount/fstab.c
+++ b/mount/fstab.c
@@ -760,6 +760,7 @@ lock_mtab (void) {
}
}
+/* returns whole option with name @optname from @src list */
static char *
get_option(const char *optname, const char *src, size_t *len)
{
@@ -786,6 +787,25 @@ get_option(const char *optname, const char *src, size_t *len)
return NULL;
}
+ /* If @list contains "user=peter" and @s is "user=", return "peter" */
+char *
+get_option_value(const char *list, const char *s)
+{
+ const char *t;
+ size_t n = strlen(s);
+
+ while (list && *list) {
+ if (strncmp(list, s, n) == 0) {
+ s = t = list + n;
+ while (*s && *s != ',')
+ s++;
+ return xstrndup(t, s-t);
+ }
+ while (*list && *list++ != ',') ;
+ }
+ return NULL;
+}
+
static int
cpy_option(const char *optname, char *dest, const char *src)
{