From 540981ef79b921fea26e24456fbecc648eaf6e9e Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Sat, 8 May 2021 11:02:08 +0800
Subject: [PATCH] print error message if process workdir failed

Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
 src/lxc/attach.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index 2ed2329..68f4148 100644
--- a/src/lxc/attach.c
+++ b/src/lxc/attach.c
@@ -798,10 +798,14 @@ static int attach_child_main(struct attach_clone_payload *payload)
 		struct stat st;
 		if (stat(init_cwd, &st) < 0 && mkdir_p(init_cwd, 0750) < 0) {
 			SYSERROR("Try to create directory \"%s\" as workdir failed when attach", init_cwd);
+			lxc_write_error_message(msg_fd, "Try to create directory \"%s\" as workdir failed when attach: %s",
+						init_cwd, strerror(errno));
 			goto on_error;
 		}
 		if (chdir(init_cwd)) {
 			SYSERROR("Could not change directory to \"%s\" when attach", init_cwd);
+			lxc_write_error_message(msg_fd, "Could not change directory to \"%s\" when attach: %s",
+						init_cwd, strerror(errno));
 			goto on_error;
 		}
 	}
-- 
2.25.1

