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