[CRIU] [PATCH v5 12/21] unix: Print reverted dir info if only directory provided

Cyrill Gorcunov gorcunov at gmail.com
Thu May 10 17:57:52 MSK 2018


Otherwise there is an imbalance in logs with number of
"Reverted working dir" message

 | (00.018604)     36: unix: Connected 0x11ceff -> 0x11cf00 (0x11cf00) flags 0
 | (00.018644)     36: unix: Reverted working dir
 | (00.018652)     36: unix: Connected 0x11cefd -> 0x11cefe (0x11cefe) flags 0
 | (00.018665)     36: unix: Reverted working dir
 | (00.018688)     36: unix: Reverted working dir

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

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index c99ae4442449..110be4a6a41e 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -1131,7 +1131,7 @@ static int restore_sk_common(int fd, struct unix_sk_info *ui)
 	return 0;
 }
 
-static int revert_unix_sk_cwd(int *prev_cwd_fd, int *root_fd, int *ns_fd)
+static int revert_unix_sk_cwd(struct unix_sk_info *ui, int *prev_cwd_fd, int *root_fd, int *ns_fd)
 {
 	int ret = 0;
 
@@ -1146,7 +1146,7 @@ static int revert_unix_sk_cwd(int *prev_cwd_fd, int *root_fd, int *ns_fd)
 	if (prev_cwd_fd && *prev_cwd_fd >= 0) {
 		if (fchdir(*prev_cwd_fd))
 			pr_perror("Can't revert working dir");
-		else
+		else if (ui->name_dir)
 			pr_debug("Reverted working dir\n");
 		close(*prev_cwd_fd);
 		*prev_cwd_fd = -1;
@@ -1280,12 +1280,12 @@ static int post_open_standalone(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, &ns_fd);
+		revert_unix_sk_cwd(peer, &cwd_fd, &root_fd, &ns_fd);
 		return -1;
 	}
 	ui->is_connected = true;
 
-	revert_unix_sk_cwd(&cwd_fd, &root_fd, &ns_fd);
+	revert_unix_sk_cwd(peer, &cwd_fd, &root_fd, &ns_fd);
 
 restore_queue:
 	if (peer->queuer == ui &&
@@ -1415,7 +1415,7 @@ static int bind_unix_sk(int sk, struct unix_sk_info *ui)
 
 	exit_code = 0;
 done:
-	revert_unix_sk_cwd(&cwd_fd, &root_fd, &ns_fd);
+	revert_unix_sk_cwd(ui, &cwd_fd, &root_fd, &ns_fd);
 	return exit_code;
 }
 
@@ -1771,7 +1771,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, &ns_fd);
+	revert_unix_sk_cwd(ui, &cwd_fd, &root_fd, &ns_fd);
 }
 
 static void try_resolve_unix_peer(struct unix_sk_info *ui);
-- 
2.14.3



More information about the CRIU mailing list