lxc/0098-lxc-make-dev-bind-mount-from-host-tmpfs-for-system-c.patch

68 lines
2.2 KiB
Diff
Raw Normal View History

From fc25d8c2e9e95f227f13244503b91aaf24367c90 Mon Sep 17 00:00:00 2001
2019-09-30 11:03:07 -04:00
From: tanyifeng <tanyifeng1@huawei.com>
Date: Wed, 15 May 2019 12:42:08 +0800
Subject: [PATCH 098/139] lxc: make /dev bind mount from host tmpfs for system
2019-09-30 11:03:07 -04:00
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
2019-09-30 11:03:07 -04:00
--- 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
2019-09-30 11:03:07 -04:00