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