lxc/0098-lxc-make-dev-bind-mount-from-host-tmpfs-for-system-c.patch
LiFeng 1e407c11a9 lxc: internal change
Signed-off-by: LiFeng <lifeng68@huawei.com>
2020-03-03 08:56:30 -05:00

68 lines
2.2 KiB
Diff

From 5fd25f9a207a2c401e9bae990a96ec9b9056a2df Mon Sep 17 00:00:00 2001
From: tanyifeng <tanyifeng1@huawei.com>
Date: Wed, 15 May 2019 12:42:08 +0800
Subject: [PATCH 098/140] lxc: make /dev bind mount from host tmpfs for system
container
reason:make /dev bind mount from host tmpfs for system container
Signed-off-by: zhangsong <zhangsong34@huawei.com>
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
src/lxc/conf.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 341fdab..3780966 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -1122,7 +1122,7 @@ on_error:
* error, log it but don't fail yet.
*/
static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs,
- const char *lxcpath)
+ const char *lxcpath, char *systemd)
{
int ret;
size_t clen;
@@ -1147,13 +1147,21 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs,
goto reset_umask;
}
- ret = safe_mount("none", path, "tmpfs", 0, "size=500000,mode=755",
+ if (systemd != NULL && !strcmp(systemd, "true")) {
+ ret = mount(path, path, "", MS_BIND, NULL);
+ if (ret < 0) {
+ SYSERROR("Failed to bind mount path \"%s\"", path);
+ goto reset_umask;
+ }
+ } else {
+ ret = safe_mount("none", path, "tmpfs", 0, "size=500000,mode=755",
rootfs->path ? rootfs->mount : NULL);
- if (ret < 0) {
- SYSERROR("Failed to mount tmpfs on \"%s\"", path);
- goto reset_umask;
- }
- TRACE("Mounted tmpfs on \"%s\"", path);
+ if (ret < 0) {
+ SYSERROR("Failed to mount tmpfs on \"%s\"", path);
+ goto reset_umask;
+ }
+ TRACE("Mounted tmpfs on \"%s\"", path);
+ }
ret = snprintf(path, clen, "%s/dev/pts", rootfs->path ? rootfs->mount : "");
if (ret < 0 || (size_t)ret >= clen) {
@@ -4130,7 +4138,7 @@ int lxc_setup(struct lxc_handler *handler)
}
if (lxc_conf->autodev > 0) {
- ret = mount_autodev(name, &lxc_conf->rootfs, lxcpath);
+ ret = mount_autodev(name, &lxc_conf->rootfs, lxcpath, lxc_conf->systemd);
if (ret < 0) {
ERROR("Failed to mount \"/dev\"");
goto on_error;
--
1.8.3.1