[CRIU] [PATCH 13/16] dump: remove redundant do_close_lfd flag

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



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

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

diff --git a/cr-dump.c b/cr-dump.c
index 40af29f..91fba5f 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -98,8 +98,7 @@ struct fd_parms {
 };
 
 static int dump_one_reg_file_fd(struct fd_parms *p, int lfd,
-				struct cr_fdset *cr_fdset,
-				bool do_close_lfd)
+				struct cr_fdset *cr_fdset)
 {
 	struct fdinfo_entry e;
 	char fd_str[128];
@@ -116,9 +115,6 @@ static int dump_one_reg_file_fd(struct fd_parms *p, int lfd,
 	pr_info("Dumping path for %lx fd via self %d [%s]\n",
 		p->fd_name, lfd, big_buffer);
 
-	if (do_close_lfd)
-		close(lfd);
-
 	e.type	= p->type;
 	e.len	= len;
 	e.flags = p->flags;
@@ -165,7 +161,7 @@ static int dump_one_reg_file(struct fd_parms *p, struct cr_fdset *cr_fdset)
 		pr_perror("Failed to open regular file '%s'\n", fd_str);
 		return -1;
 	}
-	ret = dump_one_reg_file_fd(p, lfd, cr_fdset, 0);
+	ret = dump_one_reg_file_fd(p, lfd, cr_fdset);
 	close_safe(&lfd);
 	return ret;
 }
@@ -186,9 +182,10 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset)
 	fd = open_proc(pid, "cwd");
 	if (fd < 0)
 		return -1;
-	ret = dump_one_reg_file_fd(&params, fd, cr_fdset, 1);
+	ret = dump_one_reg_file_fd(&params, fd, cr_fdset);
 	if (ret)
 		return ret;
+	close(fd);
 
 	/* Dump /proc/pid/exe */
 	params = (struct fd_parms) {
@@ -201,7 +198,8 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset)
 	fd = open_proc(pid, "exe");
 	if (fd < 0)
 		return -1;
-	ret = dump_one_reg_file_fd(&params, fd, cr_fdset, 1);
+	ret = dump_one_reg_file_fd(&params, fd, cr_fdset);
+	close(fd);
 
 	return ret;
 }
@@ -490,7 +488,7 @@ static int dump_task_mappings(pid_t pid, struct list_head *vma_area_list, struct
 				else
 					p.flags = O_RDONLY;
 
-				ret = dump_one_reg_file_fd(&p, vma_area->vm_file_fd, cr_fdset, 0);
+				ret = dump_one_reg_file_fd(&p, vma_area->vm_file_fd, cr_fdset);
 				if (ret)
 					goto err;
 			}



More information about the CRIU mailing list