Fix: Build on CentOS 9 Stream 2024-06
[lttng-modules.git] / include / wrapper / fdtable.h
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
9f36eaed 2 *
83f9bb7f
MD
3 * wrapper/fdtable.h
4 *
5 * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
83f9bb7f
MD
6 */
7
9f36eaed
MJ
8#ifndef _LTTNG_WRAPPER_FDTABLE_H
9#define _LTTNG_WRAPPER_FDTABLE_H
10
5f4c791e 11#include <lttng/kernel-version.h>
83f9bb7f 12#include <linux/fdtable.h>
cf41b81e 13#include <linux/sched.h>
83f9bb7f 14
c35f268c 15#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0))
0aebcd68 16static inline
c35f268c 17struct file *lttng_lookup_fdget_rcu(unsigned int fd)
0aebcd68 18{
c35f268c
KS
19 return lookup_fdget_rcu(fd);
20}
21
4ff82ec4
MJ
22#elif ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0)) || \
23 LTTNG_KERNEL_RANGE(5,10,220, 5,11,0))
c35f268c
KS
24static inline
25struct file *lttng_lookup_fdget_rcu(unsigned int fd)
26{
27 struct file* file = lookup_fd_rcu(fd);
28
29 if (unlikely(!file || !get_file_rcu(file)))
30 return NULL;
31 return file;
0aebcd68
MJ
32}
33#else
34static inline
c35f268c 35struct file *lttng_lookup_fdget_rcu(unsigned int fd)
0aebcd68 36{
c35f268c
KS
37 struct file* file = fcheck(fd);
38
39 if (unlikely(!file || !get_file_rcu(file)))
40 return NULL;
41 return file;
0aebcd68
MJ
42}
43#endif
44
c8adc20d
MJ
45#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0))
46static inline
47bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files)
48{
49 return close_on_exec(fd, files);
50}
51#else
52static inline
53bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files)
54{
55 return close_on_exec(fd, files_fdtable(files));
56}
57#endif
58
83f9bb7f 59#endif /* _LTTNG_WRAPPER_FDTABLE_H */
This page took 0.057334 seconds and 5 git commands to generate.