1VMSPLICE(2) Linux Programmer's Manual VMSPLICE(2)
2
3
4
6 vmsplice - splice user pages to/from a pipe
7
9 #define _GNU_SOURCE /* See feature_test_macros(7) */
10 #include <fcntl.h>
11 #include <sys/uio.h>
12
13 ssize_t vmsplice(int fd, const struct iovec *iov,
14 unsigned long nr_segs, unsigned int flags);
15
17 If fd is opened for writing, the vmsplice() system call maps nr_segs
18 ranges of user memory described by iov into a pipe. If fd is opened
19 for reading, the vmsplice() system call fills nr_segs ranges of user
20 memory described by iov from a pipe. The file descriptor fd must refer
21 to a pipe.
22
23 The pointer iov points to an array of iovec structures as defined in
24 <sys/uio.h>:
25
26 struct iovec {
27 void *iov_base; /* Starting address */
28 size_t iov_len; /* Number of bytes */
29 };
30
31 The flags argument is a bit mask that is composed by ORing together
32 zero or more of the following values:
33
34 SPLICE_F_MOVE
35 Unused for vmsplice(); see splice(2).
36
37 SPLICE_F_NONBLOCK
38 Do not block on I/O; see splice(2) for further details.
39
40 SPLICE_F_MORE
41 Currently has no effect for vmsplice(), but may be implemented
42 in the future; see splice(2).
43
44 SPLICE_F_GIFT
45 The user pages are a gift to the kernel. The application may
46 not modify this memory ever, otherwise the page cache and on-
47 disk data may differ. Gifting pages to the kernel means that a
48 subsequent splice(2) SPLICE_F_MOVE can successfully move the
49 pages; if this flag is not specified, then a subsequent
50 splice(2) SPLICE_F_MOVE must copy the pages. Data must also be
51 properly page aligned, both in memory and length.
52
54 Upon successful completion, vmsplice() returns the number of bytes
55 transferred to the pipe. On error, vmsplice() returns -1 and errno is
56 set to indicate the error.
57
59 EAGAIN SPLICE_F_NONBLOCK was specified in flags, and the operation
60 would block.
61
62 EBADF fd either not valid, or doesn't refer to a pipe.
63
64 EINVAL nr_segs is greater than IOV_MAX; or memory not aligned if
65 SPLICE_F_GIFT set.
66
67 ENOMEM Out of memory.
68
70 The vmsplice() system call first appeared in Linux 2.6.17; library sup‐
71 port was added to glibc in version 2.5.
72
74 This system call is Linux-specific.
75
77 vmsplice() follows the other vectorized read/write type functions when
78 it comes to limitations on the number of segments being passed in.
79 This limit is IOV_MAX as defined in <limits.h>. Currently, this limit
80 is 1024.
81
82 vmsplice() really supports true splicing only from user memory to a
83 pipe. In the opposite direction, it actually just copies the data to
84 userspace. But this makes the interface nice and symmetric and enables
85 people to build on vmsplice() with room for future improvement in per‐
86 formance.
87
89 splice(2), tee(2), pipe(7)
90
92 This page is part of release 5.07 of the Linux man-pages project. A
93 description of the project, information about reporting bugs, and the
94 latest version of this page, can be found at
95 https://www.kernel.org/doc/man-pages/.
96
97
98
99Linux 2019-03-06 VMSPLICE(2)