]> err.no Git - util-linux/commitdiff
libmount: fix mnt_optstr_apply_flags() to work with optional variables
authorKarel Zak <kzak@redhat.com>
Fri, 15 Oct 2010 13:51:25 +0000 (15:51 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Jan 2011 11:28:45 +0000 (12:28 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/mount/src/optstr.c

index 84ce048964763b47e9945ae368aadca2e265c498..5e54465896da5fea1d267b63734e3f5c42dccd5d 100644 (file)
@@ -630,7 +630,7 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
        fl = flags;
 
        /*
-        * There is convetion that 'rw/ro' flags is always at the begin of
+        * There is convetion that 'rw/ro' flags is always at the begin of
         * the string (athough the 'rw' is unnecessary).
         */
        if (map == mnt_get_builtin_optmap(MNT_LINUX_MAP)) {
@@ -696,11 +696,12 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
 
                        /* don't add options which require values (e.g. offset=%d) */
                        p = strchr(ent->name, '=');
-                       if (p && p > ent->name && *(p - 1) != '[')
-                               continue;
-
-                       /* prepare name for value with optional value (e.g. loop[=%s]) */
                        if (p) {
+                               if (*(p - 1) == '[')
+                                       p--;                    /* name[=%s] */
+                               else
+                                       continue;               /* name=%s */
+
                                p = strndup(ent->name, p - ent->name);
                                if (!p) {
                                        rc = -ENOMEM;