summaryrefslogtreecommitdiffstats
path: root/shlibs/mount
diff options
context:
space:
mode:
authorKarel Zak2010-10-15 15:51:25 +0200
committerKarel Zak2011-01-03 12:28:45 +0100
commit6f8ab4de470fa0bc6a2932a20795fb9ff1d8241e (patch)
tree8c928ddaf3efc41f1e299e2d9faac4952fc48c35 /shlibs/mount
parenttests: use {src,build}dir variables for tests (diff)
downloadkernel-qcow2-util-linux-6f8ab4de470fa0bc6a2932a20795fb9ff1d8241e.tar.gz
kernel-qcow2-util-linux-6f8ab4de470fa0bc6a2932a20795fb9ff1d8241e.tar.xz
kernel-qcow2-util-linux-6f8ab4de470fa0bc6a2932a20795fb9ff1d8241e.zip
libmount: fix mnt_optstr_apply_flags() to work with optional variables
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount')
-rw-r--r--shlibs/mount/src/optstr.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/shlibs/mount/src/optstr.c b/shlibs/mount/src/optstr.c
index 84ce04896..5e5446589 100644
--- a/shlibs/mount/src/optstr.c
+++ b/shlibs/mount/src/optstr.c
@@ -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 a 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;