[CRIU] [PATCH v2 07/11] dump: hide pipe open

Kinsbursky Stanislav skinsbursky at openvz.org
Mon Mar 5 07:38:45 EST 2012


This patch hides fd reopen for pipes.
Next one will hide the same operation for regular files.

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

---
 cr-dump.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index b880f8e..8494820 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -250,19 +250,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 d_name[32];
 	struct statfs stfs_buf;
 
+	snprintf(d_name, sizeof(d_name), "%ld", p->fd_name);
+	lfd = openat(p->pid_fd_dir, d_name, O_RDONLY);
+	if (lfd < 0) {
+		pr_perror("Failed to open pipe %d/%ld\n", p->pid_fd_dir, p->fd_name);
+		return -1;
+	}
+
 	if (fstatfs(lfd, &stfs_buf) < 0) {
-		pr_perror("Can't fstatfs on %ld", p->fd_name);
+		pr_perror("Can't fstatfs on %d/%ld", p->pid_fd_dir, 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("FIFO is not supported: %d/%ld'\n", p->pid_fd_dir, p->fd_name);
 		return -1;
 	}
 
@@ -285,6 +294,7 @@ err:
 	else
 		pr_err("Dumping pipe %ld/%lx flags %x\n", p->fd_name, p->ino, p->flags);
 
+	close_safe(&lfd);
 	return ret;
 }
 
@@ -363,7 +373,7 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct 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