From 789457f1ae076552a3fbd6b7dd579ed74c4c5a39 Mon Sep 17 00:00:00 2001 From: dongxinhua Date: Mon, 23 Dec 2019 18:59:29 +0800 Subject: [PATCH] config: try to create workdir if not exist Signed-off-by: dongxinhua --- src/lxc/start.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lxc/start.c b/src/lxc/start.c index e1dff590f..d8f641a8d 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -1326,6 +1326,12 @@ static int do_start(void *data) setsid(); if (handler->conf->init_cwd) { + struct stat st; + if (stat(handler->conf->init_cwd, &st) < 0 && lxc_mkdir_p(handler->conf->init_cwd, 0755) < 0) { + SYSERROR("Try to create directory \"%s\" as workdir failed", handler->conf->init_cwd); + goto out_warn_father; + } + ret = chdir(handler->conf->init_cwd); if (ret < 0) { SYSERROR("Could not change directory to \"%s\"", -- 2.47.2