mirror of
https://github.com/clearlinux/hyperstart.git
synced 2026-09-03 12:11:34 +00:00
mount proc filesystem of container in enter_container
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
This commit is contained in:
+2
-2
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user