From 7897c815ba0319146a4fe41f12eaba802dd3b3ff Mon Sep 17 00:00:00 2001 From: Petr Uzel Date: Wed, 26 Jan 2011 12:17:00 +0100 Subject: mount: fix parsing offset= followed by more options mount does not parse parse offset= option if it is followed by other options. In umount, the parsing is done with the get_value() function. This patch moves get_value to fstab.c (with new name get_option_value()) and fixes mount to use the function. [kzak@redhat.com: - rename to get_option_value() - use fstab.c rather than sundries.c] Novell bugzilla: #666150 Reported-by: Ludwig Nussel Signed-off-by: Petr Uzel Signed-off-by: Karel Zak --- mount/fstab.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'mount/fstab.c') 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) { -- cgit v1.2.3-55-g7522