diff --git a/criu/autofs.c b/criu/autofs.c index 351343149..1875fe799 100644 --- a/criu/autofs.c +++ b/criu/autofs.c @@ -875,9 +875,7 @@ static int autofs_create_fle(struct pstree_item *task, FdinfoEntry *fe, fle_init(le, task->pid->ns[0].virt, fe); - collect_gen_fd(le, rst_info); - - collect_used_fd(le, rst_info); + collect_task_fd(le, rst_info); list_add_tail(&le->desc_list, &desc->fd_info_head); le->desc = desc; diff --git a/criu/fifo.c b/criu/fifo.c index cb642befc..5e2b44ff5 100644 --- a/criu/fifo.c +++ b/criu/fifo.c @@ -126,7 +126,6 @@ static void collect_fifo_fd(struct file_desc *d, info = container_of(d, struct fifo_info, d); info->reg_d = collect_special_file(info->fe->id); BUG_ON(info->reg_d == NULL); - collect_gen_fd(fle, ri); } static struct file_desc_ops fifo_desc_ops = { diff --git a/criu/files-reg.c b/criu/files-reg.c index 82790ce76..81982e052 100644 --- a/criu/files-reg.c +++ b/criu/files-reg.c @@ -1654,12 +1654,6 @@ int collect_filemap(struct vma_area *vma) return 0; } -static void collect_reg_fd(struct file_desc *fdesc, - struct fdinfo_list_entry *fle, struct rst_info *ri) -{ - collect_gen_fd(fle, ri); -} - static int open_fe_fd(struct file_desc *fd, int *new_fd) { int tmp; @@ -1682,7 +1676,6 @@ static char *reg_file_path(struct file_desc *d, char *buf, size_t s) static struct file_desc_ops reg_desc_ops = { .type = FD_TYPES__REG, .open = open_fe_fd, - .collect_fd = collect_reg_fd, .name = reg_file_path, }; diff --git a/criu/files.c b/criu/files.c index 79a765e47..b83e62db1 100644 --- a/criu/files.c +++ b/criu/files.c @@ -112,10 +112,14 @@ struct fdinfo_list_entry *find_used_fd(struct list_head *head, int fd) return NULL; } -void collect_used_fd(struct fdinfo_list_entry *new_fle, struct rst_info *ri) +void collect_task_fd(struct fdinfo_list_entry *new_fle, struct rst_info *ri) { struct fdinfo_list_entry *fle; + /* fles in fds list are disordered */ + list_add_tail(&new_fle->ps_list, &ri->fds); + + /* fles in used list are ordered by fd */ list_for_each_entry(fle, &ri->used, used_list) { if (new_fle->fe->fd < fle->fe->fd) break; @@ -705,10 +709,8 @@ static int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info) if (fdesc->ops->collect_fd) fdesc->ops->collect_fd(fdesc, new_le, rst_info); - else - collect_gen_fd(new_le, rst_info); - collect_used_fd(new_le, rst_info); + collect_task_fd(new_le, rst_info); list_add_tail(&new_le->desc_list, &le->desc_list); new_le->desc = fdesc; diff --git a/criu/include/files.h b/criu/include/files.h index cd7c4608d..39ef23b77 100644 --- a/criu/include/files.h +++ b/criu/include/files.h @@ -115,12 +115,7 @@ struct file_desc_ops { char * (*name)(struct file_desc *, char *b, size_t s); }; -extern void collect_used_fd(struct fdinfo_list_entry *new_fle, struct rst_info *ri); - -static inline void collect_gen_fd(struct fdinfo_list_entry *fle, struct rst_info *ri) -{ - list_add_tail(&fle->ps_list, &ri->fds); -} +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); struct fdinfo_list_entry *find_used_fd(struct list_head *head, int fd);