From: Michael Jeanson Date: Fri, 2 Oct 2020 20:10:05 +0000 (-0400) Subject: fix: backport 'Add 'kernel_read' wrapper for kernels < v4.14' X-Git-Tag: v2.11.6~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f09336431c054edc4349b579463db0b3c6006ae5;p=lttng-modules.git fix: backport 'Add 'kernel_read' wrapper for kernels < v4.14' Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers Change-Id: I3b558a6a4b850054d5786bdf99e0849091c83eae --- diff --git a/include/wrapper/fs.h b/include/wrapper/fs.h deleted file mode 100644 index f11c19fc..00000000 --- a/include/wrapper/fs.h +++ /dev/null @@ -1,43 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * wrapper/fs.h - * - * Copyright (C) 2020 Michael Jeanson - */ - -#ifndef _LTTNG_WRAPPER_FS_H -#define _LTTNG_WRAPPER_FS_H - -#include -#include - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) - -static inline -ssize_t lttng_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) -{ - return kernel_read(file, buf, count, pos); -} - -#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) */ - -static inline -ssize_t lttng_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) -{ - ssize_t len; - - len = kernel_read(file, *pos, buf, count); - - /* - * Move 'pos' forward since it's passed by value in this - * implementation of 'kernel_read'. - */ - if (len > 0) - (*pos) += len; - - return len; -} - -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) */ - -#endif /* _LTTNG_WRAPPER_FS_H */ diff --git a/wrapper/fs.h b/wrapper/fs.h new file mode 100644 index 00000000..99697f87 --- /dev/null +++ b/wrapper/fs.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * wrapper/fs.h + * + * Copyright (C) 2020 Michael Jeanson + */ + +#ifndef _LTTNG_WRAPPER_FS_H +#define _LTTNG_WRAPPER_FS_H + +#include +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) + +static inline +ssize_t lttng_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) +{ + return kernel_read(file, buf, count, pos); +} + +#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) */ + +static inline +ssize_t lttng_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) +{ + ssize_t len; + + len = kernel_read(file, *pos, buf, count); + + /* + * Move 'pos' forward since it's passed by value in this + * implementation of 'kernel_read'. + */ + if (len > 0) + (*pos) += len; + + return len; +} + +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) */ + +#endif /* _LTTNG_WRAPPER_FS_H */