diff options
author | Petr Uzel | 2011-01-26 12:17:00 +0100 |
---|---|---|
committer | Karel Zak | 2011-01-31 17:12:49 +0100 |
commit | 7897c815ba0319146a4fe41f12eaba802dd3b3ff (patch) | |
tree | 1d0e94a7a73a023e2dd9c0d95bca7180b2a129a4 /mount/fstab.c | |
parent | build-sys: provide missing strnlen from strutils (diff) | |
download | kernel-qcow2-util-linux-7897c815ba0319146a4fe41f12eaba802dd3b3ff.tar.gz kernel-qcow2-util-linux-7897c815ba0319146a4fe41f12eaba802dd3b3ff.tar.xz kernel-qcow2-util-linux-7897c815ba0319146a4fe41f12eaba802dd3b3ff.zip |
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 <ludwig.nussel@suse.de>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/fstab.c')
-rw-r--r-- | mount/fstab.c | 20 |
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) { |