Commit | Line | Data |
---|---|---|
62d0a59c MJ |
1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
2 | * | |
3 | * wrapper/fs.h | |
4 | * | |
5 | * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com> | |
6 | */ | |
7 | ||
8 | #ifndef _LTTNG_WRAPPER_FS_H | |
9 | #define _LTTNG_WRAPPER_FS_H | |
10 | ||
11 | #include <linux/fs.h> | |
12 | #include <lttng/kernel-version.h> | |
13 | ||
14 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) | |
15 | ||
16 | static inline | |
17 | ssize_t lttng_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) | |
18 | { | |
19 | return kernel_read(file, buf, count, pos); | |
20 | } | |
21 | ||
22 | #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) */ | |
23 | ||
24 | static inline | |
25 | ssize_t lttng_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) | |
26 | { | |
27 | ssize_t len; | |
28 | ||
29 | len = kernel_read(file, *pos, buf, count); | |
30 | ||
31 | /* | |
32 | * Move 'pos' forward since it's passed by value in this | |
33 | * implementation of 'kernel_read'. | |
34 | */ | |
35 | if (len > 0) | |
36 | (*pos) += len; | |
37 | ||
38 | return len; | |
39 | } | |
40 | ||
41 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) */ | |
42 | ||
43 | #endif /* _LTTNG_WRAPPER_FS_H */ |