XenevaOS
Loading...
Searching...
No Matches
splice.h
Go to the documentation of this file.
1#ifndef __LINUX_SPLICE_H__
2#define __LINUX_SPLICE_H__
3
4/*
5 * DCL <linux/splice.h> -- enough of the splice graph for mem.c's
6 * null/zero/full fops (.splice_write -> splice_from_pipe, .splice_read ->
7 * copy_splice_read). Xeneva's devfs bridge does not route splice yet, so
8 * these are ABI-shaped definitions that keep the fops initializers legal;
9 * the declarations live here so the vendored source compiles unchanged.
10 */
11
12#include <stddef.h>
13#include <linux/kernel.h> /* loff_t, ssize_t, gfp_t -- splice_from_pipe()'s
14 * own parameter types. They used to come in
15 * sideways through whatever the includer had
16 * pulled first (the driver reaches splice.h from
17 * cdev.h -> kobject.h -> kernel.h), which is not
18 * an include order a header may rely on: this
19 * file now compiles on its own as
20 * DCL/linux_splice_shim.c proved by failing to. */
21#include <linux/fs.h> /* struct pipe_inode_info (fwd), struct file */
22
24 void* page;
25 unsigned int offset, len;
26 const void* ops;
27 unsigned int flags;
28 unsigned long private;
29};
30
32 size_t len; /* mem.c's pipe_to_null returns sd->len */
33 unsigned int total_len;
34 unsigned int flags;
35 unsigned int pos;
36 struct pipe_inode_info* pipe;
37 /*
38 * mainline names this `union { void *data; void (*cleanup)(...); } u;`
39 * and the ported splice actor reads it as sd->u.data -- virtio_console.c:912
40 * initialises `.u.data = &sgl` and pipe_to_sg() at :861 casts it back.
41 * The union has only the one arm DCL can name: nothing here has a
42 * cleanup callback to hang off the other, and a member that no source
43 * can reach is not worth carrying.
44 *
45 * Nothing in this tree reads the old flat `sd->data` spelling (checked
46 * across Vendored/ and DCL/ before the rename), so this is a rename and
47 * not a widening.
48 */
49 union {
50 void* data;
51 } u;
52 struct file* file;
53};
54
55/*
56 * The pipe side of splice. mainline has these as static inlines over
57 * pipe->head/pipe->tail (linux/pipe_fs_i.h); DCL's struct pipe_inode_info is
58 * a forward declaration only -- see the include at the top -- so they are
59 * calls, bodies in DCL/linux_splice_shim.c.
60 *
61 * All four are unreachable today: Xeneva's devfs bridge does not route
62 * splice, so no port's .splice_write is ever entered (the header's own note
63 * above). They exist so the vendored source compiles, and their bodies say
64 * the same thing the rest of the splice layer says -- a list that is empty,
65 * a lock nobody holds, a buffer nobody took.
66 */
67void pipe_lock(struct pipe_inode_info* pipe);
68void pipe_unlock(struct pipe_inode_info* pipe);
69unsigned int pipe_is_empty(struct pipe_inode_info* pipe);
70unsigned int pipe_buf_usage(struct pipe_inode_info* pipe);
71
72/*
73 * pipe_buf_try_steal() -- take ownership of a buffer's page so the caller can
74 * move it without copying. DCL's returns false always, which sends the one
75 * caller (virtio_console.c:866) down its copy arm: alloc_page(), memcpy,
76 * sg_set_page(). Returning true instead would claim ownership of a page the
77 * pipe still points at, and there is no pipe here with a page to lose -- but
78 * false is the answer that is true even if splice is wired up one day.
79 */
80bool pipe_buf_try_steal(struct pipe_inode_info* pipe,
81 struct pipe_buffer* buf);
82
83/*
84 * splice_pipe_actor -- the callback __splice_from_pipe() drives, one buffer
85 * at a time. Declared before its first use: __splice_from_pipe() below takes
86 * one as a parameter, and a parameter of undeclared function-pointer type
87 * would be a different type from the typedef that follows it.
88 */
89typedef int (*splice_pipe_actor)(struct pipe_inode_info* pipe,
90 struct pipe_buffer* buf,
91 struct splice_desc* sd);
92
93/*
94 * __splice_from_pipe() -- push each buffered page through `actor`.
95 *
96 * mainline's returns the actor's accumulated byte count and is the engine
97 * behind splice_from_pipe(), which this header declares just after. The DCL
98 * body is the loop's *shape* without a loop behind it, for the same reason
99 * every other entry point here is stubbed: no pipe ever has content to
100 * iterate, because devfs does not route splice.
101 */
102long __splice_from_pipe(struct pipe_inode_info* pipe,
103 struct splice_desc* sd, splice_pipe_actor actor);
104
105ssize_t splice_from_pipe(struct pipe_inode_info* pipe, struct file* out,
106 loff_t* ppos, size_t len, unsigned int flags,
107 splice_pipe_actor actor);
108
110 struct pipe_inode_info* pipe, size_t len,
111 unsigned int flags);
112
113#endif /* __LINUX_SPLICE_H__ */
int64_t ssize_t
Definition stddef.h:38
uint8_t flags
Definition virtio.h:0
#define out(...)
Definition main.cpp:65
size_t len
Definition initial.c:23
uint64_t loff_t
Definition kernel.h:49
ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out, loff_t *ppos, size_t len, unsigned int flags, splice_pipe_actor actor)
bool pipe_buf_try_steal(struct pipe_inode_info *pipe, struct pipe_buffer *buf)
long __splice_from_pipe(struct pipe_inode_info *pipe, struct splice_desc *sd, splice_pipe_actor actor)
void pipe_unlock(struct pipe_inode_info *pipe)
int(* splice_pipe_actor)(struct pipe_inode_info *pipe, struct pipe_buffer *buf, struct splice_desc *sd)
Definition splice.h:89
ssize_t copy_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags)
unsigned int pipe_is_empty(struct pipe_inode_info *pipe)
void pipe_lock(struct pipe_inode_info *pipe)
unsigned int pipe_buf_usage(struct pipe_inode_info *pipe)
Definition fs.h:142
Definition splice.h:23
unsigned int len
Definition splice.h:25
unsigned int offset
Definition splice.h:25
const void * ops
Definition splice.h:26
unsigned int flags
Definition splice.h:27
void * page
Definition splice.h:24
Definition splice.h:31
size_t len
Definition splice.h:32
unsigned int pos
Definition splice.h:35
union splice_desc::@92 u
struct file * file
Definition splice.h:52
void * data
Definition splice.h:50
struct pipe_inode_info * pipe
Definition splice.h:36
unsigned int flags
Definition splice.h:34
unsigned int total_len
Definition splice.h:33