]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/vmsplice.2
posix_fadvise.2: tfix
[thirdparty/man-pages.git] / man2 / vmsplice.2
CommitLineData
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 28vmsplice \- 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
47If
48.I fd
b94a87a5 49is opened for writing, the
2bc4bb77
MK
50.BR vmsplice ()
51system call maps
52.I nr_segs
53ranges of user memory described by
54.I iov
c13182ef 55into a pipe.
dc7b1aab
AV
56If
57.I fd
58is opened for reading,
59.\" Since Linux 2.6.23
60.\" commit 6a14b90bb6bc7cd83e2a444bf457a2ea645cbfe7
61the
62.BR vmsplice ()
63system call fills
64.I nr_segs
65ranges of user memory described by
66.I iov
67from a pipe.
2bc4bb77 68The file descriptor
c13182ef 69.I fd
2bc4bb77 70must refer to a pipe.
efeece04 71.PP
2bc4bb77
MK
72The pointer
73.I iov
74points to an array of
75.I iovec
76structures as defined in
77.IR <sys/uio.h> :
efeece04 78.PP
a08ea57c 79.in +4n
b8302363 80.EX
2bc4bb77 81struct 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
88The
89.I flags
90argument is a bit mask that is composed by ORing together
91zero or more of the following values:
c6228d17 92.TP
2bc4bb77
MK
93.B SPLICE_F_MOVE
94Unused for
95.BR vmsplice ();
96see
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
102Do not block on I/O; see
103.BR splice (2)
2bc4bb77
MK
104for further details.
105.TP
106.B SPLICE_F_MORE
c13182ef 107Currently has no effect for
2bc4bb77
MK
108.BR vmsplice (),
109but may be implemented in the future; see
110.BR splice (2).
111.TP
112.B SPLICE_F_GIFT
c13182ef
MK
113The user pages are a gift to the kernel.
114The application may not modify this memory ever,
bea08fec 115.\" FIXME . Explain the following line in a little more detail:
8031e529 116otherwise the page cache and on-disk data may differ.
2bc4bb77 117Gifting pages to the kernel means that a subsequent
0bfa087b 118.BR splice (2)
2bc4bb77
MK
119.B SPLICE_F_MOVE
120can successfully move the pages;
121if this flag is not specified, then a subsequent
0bfa087b 122.BR splice (2)
2bc4bb77
MK
123.B SPLICE_F_MOVE
124must copy the pages.
125Data 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
132Upon successful completion,
133.BR vmsplice ()
c13182ef
MK
134returns the number of bytes transferred to the pipe.
135On error,
d504a994 136.BR vmsplice ()
2bc4bb77
MK
137returns \-1 and
138.I errno
139is set to indicate the error.
140.SH ERRORS
141.TP
56cb0650
MK
142.B EAGAIN
143.B SPLICE_F_NONBLOCK
144was specified in
145.IR flags ,
146and the operation would block.
147.TP
2bc4bb77
MK
148.B EBADF
149.I fd
150either not valid, or doesn't refer to a pipe.
151.TP
152.B EINVAL
153.I nr_segs
a2cf8898 154is greater than
4df883b9 155.BR IOV_MAX ;
2bc4bb77
MK
156or memory not aligned if
157.B SPLICE_F_GIFT
158set.
159.TP
160.B ENOMEM
161Out of memory.
2dd578fd
MK
162.SH VERSIONS
163The
2777b1ca 164.BR vmsplice ()
c95b6ae1
MK
165system call first appeared in Linux 2.6.17;
166library support was added to glibc in version 2.5.
47297adb 167.SH CONFORMING TO
8382f16d 168This system call is Linux-specific.
2bc4bb77
MK
169.SH NOTES
170.BR vmsplice ()
171follows the other vectorized read/write type functions when it comes to
8031e529 172limitations on the number of segments being passed in.
2bc4bb77
MK
173This limit is
174.B IOV_MAX
175as defined in
176.IR <limits.h> .
8031e529
MK
177Currently,
178.\" UIO_MAXIOV in kernel source
179this limit is 1024.
dc7b1aab
AV
180.PP
181.\" commit 6a14b90bb6bc7cd83e2a444bf457a2ea645cbfe7
182.BR vmsplice ()
b94a87a5
MK
183really supports true splicing only from user memory to a pipe.
184In the opposite direction, it actually just copies the data to userspace.
185But this makes the interface nice and symmetric and enables people to build on
186.BR vmsplice ()
dc7b1aab 187with 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)