Remove dependency on kallsyms for splice_to_pipe (kernel 4.2+)
[lttng-modules.git] / wrapper / splice.c
1 /*
2 * wrapper/splice.c
3 *
4 * wrapper around splice_to_pipe. Using KALLSYMS to get its address when
5 * available, else we need to have a kernel that exports this function to GPL
6 * modules. The export was introduced in kernel 4.2.
7 *
8 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; only
13 * version 2.1 of the License.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #include <lttng-kernel-version.h>
26
27 #if (defined(CONFIG_KALLSYMS) \
28 && (LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)))
29
30 #include <linux/kallsyms.h>
31 #include <linux/fs.h>
32 #include <linux/splice.h>
33 #include <wrapper/kallsyms.h>
34
35 static
36 ssize_t (*splice_to_pipe_sym)(struct pipe_inode_info *pipe,
37 struct splice_pipe_desc *spd);
38
39 ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
40 struct splice_pipe_desc *spd)
41 {
42 if (!splice_to_pipe_sym)
43 splice_to_pipe_sym = (void *) kallsyms_lookup_funcptr("splice_to_pipe");
44 if (splice_to_pipe_sym) {
45 return splice_to_pipe_sym(pipe, spd);
46 } else {
47 printk_once(KERN_WARNING "LTTng: splice_to_pipe symbol lookup failed.\n");
48 return -ENOSYS;
49 }
50 }
51
52 #else
53
54 #include <linux/fs.h>
55 #include <linux/splice.h>
56
57 ssize_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.050928 seconds and 4 git commands to generate.