cleanup: add correct error messages to lttng-get-syscall-inout.sh
[lttng-modules.git] / include / wrapper / fdtable.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
2 *
3 * wrapper/fdtable.h
4 *
5 * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 */
7
8#ifndef _LTTNG_WRAPPER_FDTABLE_H
9#define _LTTNG_WRAPPER_FDTABLE_H
10
11#include <lttng/kernel-version.h>
12#include <linux/fdtable.h>
13#include <linux/sched.h>
14
15#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0))
16static inline
17struct file *lttng_lookup_fdget_rcu(unsigned int fd)
18{
19 return lookup_fdget_rcu(fd);
20}
21
22#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0))
23static inline
24struct file *lttng_lookup_fdget_rcu(unsigned int fd)
25{
26 struct file* file = lookup_fd_rcu(fd);
27
28 if (unlikely(!file || !get_file_rcu(file)))
29 return NULL;
30 return file;
31}
32#else
33static inline
34struct file *lttng_lookup_fdget_rcu(unsigned int fd)
35{
36 struct file* file = fcheck(fd);
37
38 if (unlikely(!file || !get_file_rcu(file)))
39 return NULL;
40 return file;
41}
42#endif
43
44#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0))
45static inline
46bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files)
47{
48 return close_on_exec(fd, files);
49}
50#else
51static inline
52bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files)
53{
54 return close_on_exec(fd, files_fdtable(files));
55}
56#endif
57
58#endif /* _LTTNG_WRAPPER_FDTABLE_H */
This page took 0.024632 seconds and 5 git commands to generate.