[lxc-devel] [lxc/master] config: try to create workdir if not exist
xinhua9569 on Github
lxc-bot at linuxcontainers.org
Mon Dec 23 11:06:24 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 350 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191223/0ccb2f9b/attachment.bin>
-------------- next part --------------
From e0263b47d2c0f742f6fa81b8ffde151f3bfc1930 Mon Sep 17 00:00:00 2001
From: dongxinhua <dongxinhua at huawei.com>
Date: Mon, 23 Dec 2019 18:59:29 +0800
Subject: [PATCH] config: try to create workdir if not exist
Signed-off-by: dongxinhua <dongxinhua at huawei.com>
---
src/lxc/start.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/lxc/start.c b/src/lxc/start.c
index a9a07bc836..d9ab5d1f43 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1421,6 +1421,11 @@ static int do_start(void *data)
setsid();
if (handler->conf->init_cwd) {
+ struct stat st;
+ if (stat(handler->conf->init_cwd, &st) < 0 && 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\"",
More information about the lxc-devel
mailing list