summaryrefslogtreecommitdiffstats
path: root/libmount
diff options
context:
space:
mode:
authorKarel Zak2012-01-13 16:27:50 +0100
committerKarel Zak2012-01-13 16:27:50 +0100
commitdc4dbbf188be91da4b13b29e04ae94f2f831e4ab (patch)
tree91713f0d0fc33f5b9ab330b3b77c92996915f01c /libmount
parentlibmount: allow to use UUID and LABEL for owner/group mount options in fstab (diff)
downloadkernel-qcow2-util-linux-dc4dbbf188be91da4b13b29e04ae94f2f831e4ab.tar.gz
kernel-qcow2-util-linux-dc4dbbf188be91da4b13b29e04ae94f2f831e4ab.tar.xz
kernel-qcow2-util-linux-dc4dbbf188be91da4b13b29e04ae94f2f831e4ab.zip
libmount: allow to toggle ro/rw and mount again
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount')
-rw-r--r--libmount/src/context.c11
-rw-r--r--libmount/src/context_mount.c4
-rw-r--r--libmount/src/mountP.h1
-rw-r--r--libmount/src/optstr.c3
4 files changed, 17 insertions, 2 deletions
diff --git a/libmount/src/context.c b/libmount/src/context.c
index 594f090f4..571a2496a 100644
--- a/libmount/src/context.c
+++ b/libmount/src/context.c
@@ -1001,7 +1001,18 @@ int mnt_context_set_mflags(struct libmnt_context *cxt, unsigned long flags)
{
if (!cxt)
return -EINVAL;
+
cxt->mountflags = flags;
+
+ if ((cxt->flags & MNT_FL_MOUNTOPTS_FIXED) && cxt->fs)
+ /*
+ * the final mount options are already generated, refresh...
+ */
+ return mnt_optstr_apply_flags(
+ &cxt->fs->vfs_optstr,
+ cxt->mountflags,
+ mnt_get_builtin_optmap(MNT_LINUX_MAP));
+
return 0;
}
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index bb895425f..6f2a3dc11 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -39,7 +39,7 @@ static int fix_optstr(struct libmnt_context *cxt)
if (!cxt)
return -EINVAL;
- if (!cxt->fs)
+ if (!cxt->fs || (cxt->flags & MNT_FL_MOUNTOPTS_FIXED))
return 0;
DBG(CXT, mnt_debug_h(cxt, "mount: fixing optstr"));
@@ -133,6 +133,8 @@ static int fix_optstr(struct libmnt_context *cxt)
fs->optstr = NULL;
fs->optstr = mnt_fs_strdup_options(fs);
done:
+ cxt->flags |= MNT_FL_MOUNTOPTS_FIXED;
+
DBG(CXT, mnt_debug_h(cxt, "fixed options [rc=%d]: "
"vfs: '%s' fs: '%s' user: '%s', optstr: '%s'", rc,
fs->vfs_optstr, fs->fs_optstr, fs->user_optstr, fs->optstr));
diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h
index fa0567877..c321702b6 100644
--- a/libmount/src/mountP.h
+++ b/libmount/src/mountP.h
@@ -338,6 +338,7 @@ struct libmnt_context
#define MNT_FL_PREPARED (1 << 24)
#define MNT_FL_HELPER (1 << 25) /* [u]mount.<type> */
#define MNT_FL_LOOPDEV_READY (1 << 26) /* /dev/loop<N> initialized by library */
+#define MNT_FL_MOUNTOPTS_FIXED (1 << 27)
/* default flags */
#define MNT_FL_DEFAULT 0
diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
index 836838440..260dc26a8 100644
--- a/libmount/src/optstr.c
+++ b/libmount/src/optstr.c
@@ -652,7 +652,7 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
if (!optstr || !map)
return -EINVAL;
- DBG(CXT, mnt_debug("applying 0x%08lu flags '%s'", flags, *optstr));
+ DBG(CXT, mnt_debug("applying 0x%08lu flags to '%s'", flags, *optstr));
maps[0] = map;
next = *optstr;
@@ -745,6 +745,7 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
}
}
+ DBG(CXT, mnt_debug("new optstr '%s'", *optstr));
return rc;
err:
DBG(CXT, mnt_debug("failed to apply flags [rc=%d]", rc));