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