summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2014-10-17 08:52:00 +0200
committerKarel Zak <kzak@redhat.com>2014-10-24 11:10:06 +0200
commit524e7bffc16b1fea6a10c8837cbf79b416bfbf13 (patch)
treecfe7ecbe860afe172b810f95af2e26c61036a762
parentfda297dd226610a60b85a40392b78dedcf255341 (diff)
downloadutil-linux-524e7bffc16b1fea6a10c8837cbf79b416bfbf13.tar.gz
mount: don't ignore mtab for --bind -o remount
Reported-by: Phillip Susi <psusi@ubuntu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--sys-utils/mount.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index 74a1a84f2..1d9e506e5 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -694,6 +694,16 @@ static void append_option(struct libmnt_context *cxt, const char *opt)
err(MOUNT_EX_SYSERR, _("failed to append option '%s'"), opt);
}
+static int has_remount_flag(struct libmnt_context *cxt)
+{
+ unsigned long mflags = 0;
+
+ if (mnt_context_get_mflags(cxt, &mflags))
+ return 0;
+
+ return mflags & MS_REMOUNT;
+}
+
static void __attribute__((__noreturn__)) usage(FILE *out)
{
fputs(USAGE_HEADER, out);
@@ -1087,8 +1097,8 @@ int main(int argc, char **argv)
/* BIND/MOVE operations, let's set the mount flags */
mnt_context_set_mflags(cxt, oper);
- if (oper || propa)
- /* For --make-* or --bind is fstab unnecessary */
+ if ((oper && !has_remount_flag(cxt)) || propa)
+ /* For --make-* or --bind is fstab/mtab unnecessary */
mnt_context_set_optsmode(cxt, MNT_OMODE_NOTAB);
rc = mnt_context_mount(cxt);