[lxc-devel] [lxc/master] Fix issue #1702, do remount with the MS_REMOUNT flag when mounts with MS_RDONLY

lifeng68 on Github lxc-bot at linuxcontainers.org
Mon Jul 17 01:11:39 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 988 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170717/1dc81b0f/attachment.bin>
-------------- next part --------------
From 0a693043fb54b2433e0936a2f69f3179e7591613 Mon Sep 17 00:00:00 2001
From: Li Feng <lifeng68 at huawei.com>
Date: Mon, 17 Jul 2017 17:09:16 +0800
Subject: [PATCH] Fix issue #1702, do remount with the MS_REMOUNT flag when
 mounts with MS_RDONLY

Signed-off-by: Li Feng <lifeng68 at huawei.com>
---
 src/lxc/bdev/lxcdir.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/lxc/bdev/lxcdir.c b/src/lxc/bdev/lxcdir.c
index 652d7e08f..0778df1cc 100644
--- a/src/lxc/bdev/lxcdir.c
+++ b/src/lxc/bdev/lxcdir.c
@@ -151,6 +151,12 @@ int dir_mount(struct bdev *bdev)
 	src = lxc_storage_get_path(bdev->src, bdev->type);
 
 	ret = mount(src, bdev->dest, "bind", MS_BIND | MS_REC | mntflags, mntdata);
+	if ((0 == ret) && (mntflags & MS_RDONLY)) {
+		DEBUG("remounting %s on %s with readonly options",
+			src ? src : "(none)", bdev->dest ? bdev->dest : "(none)");
+		ret = mount(src, bdev->dest, "bind", MS_BIND | MS_REC | mntflags | MS_REMOUNT, mntdata);
+	}
+
 	free(mntdata);
 	return ret;
 }


More information about the lxc-devel mailing list