fix: kallsyms wrapper on ppc64el
[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>
d072dbc6 13
0e5e973d 14#ifdef CONFIG_KALLSYMS
5dd620fa
MD
15
16#include <linux/kallsyms.h>
17#include <linux/fs.h>
18#include <linux/splice.h>
5a2f5e92 19#include <wrapper/kallsyms.h>
5dd620fa
MD
20
21static
22ssize_t (*splice_to_pipe_sym)(struct pipe_inode_info *pipe,
23 struct splice_pipe_desc *spd);
24
25ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
26 struct splice_pipe_desc *spd)
27{
28 if (!splice_to_pipe_sym)
1e543e7c 29 splice_to_pipe_sym = (void *) kallsyms_lookup_funcptr("splice_to_pipe");
5dd620fa
MD
30 if (splice_to_pipe_sym) {
31 return splice_to_pipe_sym(pipe, spd);
32 } else {
e36de50d 33 printk_once(KERN_WARNING "LTTng: splice_to_pipe symbol lookup failed.\n");
5dd620fa
MD
34 return -ENOSYS;
35 }
36}
37
3dfec228
MJ
38/*
39 * Canary function to check for 'splice_to_pipe()' at compile time.
40 *
41 * From 'include/linux/splice.h':
42 *
43 * extern ssize_t splice_to_pipe(struct pipe_inode_info *,
44 * struct splice_pipe_desc *spd);
45 */
46__attribute__((unused)) static
47ssize_t __canary__splice_to_pipe(struct pipe_inode_info *pipe,
48 struct splice_pipe_desc *spd)
49{
50 return splice_to_pipe(pipe, spd);
51}
52
5dd620fa
MD
53#else
54
55#include <linux/fs.h>
56#include <linux/splice.h>
57
58ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
59 struct splice_pipe_desc *spd)
60{
61 return splice_to_pipe(pipe, spd);
62}
63
64#endif
This page took 0.064819 seconds and 4 git commands to generate.