1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
5 * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 #ifndef _LTTNG_WRAPPER_FDTABLE_H
9 #define _LTTNG_WRAPPER_FDTABLE_H
11 #include <lttng/kernel-version.h>
12 #include <linux/fdtable.h>
13 #include <linux/sched.h>
15 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0))
17 struct file
*lttng_lookup_fdget_rcu(unsigned int fd
)
19 return lookup_fdget_rcu(fd
);
22 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0))
24 struct file
*lttng_lookup_fdget_rcu(unsigned int fd
)
26 struct file
* file
= lookup_fd_rcu(fd
);
28 if (unlikely(!file
|| !get_file_rcu(file
)))
32 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,1,0))
34 struct file
*lttng_lookup_fdget_rcu(unsigned int fd
)
36 struct file
* file
= fcheck(fd
);
38 if (unlikely(!file
|| !get_file_rcu(file
)))
44 struct file
*lttng_lookup_fdget_rcu(unsigned int fd
)
46 struct file
* file
= fcheck(fd
);
48 if (unlikely(!file
|| !atomic_long_inc_not_zero(&file
->f_count
)))
54 #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,7,0))
56 int lttng_iterate_fd(struct files_struct
*files
,
58 int (*cb
)(const void *, struct file
*, unsigned int),
64 * iterate_fd() appeared at commit
65 * c3c073f808b22dfae15ef8412b6f7b998644139a in the Linux kernel (first
66 * released kernel: v3.7).
68 #define lttng_iterate_fd iterate_fd
72 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,4,0))
74 static inline bool lttng_close_on_exec(int fd
, const struct fdtable
*fdt
)
76 return close_on_exec(fd
, fdt
);
81 static inline bool lttng_close_on_exec(int fd
, const struct fdtable
*fdt
)
83 return FD_ISSET(fd
, fdt
->close_on_exec
);
88 #endif /* _LTTNG_WRAPPER_FDTABLE_H */
This page took 0.034776 seconds and 4 git commands to generate.