[CRIU] [PATCH 1/4] files: Make find_unused_fd work on pstree_item

Pavel Emelyanov xemul at virtuozzo.com
Thu Feb 16 04:11:10 PST 2017


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/autofs.c        | 4 ++--
 criu/files.c         | 5 ++++-
 criu/include/files.h | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/criu/autofs.c b/criu/autofs.c
index 1875fe7..0ba99fc 100644
--- a/criu/autofs.c
+++ b/criu/autofs.c
@@ -569,7 +569,7 @@ static int autofs_dup_pipe(struct pstree_item *task,
 	struct pipe_info *pi = container_of(ple->desc, struct pipe_info, d);
 	unsigned flags = O_WRONLY;
 
-	new_fd = find_unused_fd(&rsti(task)->used, new_fd);
+	new_fd = find_unused_fd(task, new_fd);
 
 	if (dup_pipe_info(pi, flags, pi->d.ops) < 0) {
 		pr_err("Failed to dup pipe entry ID %#x PIPE_ID %#x\n",
@@ -911,7 +911,7 @@ static int autofs_create_pipe(struct pstree_item *task, autofs_info_t *i,
 	struct file_desc_ops *ops;
 	PipeEntry *pe;
 
-	fd = find_unused_fd(&rsti(task)->used, fd);
+	fd = find_unused_fd(task, fd);
 
 	ops = shmalloc(sizeof(*ops));
 	if (!ops)
diff --git a/criu/files.c b/criu/files.c
index a114e18..a0eecf0 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -128,11 +128,14 @@ void collect_task_fd(struct fdinfo_list_entry *new_fle, struct rst_info *ri)
 	list_add_tail(&new_fle->used_list, &fle->used_list);
 }
 
-unsigned int find_unused_fd(struct list_head *head, int hint_fd)
+unsigned int find_unused_fd(struct pstree_item *task, int hint_fd)
 {
+	struct list_head *head;
 	struct fdinfo_list_entry *fle;
 	int fd = 0, prev_fd;
 
+	head = &rsti(task)->used;
+
 	if ((hint_fd >= 0) && (!find_used_fd(head, hint_fd))) {
 		fd = hint_fd;
 		goto out;
diff --git a/criu/include/files.h b/criu/include/files.h
index 6e0d0a2..855f095 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -117,7 +117,7 @@ struct file_desc_ops {
 
 void collect_task_fd(struct fdinfo_list_entry *new_fle, struct rst_info *ri);
 
-unsigned int find_unused_fd(struct list_head *head, int hint_fd);
+unsigned int find_unused_fd(struct pstree_item *, int hint_fd);
 struct fdinfo_list_entry *find_used_fd(struct list_head *head, int fd);
 
 struct file_desc {
-- 
2.5.0



More information about the CRIU mailing list