mount proc filesystem of container in enter_container

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
This commit is contained in:
Gao feng
2016-07-07 18:50:47 +08:00
parent 1f501c5417
commit 70d35640b9
2 changed files with 10 additions and 3 deletions
+2 -2
View File
@@ -268,8 +268,8 @@ static int container_setup_mount(struct hyper_container *container)
hyper_mkdir("./dev");
hyper_mkdir("./lib/modules");
if (mount("proc", "./proc", "proc", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0 ||
mount("sysfs", "./sys", "sysfs", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0 ||
// mount proc filesystem when the container init process running in the pidns of podinit
if (mount("sysfs", "./sys", "sysfs", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0 ||
mount("devtmpfs", "./dev", "devtmpfs", MS_NOSUID, NULL) < 0) {
perror("mount basic filesystem for container failed");
return -1;
+8 -1
View File
@@ -8,6 +8,7 @@
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/mount.h>
#include <dirent.h>
#include <sched.h>
#include <errno.h>
@@ -518,8 +519,14 @@ static int hyper_enter_container(struct hyper_pod *pod,
/* TODO: wait for container finishing setup root */
chdir("/");
ret = 0;
/* already in pidns & mntns of container, mount proc filesystem */
if (exec->init && mount("proc", "/proc", "proc", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0) {
perror("fail to mount proc filesystem for container");
goto out;
}
ret = 0;
out:
close(ipcns);
close(utsns);