[CRIU] [PATCH v2 02/15] files: Implement find_used_fd()
Pavel Emelyanov
xemul at virtuozzo.com
Mon May 30 04:33:14 PDT 2016
On 05/27/2016 04:05 PM, Kirill Tkhai wrote:
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
> criu/files.c | 13 +++++++++++++
> criu/include/files.h | 1 +
> 2 files changed, 14 insertions(+)
>
> diff --git a/criu/files.c b/criu/files.c
> index a52e12f..0e9e41d 100644
> --- a/criu/files.c
> +++ b/criu/files.c
> @@ -128,6 +128,19 @@ unsigned int find_unused_fd(struct list_head *head, int hint_fd)
> return fd;
> }
>
> +struct fdinfo_list_entry *find_used_fd(struct list_head *head, int fd)
> +{
> + struct fdinfo_list_entry *fle;
> +
> + list_for_each_entry_reverse(fle, head, used_list) {
> + if (fle->fe->fd == fd)
> + return fle;
This only differs from fd_is_used() with return argument. Can we squash two routines together?
> + }
> + pr_err("Trying to unhash unexisting fd %d\n", fd);
> + BUG();
> + return NULL;
+}
> +
> /*
> * A file may be shared between several file descriptors. E.g
> * when doing a fork() every fd of a forker and respective fds
> diff --git a/criu/include/files.h b/criu/include/files.h
> index d46b3cd..025c7d0 100644
> --- a/criu/include/files.h
> +++ b/criu/include/files.h
> @@ -138,6 +138,7 @@ static inline bool fd_is_used(struct list_head *head, int fd)
> }
>
> 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);
>
> struct file_desc {
> u32 id; /* File id, unique */
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> .
>
More information about the CRIU
mailing list