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 sundries.c and fixes mount to use get_value(). Novell bugzilla: #666150 Reported-by: Ludwig Nussel <ludwig.nussel@xxxxxxx> Signed-off-by: Petr Uzel <petr.uzel@xxxxxxx> --- mount/mount.c | 5 +++-- mount/sundries.c | 20 ++++++++++++++++++++ mount/sundries.h | 2 ++ mount/umount.c | 20 -------------------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/mount/mount.c b/mount/mount.c index bb4bd34..6a146db 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -2042,16 +2042,17 @@ is_fstab_entry_mounted(struct mntentchn *mc, int verbose) if ((strstr(mc->m.mnt_opts, "loop=") || (stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode)))) { - char *p = strstr(mc->m.mnt_opts, "offset="); + char *p = get_value(mc->m.mnt_opts, "offset="); uintmax_t offset = 0; - if (p && strtosize(p + 7, &offset) != 0) { + if (p && strtosize(p, &offset) != 0) { if (verbose) printf(_("mount: ignore %s " "(unparsable offset= option)\n"), mc->m.mnt_fsname); return -1; } + free(p); if (is_mounted_same_loopfile(mc->m.mnt_dir, mc->m.mnt_fsname, offset)) goto yes; } diff --git a/mount/sundries.c b/mount/sundries.c index ae4501a..5b4d9e9 100644 --- a/mount/sundries.c +++ b/mount/sundries.c @@ -298,3 +298,23 @@ char *canonicalize (const char *path) return res; } +/* + * If list contains "user=peter" and we ask for "user=", return "peter" + */ +char *get_value(const char *list, const char *s) +{ + const char *t; + int 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; +} + diff --git a/mount/sundries.h b/mount/sundries.h index 3b6a464..767226d 100644 --- a/mount/sundries.h +++ b/mount/sundries.h @@ -41,6 +41,8 @@ int is_pseudo_fs(const char *type); char *canonicalize (const char *path); char *canonicalize_spec (const char *path); +char *get_value (const char *list, const char *s); + /* exit status - bits below are ORed */ #define EX_USAGE 1 /* incorrect invocation or permission */ #define EX_SYSERR 2 /* out of memory, cannot fork, ... */ diff --git a/mount/umount.c b/mount/umount.c index 079aa33..5de1cdf 100644 --- a/mount/umount.c +++ b/mount/umount.c @@ -455,26 +455,6 @@ contains(const char *list, const char *s) { return 0; } -/* - * If list contains "user=peter" and we ask for "user=", return "peter" - */ -static char * -get_value(const char *list, const char *s) { - const char *t; - int 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; -} - /* check if @mc contains a loop device which is associated * with the @file in fs */ -- 1.7.1 Petr -- Petr Uzel IRC: ptr_uzl @ freenode
Attachment:
pgpVTrDrz3ABk.pgp
Description: PGP signature