[CRIU] [PATCH 16/18] sk-unix: Print cwd been restored if @name_dir is present

Cyrill Gorcunov gorcunov at openvz.org
Wed Apr 12 06:58:36 PDT 2017


Otherwise it's imbalance in logs: "Reverted working dir"
printed even if no relative name is provided.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 criu/sk-unix.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 6178dd97312c..cdad971e3dea 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -893,7 +893,7 @@ static int restore_sk_common(int fd, struct unix_sk_info *ui)
 	return 0;
 }
 
-static void revert_unix_sk_cwd(int *prev_cwd_fd, int *root_fd)
+static void revert_unix_sk_cwd(struct unix_sk_info *ui, int *prev_cwd_fd, int *root_fd)
 {
 	if (*root_fd >= 0) {
 		if (fchdir(*root_fd) || chroot("."))
@@ -904,7 +904,8 @@ static void revert_unix_sk_cwd(int *prev_cwd_fd, int *root_fd)
 		if (fchdir(*prev_cwd_fd))
 			pr_perror("Can't revert working dir");
 		else
-			pr_debug("Reverted working dir\n");
+			if (ui->name_dir)
+				pr_debug("Reverted working dir\n");
 		close(*prev_cwd_fd);
 		*prev_cwd_fd = -1;
 	}
@@ -988,11 +989,11 @@ static int post_open_unix_sk(struct file_desc *d, int fd)
 				sizeof(addr.sun_family) +
 				peer->ue->name.len) < 0) {
 		pr_perror("Can't connect %#x socket", ui->ue->ino);
-		revert_unix_sk_cwd(&cwd_fd, &root_fd);
+		revert_unix_sk_cwd(peer, &cwd_fd, &root_fd);
 		return -1;
 	}
 
-	revert_unix_sk_cwd(&cwd_fd, &root_fd);
+	revert_unix_sk_cwd(peer, &cwd_fd, &root_fd);
 
 	if (peer->queuer == ui->ue->ino && restore_sk_queue(fd, peer->ue->id))
 		return -1;
@@ -1111,7 +1112,7 @@ static int bind_unix_sk(int sk, struct unix_sk_info *ui)
 
 	ret = 0;
 done:
-	revert_unix_sk_cwd(&cwd_fd, &root_fd);
+	revert_unix_sk_cwd(ui, &cwd_fd, &root_fd);
 	return ret;
 }
 
@@ -1392,7 +1393,7 @@ static void unlink_stale(struct unix_sk_info *ui)
 			ui->name ? (ui->name[0] ? ui->name : &ui->name[1]) : "-",
 			ui->name_dir ? ui->name_dir : "-");
 	}
-	revert_unix_sk_cwd(&cwd_fd, &root_fd);
+	revert_unix_sk_cwd(ui, &cwd_fd, &root_fd);
 }
 
 static int resolve_unix_peers(void *unused);
-- 
2.7.4



More information about the CRIU mailing list