From 71c5729c47c806cda99a2afa8073fe699d8849d2 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Thu, 7 Jan 2021 12:10:23 -0500 Subject: [PATCH] fix: file: Rename fcheck lookup_fd_rcu (v5.11) See upstream commit: commit 460b4f812a9d473d4b39d87d37844f9fc30a9eb3 Author: Eric W. Biederman Date: Fri Nov 20 17:14:27 2020 -0600 file: Rename fcheck lookup_fd_rcu Also remove the confusing comment about checking if a fd exists. I could not find one instance in the entire kernel that still matches the description or the reason for the name fcheck. The need for better names became apparent in the last round of discussion of this set of changes[1]. [1] https://lkml.kernel.org/r/CAHk-=wj8BQbgJFLa+J0e=iT-1qpmCRTbPAJ8gd6MJQ=kbRPqyQ@mail.gmail.com Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers Change-Id: Ic44ef9b2e3e98153e2d141fc4550b61b6c011793 --- probes/lttng-uprobes.c | 4 ++-- wrapper/fdtable.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/probes/lttng-uprobes.c b/probes/lttng-uprobes.c index bda1d9b4..acb2627a 100644 --- a/probes/lttng-uprobes.c +++ b/probes/lttng-uprobes.c @@ -9,7 +9,7 @@ * */ -#include +#include #include #include #include @@ -126,7 +126,7 @@ static struct inode *get_inode_from_fd(int fd) * Returns the file backing the given fd. Needs to be done inside an RCU * critical section. */ - file = fcheck(fd); + file = lttng_lookup_fd_rcu(fd); if (file == NULL) { printk(KERN_WARNING "Cannot access file backing the fd(%d)\n", fd); inode = NULL; diff --git a/wrapper/fdtable.h b/wrapper/fdtable.h index b8b1a471..86a6a079 100644 --- a/wrapper/fdtable.h +++ b/wrapper/fdtable.h @@ -11,6 +11,20 @@ #include #include +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0)) +static inline +struct file *lttng_lookup_fd_rcu(unsigned int fd) +{ + return lookup_fd_rcu(fd); +} +#else +static inline +struct file *lttng_lookup_fd_rcu(unsigned int fd) +{ + return fcheck(fd); +} +#endif + #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,7,0)) int lttng_iterate_fd(struct files_struct *files, -- 2.34.1