]>
Commit | Line | Data |
---|---|---|
2bc4bb77 | 1 | .\" This manpage is Copyright (C) 2006 Jens Axboe |
c11b1abf | 2 | .\" and Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com> |
2bc4bb77 | 3 | .\" |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
2bc4bb77 MK |
5 | .\" Permission is granted to make and distribute verbatim copies of this |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
c13182ef | 13 | .\" |
2bc4bb77 MK |
14 | .\" Since the Linux kernel and libraries are constantly changing, this |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
c13182ef | 21 | .\" |
2bc4bb77 MK |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
2bc4bb77 | 25 | .\" |
9ba01802 | 26 | .TH VMSPLICE 2 2019-03-06 "Linux" "Linux Programmer's Manual" |
2bc4bb77 | 27 | .SH NAME |
dc7b1aab | 28 | vmsplice \- splice user pages to/from a pipe |
2bc4bb77 MK |
29 | .SH SYNOPSIS |
30 | .nf | |
b80f966b | 31 | .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" |
2bc4bb77 MK |
32 | .B #include <fcntl.h> |
33 | .B #include <sys/uio.h> | |
dbfe9c70 | 34 | .PP |
52520fb5 MH |
35 | .BI "ssize_t vmsplice(int " fd ", const struct iovec *" iov , |
36 | .BI " unsigned long " nr_segs ", unsigned int " flags ); | |
2bc4bb77 | 37 | .fi |
52520fb5 | 38 | .\" Return type was long before glibc 2.7 |
2bc4bb77 | 39 | .SH DESCRIPTION |
c13182ef MK |
40 | .\" Linus: vmsplice() system call to basically do a "write to |
41 | .\" the buffer", but using the reference counting and VM traversal | |
42 | .\" to actually fill the buffer. This means that the user needs to | |
3b777aff | 43 | .\" be careful not to reuse the user-space buffer it spliced into |
c13182ef | 44 | .\" the kernel-space one (contrast this to "write()", which copies |
3b777aff | 45 | .\" the actual data, and you can thus reuse the buffer immediately |
c13182ef | 46 | .\" after a successful write), but that is often easy to do. |
dc7b1aab AV |
47 | If |
48 | .I fd | |
b94a87a5 | 49 | is opened for writing, the |
2bc4bb77 MK |
50 | .BR vmsplice () |
51 | system call maps | |
52 | .I nr_segs | |
53 | ranges of user memory described by | |
54 | .I iov | |
c13182ef | 55 | into a pipe. |
dc7b1aab AV |
56 | If |
57 | .I fd | |
58 | is opened for reading, | |
59 | .\" Since Linux 2.6.23 | |
60 | .\" commit 6a14b90bb6bc7cd83e2a444bf457a2ea645cbfe7 | |
61 | the | |
62 | .BR vmsplice () | |
63 | system call fills | |
64 | .I nr_segs | |
65 | ranges of user memory described by | |
66 | .I iov | |
67 | from a pipe. | |
2bc4bb77 | 68 | The file descriptor |
c13182ef | 69 | .I fd |
2bc4bb77 | 70 | must refer to a pipe. |
efeece04 | 71 | .PP |
2bc4bb77 MK |
72 | The pointer |
73 | .I iov | |
74 | points to an array of | |
75 | .I iovec | |
76 | structures as defined in | |
77 | .IR <sys/uio.h> : | |
efeece04 | 78 | .PP |
a08ea57c | 79 | .in +4n |
b8302363 | 80 | .EX |
2bc4bb77 | 81 | struct iovec { |
8031e529 MK |
82 | void *iov_base; /* Starting address */ |
83 | size_t iov_len; /* Number of bytes */ | |
2bc4bb77 | 84 | }; |
b8302363 | 85 | .EE |
e646a1ba | 86 | .in |
efeece04 | 87 | .PP |
2bc4bb77 MK |
88 | The |
89 | .I flags | |
90 | argument is a bit mask that is composed by ORing together | |
91 | zero or more of the following values: | |
c6228d17 | 92 | .TP |
2bc4bb77 MK |
93 | .B SPLICE_F_MOVE |
94 | Unused for | |
95 | .BR vmsplice (); | |
96 | see | |
97 | .BR splice (2). | |
98 | .TP | |
99 | .B SPLICE_F_NONBLOCK | |
100 | .\" Not used for vmsplice | |
101 | .\" May be in the future -- therefore EAGAIN | |
c13182ef MK |
102 | Do not block on I/O; see |
103 | .BR splice (2) | |
2bc4bb77 MK |
104 | for further details. |
105 | .TP | |
106 | .B SPLICE_F_MORE | |
c13182ef | 107 | Currently has no effect for |
2bc4bb77 MK |
108 | .BR vmsplice (), |
109 | but may be implemented in the future; see | |
110 | .BR splice (2). | |
111 | .TP | |
112 | .B SPLICE_F_GIFT | |
c13182ef MK |
113 | The user pages are a gift to the kernel. |
114 | The application may not modify this memory ever, | |
bea08fec | 115 | .\" FIXME . Explain the following line in a little more detail: |
8031e529 | 116 | otherwise the page cache and on-disk data may differ. |
2bc4bb77 | 117 | Gifting pages to the kernel means that a subsequent |
0bfa087b | 118 | .BR splice (2) |
2bc4bb77 MK |
119 | .B SPLICE_F_MOVE |
120 | can successfully move the pages; | |
121 | if this flag is not specified, then a subsequent | |
0bfa087b | 122 | .BR splice (2) |
2bc4bb77 MK |
123 | .B SPLICE_F_MOVE |
124 | must copy the pages. | |
125 | Data must also be properly page aligned, both in memory and length. | |
ced56703 | 126 | .\" FIXME |
68c11e15 MK |
127 | .\" It looks like the page-alignment requirement went away with |
128 | .\" commit bd1a68b59c8e3bce45fb76632c64e1e063c3962d | |
ced56703 | 129 | .\" |
2bc4bb77 MK |
130 | .\" .... if we expect to later SPLICE_F_MOVE to the cache. |
131 | .SH RETURN VALUE | |
132 | Upon successful completion, | |
133 | .BR vmsplice () | |
c13182ef MK |
134 | returns the number of bytes transferred to the pipe. |
135 | On error, | |
d504a994 | 136 | .BR vmsplice () |
2bc4bb77 MK |
137 | returns \-1 and |
138 | .I errno | |
139 | is set to indicate the error. | |
140 | .SH ERRORS | |
141 | .TP | |
56cb0650 MK |
142 | .B EAGAIN |
143 | .B SPLICE_F_NONBLOCK | |
144 | was specified in | |
145 | .IR flags , | |
146 | and the operation would block. | |
147 | .TP | |
2bc4bb77 MK |
148 | .B EBADF |
149 | .I fd | |
150 | either not valid, or doesn't refer to a pipe. | |
151 | .TP | |
152 | .B EINVAL | |
153 | .I nr_segs | |
a2cf8898 | 154 | is greater than |
4df883b9 | 155 | .BR IOV_MAX ; |
2bc4bb77 MK |
156 | or memory not aligned if |
157 | .B SPLICE_F_GIFT | |
158 | set. | |
159 | .TP | |
160 | .B ENOMEM | |
161 | Out of memory. | |
2dd578fd MK |
162 | .SH VERSIONS |
163 | The | |
2777b1ca | 164 | .BR vmsplice () |
c95b6ae1 MK |
165 | system call first appeared in Linux 2.6.17; |
166 | library support was added to glibc in version 2.5. | |
47297adb | 167 | .SH CONFORMING TO |
8382f16d | 168 | This system call is Linux-specific. |
2bc4bb77 MK |
169 | .SH NOTES |
170 | .BR vmsplice () | |
171 | follows the other vectorized read/write type functions when it comes to | |
8031e529 | 172 | limitations on the number of segments being passed in. |
2bc4bb77 MK |
173 | This limit is |
174 | .B IOV_MAX | |
175 | as defined in | |
176 | .IR <limits.h> . | |
8031e529 MK |
177 | Currently, |
178 | .\" UIO_MAXIOV in kernel source | |
179 | this limit is 1024. | |
dc7b1aab AV |
180 | .PP |
181 | .\" commit 6a14b90bb6bc7cd83e2a444bf457a2ea645cbfe7 | |
182 | .BR vmsplice () | |
b94a87a5 MK |
183 | really supports true splicing only from user memory to a pipe. |
184 | In the opposite direction, it actually just copies the data to userspace. | |
185 | But this makes the interface nice and symmetric and enables people to build on | |
186 | .BR vmsplice () | |
dc7b1aab | 187 | with room for future improvement in performance. |
2bc4bb77 MK |
188 | .SH SEE ALSO |
189 | .BR splice (2), | |
6c97eb40 MK |
190 | .BR tee (2), |
191 | .BR pipe (7) |