[CRIU] [PATCH 2/4] files: Make find_used_fd work on pstree_item
Pavel Emelyanov
xemul at virtuozzo.com
Thu Feb 16 04:11:27 PST 2017
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/files.c | 9 +++++----
criu/include/files.h | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/criu/files.c b/criu/files.c
index a0eecf0..371f0d7 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -98,10 +98,12 @@ static inline struct file_desc *find_file_desc(FdinfoEntry *fe)
return find_file_desc_raw(fe->type, fe->id);
}
-struct fdinfo_list_entry *find_used_fd(struct list_head *head, int fd)
+struct fdinfo_list_entry *find_used_fd(struct pstree_item *task, int fd)
{
+ struct list_head *head;
struct fdinfo_list_entry *fle;
+ head = &rsti(task)->used;
list_for_each_entry_reverse(fle, head, used_list) {
if (fle->fe->fd == fd)
return fle;
@@ -134,14 +136,13 @@ unsigned int find_unused_fd(struct pstree_item *task, int hint_fd)
struct fdinfo_list_entry *fle;
int fd = 0, prev_fd;
- head = &rsti(task)->used;
-
- if ((hint_fd >= 0) && (!find_used_fd(head, hint_fd))) {
+ if ((hint_fd >= 0) && (!find_used_fd(task, hint_fd))) {
fd = hint_fd;
goto out;
}
prev_fd = service_fd_min_fd() - 1;
+ head = &rsti(task)->used;
list_for_each_entry_reverse(fle, head, used_list) {
fd = fle->fe->fd;
diff --git a/criu/include/files.h b/criu/include/files.h
index 855f095..98e5410 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -118,7 +118,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 pstree_item *, int hint_fd);
-struct fdinfo_list_entry *find_used_fd(struct list_head *head, int fd);
+struct fdinfo_list_entry *find_used_fd(struct pstree_item *, int fd);
struct file_desc {
u32 id; /* File id, unique */
--
2.5.0
More information about the CRIU
mailing list