OSDN Git Service

vfs, fdtable: Add fget_task helper
authorSargun Dhillon <sargun@sargun.me>
Tue, 7 Jan 2020 17:59:24 +0000 (09:59 -0800)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 13 Jan 2020 20:48:42 +0000 (21:48 +0100)
commit5e876fb43dbf24c941a323139752bcb2f0a80da0
tree79948c06e4f93aeb83eb698d2409ca4997bd942a
parentc79f46a282390e0f5b306007bf7b11a46d529538
vfs, fdtable: Add fget_task helper

This introduces a function which can be used to fetch a file, given an
arbitrary task. As long as the user holds a reference (refcnt) to the
task_struct it is safe to call, and will either return NULL on failure,
or a pointer to the file, with a refcnt.

This patch is based on Oleg Nesterov's (cf. [1]) patch from September
2018.

Link: https://lore.kernel.org/r/20180915160423.GA31461@redhat.com
Signed-off-by: Sargun Dhillon <sargun@sargun.me>
Suggested-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200107175927.4558-2-sargun@sargun.me
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
fs/file.c
include/linux/file.h