From b7d93c2ec522bc4fbaa804bf5f76ef3beffb1e67 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Thu, 22 Dec 2016 21:38:56 +0800 Subject: [PATCH 1/2] do unlink/symlink /dev/ptmx when hyperstart starts Signed-off-by: Lai Jiangshan --- src/container.c | 8 ++------ src/init.c | 9 +++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/container.c b/src/container.c index 18f449ec..3eb041f7 100644 --- a/src/container.c +++ b/src/container.c @@ -313,16 +313,12 @@ static int container_setup_mount(struct hyper_container *container) return -1; } - if (unlink("./dev/ptmx") < 0) { - perror("remove /dev/ptmx failed"); - return -1; - } - if (symlink("/dev/pts/ptmx", "./dev/ptmx") < 0) { + /* all containers share the same devtmpfs, so we need to ignore the errno EEXIST */ + if (symlink("/dev/pts/ptmx", "./dev/ptmx") < 0 && errno != EEXIST) { perror("link /dev/pts/ptmx to /dev/ptmx failed"); return -1; } - /* all containers share the same devtmpfs, so we need to ignore the errno EEXIST */ if ((symlink("/proc/self/fd", "./dev/fd") < 0 && errno != EEXIST) || (symlink("/proc/self/fd/0", "./dev/stdin") < 0 && errno != EEXIST) || (symlink("/proc/self/fd/1", "./dev/stdout") < 0 && errno != EEXIST) || diff --git a/src/init.c b/src/init.c index df67fc32..e03a7ed4 100644 --- a/src/init.c +++ b/src/init.c @@ -1380,6 +1380,15 @@ int main(int argc, char *argv[]) return -1; } + if (unlink("/dev/ptmx") < 0) { + perror("remove /dev/ptmx failed"); + return -1; + } + if (symlink("/dev/pts/ptmx", "/dev/ptmx") < 0) { + perror("link /dev/pts/ptmx to /dev/ptmx failed"); + return -1; + } + cmdline = read_cmdline(); setsid(); From 7371a6f4620178f77ef6926875c5a5f49e18e67a Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Fri, 23 Dec 2016 13:59:16 +0800 Subject: [PATCH 2/2] remove unneeded /tmp/hyper/proc Signed-off-by: Lai Jiangshan --- src/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/init.c b/src/init.c index e03a7ed4..4b6becb6 100644 --- a/src/init.c +++ b/src/init.c @@ -484,9 +484,9 @@ static int hyper_setup_shared(struct hyper_pod *pod) static int hyper_setup_pod(struct hyper_pod *pod) { - /* create tmp proc directory */ - if (hyper_mkdir("/tmp/hyper/proc", 0755) < 0) { - perror("create tmp proc failed"); + /* create sandbox directory */ + if (hyper_mkdir("/tmp/hyper", 0755) < 0) { + perror("create sandbox directory failed"); return -1; }