Commit | Line | Data |
---|---|---|
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 | |
5f4c791e | 15 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0)) |
0aebcd68 MJ |
16 | static inline |
17 | struct file *lttng_lookup_fd_rcu(unsigned int fd) | |
18 | { | |
19 | return lookup_fd_rcu(fd); | |
20 | } | |
21 | #else | |
22 | static inline | |
23 | struct file *lttng_lookup_fd_rcu(unsigned int fd) | |
24 | { | |
25 | return fcheck(fd); | |
26 | } | |
27 | #endif | |
28 | ||
5f4c791e | 29 | #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,7,0)) |
83f9bb7f MD |
30 | |
31 | int lttng_iterate_fd(struct files_struct *files, | |
32 | unsigned int first, | |
33 | int (*cb)(const void *, struct file *, unsigned int), | |
34 | const void *ctx); | |
35 | ||
36 | #else | |
37 | ||
38 | /* | |
39 | * iterate_fd() appeared at commit | |
40 | * c3c073f808b22dfae15ef8412b6f7b998644139a in the Linux kernel (first | |
41 | * released kernel: v3.7). | |
42 | */ | |
43 | #define lttng_iterate_fd iterate_fd | |
44 | ||
45 | #endif | |
c07dca48 | 46 | |
5f4c791e | 47 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,4,0)) |
c07dca48 MJ |
48 | |
49 | static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt) | |
50 | { | |
51 | return close_on_exec(fd, fdt); | |
52 | } | |
53 | ||
54 | #else | |
55 | ||
56 | static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt) | |
57 | { | |
58 | return FD_ISSET(fd, fdt->close_on_exec); | |
59 | } | |
60 | ||
61 | #endif | |
62 | ||
83f9bb7f | 63 | #endif /* _LTTNG_WRAPPER_FDTABLE_H */ |