splice wrapper: Fix missing declaration
[lttng-modules.git] / src / wrapper / splice.c
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
9f36eaed 2 *
886d51a3 3 * wrapper/splice.c
5dd620fa 4 *
711e3212 5 * wrapper around splice_to_pipe. Using KALLSYMS to get its address when
5dd620fa 6 * available, else we need to have a kernel that exports this function to GPL
d072dbc6 7 * modules. The export was introduced in kernel 4.2.
5dd620fa 8 *
886d51a3 9 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5dd620fa
MD
10 */
11
2df37e95 12#include <lttng/kernel-version.h>
86d39f4f
MD
13#include <linux/fs.h>
14#include <linux/splice.h>
15#include <wrapper/splice.h>
d072dbc6
MD
16
17#if (defined(CONFIG_KALLSYMS) \
5f4c791e 18 && (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(4,2,0)))
5dd620fa
MD
19
20#include <linux/kallsyms.h>
5a2f5e92 21#include <wrapper/kallsyms.h>
5dd620fa
MD
22
23static
24ssize_t (*splice_to_pipe_sym)(struct pipe_inode_info *pipe,
25 struct splice_pipe_desc *spd);
26
27ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
28 struct splice_pipe_desc *spd)
29{
30 if (!splice_to_pipe_sym)
1e543e7c 31 splice_to_pipe_sym = (void *) kallsyms_lookup_funcptr("splice_to_pipe");
5dd620fa
MD
32 if (splice_to_pipe_sym) {
33 return splice_to_pipe_sym(pipe, spd);
34 } else {
e36de50d 35 printk_once(KERN_WARNING "LTTng: splice_to_pipe symbol lookup failed.\n");
5dd620fa
MD
36 return -ENOSYS;
37 }
38}
39
3dfec228
MJ
40/*
41 * Canary function to check for 'splice_to_pipe()' at compile time.
42 *
43 * From 'include/linux/splice.h':
44 *
45 * extern ssize_t splice_to_pipe(struct pipe_inode_info *,
46 * struct splice_pipe_desc *spd);
47 */
48__attribute__((unused)) static
49ssize_t __canary__splice_to_pipe(struct pipe_inode_info *pipe,
50 struct splice_pipe_desc *spd)
51{
52 return splice_to_pipe(pipe, spd);
53}
54
5dd620fa
MD
55#else
56
5dd620fa
MD
57ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
58 struct splice_pipe_desc *spd)
59{
60 return splice_to_pipe(pipe, spd);
61}
62
63#endif
This page took 0.060923 seconds and 4 git commands to generate.