[CRIU] [PATCH 11/16] dump: hide pipe open

Kinsbursky Stanislav skinsbursky at openvz.org
Thu Mar 1 12:57:30 EST 2012



Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>

---
 cr-dump.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index 295be26..09e362a 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -248,19 +248,28 @@ err:
 	return ret;
 }
 
-static int dump_one_pipe(struct fd_parms *p, int lfd, struct cr_fdset *cr_fdset)
+static int dump_one_pipe(struct fd_parms *p, struct cr_fdset *cr_fdset)
 {
 	struct pipe_entry e;
 	int ret = -1;
+	int lfd;
+	char file_path[128];
 	struct statfs stfs_buf;
 
+	snprintf(file_path, sizeof(file_path), "/proc/%d/fd/%ld", p->pid, p->fd_name);
+	lfd = open(file_path, O_RDONLY);
+	if (lfd < 0) {
+		pr_perror("Failed to open pipe '%s'\n", file_path);
+		return -1;
+	}
+
 	if (fstatfs(lfd, &stfs_buf) < 0) {
 		pr_perror("Can't fstatfs on %ld", p->fd_name);
 		return -1;
 	}
 
 	if (stfs_buf.f_type != PIPEFS_MAGIC) {
-		pr_err("Dumping of FIFO's is not supported: %ld\n", p->fd_name);
+		pr_err("Dumping of FIFO's is not supported: '%s'\n", file_path);
 		return -1;
 	}
 
@@ -283,6 +292,7 @@ err:
 	else
 		pr_err("Dumping pipe %ld/%lx flags %x\n", p->fd_name, p->ino, p->flags);
 
+	close_safe(&lfd);
 	return ret;
 }
 
@@ -360,7 +370,7 @@ static int dump_one_fd(pid_t pid, char *d_name, struct cr_fdset *cr_fdset,
 		err = dump_one_reg_file(&p, lfd, cr_fdset, 0);
 		break;
 	case S_IFIFO:
-		err = dump_one_pipe(&p, lfd, cr_fdset);
+		err = dump_one_pipe(&p, cr_fdset);
 		break;
 	case S_IFSOCK:
 		err = try_dump_socket(pid, p.fd_name, cr_fdset, sk_queue);



More information about the CRIU mailing list