From db6f2862441d97105f8ee1f26a22d17daf5717e1 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Mon, 26 Sep 2016 17:51:49 +0800 Subject: [PATCH] ignore the errno EEXIST when symlink for /dev/fd & /dev/std* Signed-off-by: Lai Jiangshan --- src/container.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/container.c b/src/container.c index 046d0ac..e7a4537 100644 --- a/src/container.c +++ b/src/container.c @@ -322,10 +322,11 @@ static int container_setup_mount(struct hyper_container *container) return -1; } - if (symlink("/proc/self/fd", "./dev/fd") < 0 || - symlink("/proc/self/fd/0", "./dev/stdin") < 0 || - symlink("/proc/self/fd/1", "./dev/stdout") < 0 || - symlink("/proc/self/fd/2", "./dev/stderr") < 0) { + /* 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) || + (symlink("/proc/self/fd/2", "./dev/stderr") < 0 && errno != EEXIST)) { perror("failed to symlink for /dev/fd, /dev/stdin, /dev/stdout or /dev/stderr"); return -1; }