From: dongxinhua Date: Mon, 23 Dec 2019 10:59:29 +0000 (+0800) Subject: config: try to create workdir if not exist X-Git-Tag: v6.0.0~32^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=789457f1ae076552a3fbd6b7dd579ed74c4c5a39;p=thirdparty%2Flxc.git config: try to create workdir if not exist Signed-off-by: dongxinhua --- 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\"",