[lxc-devel] [lxc/master] mount: Allow over-mounting

stgraber on Github lxc-bot at linuxcontainers.org
Sat Feb 16 01:02:28 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190215/5cbf5fb9/attachment.bin>
-------------- next part --------------
From c00d0e3b2a06b34ebe25c27208ab38075bbf33d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 15 Feb 2019 20:02:07 -0500
Subject: [PATCH] mount: Allow over-mounting
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 src/lxc/lxccontainer.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 9875a58a37..667674ba0b 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -5071,10 +5071,12 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
 			_exit(EXIT_FAILURE);
 		}
 
-		ret = create_mount_target(target, sb.st_mode);
-		if (ret < 0)
-			_exit(EXIT_FAILURE);
-		TRACE("Created mount target \"%s\"", target);
+		if (access(target, F_OK) < 0 && errno == ENOENT) {
+			ret = create_mount_target(target, sb.st_mode);
+			if (ret < 0)
+				_exit(EXIT_FAILURE);
+			TRACE("Created mount target \"%s\"", target);
+		}
 
 		suff = strrchr(template, '/');
 		if (!suff)


More information about the lxc-devel mailing list