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 MD |
12 | #include <linux/fdtable.h> |
13 | ||
2d042821 | 14 | #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,7,0)) |
83f9bb7f MD |
15 | |
16 | int lttng_iterate_fd(struct files_struct *files, | |
17 | unsigned int first, | |
18 | int (*cb)(const void *, struct file *, unsigned int), | |
19 | const void *ctx); | |
20 | ||
21 | #else | |
22 | ||
23 | /* | |
24 | * iterate_fd() appeared at commit | |
25 | * c3c073f808b22dfae15ef8412b6f7b998644139a in the Linux kernel (first | |
26 | * released kernel: v3.7). | |
27 | */ | |
28 | #define lttng_iterate_fd iterate_fd | |
29 | ||
30 | #endif | |
518dba2d | 31 | |
2d042821 | 32 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,4,0)) |
518dba2d MJ |
33 | |
34 | static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt) | |
35 | { | |
36 | return close_on_exec(fd, fdt); | |
37 | } | |
38 | ||
39 | #else | |
40 | ||
41 | static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt) | |
42 | { | |
43 | return FD_ISSET(fd, fdt->close_on_exec); | |
44 | } | |
45 | ||
46 | #endif | |
47 | ||
83f9bb7f | 48 | #endif /* _LTTNG_WRAPPER_FDTABLE_H */ |