]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/vmsplice.2
Changes, ldd.1, chown.2, epoll_wait.2, get_mempolicy.2, ioctl_getfsmap.2, madvise...
[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.\"
f55a6d59 26.TH VMSPLICE 2 2017-07-13 "Linux" "Linux Programmer's Manual"
2bc4bb77
MK
27.SH NAME
28vmsplice \- splice user pages into a pipe
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>
34
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.
2bc4bb77
MK
47The
48.BR vmsplice ()
49system call maps
50.I nr_segs
51ranges of user memory described by
52.I iov
c13182ef 53into a pipe.
2bc4bb77 54The file descriptor
c13182ef 55.I fd
2bc4bb77
MK
56must refer to a pipe.
57
58The pointer
59.I iov
60points to an array of
61.I iovec
62structures as defined in
63.IR <sys/uio.h> :
64
a08ea57c 65.in +4n
2bc4bb77
MK
66.nf
67struct iovec {
8031e529
MK
68 void *iov_base; /* Starting address */
69 size_t iov_len; /* Number of bytes */
2bc4bb77 70};
a08ea57c 71.in
2bc4bb77
MK
72.fi
73
74The
75.I flags
76argument is a bit mask that is composed by ORing together
77zero or more of the following values:
68c11e15 78.RS
2bc4bb77
MK
79.TP 1.9i
80.B SPLICE_F_MOVE
81Unused for
82.BR vmsplice ();
83see
84.BR splice (2).
85.TP
86.B SPLICE_F_NONBLOCK
87.\" Not used for vmsplice
88.\" May be in the future -- therefore EAGAIN
c13182ef
MK
89Do not block on I/O; see
90.BR splice (2)
2bc4bb77
MK
91for further details.
92.TP
93.B SPLICE_F_MORE
c13182ef 94Currently has no effect for
2bc4bb77
MK
95.BR vmsplice (),
96but may be implemented in the future; see
97.BR splice (2).
98.TP
99.B SPLICE_F_GIFT
c13182ef
MK
100The user pages are a gift to the kernel.
101The application may not modify this memory ever,
bea08fec 102.\" FIXME . Explain the following line in a little more detail:
8031e529 103otherwise the page cache and on-disk data may differ.
2bc4bb77 104Gifting pages to the kernel means that a subsequent
0bfa087b 105.BR splice (2)
2bc4bb77
MK
106.B SPLICE_F_MOVE
107can successfully move the pages;
108if this flag is not specified, then a subsequent
0bfa087b 109.BR splice (2)
2bc4bb77
MK
110.B SPLICE_F_MOVE
111must copy the pages.
112Data must also be properly page aligned, both in memory and length.
68c11e15 113.RE
ced56703 114.\" FIXME
68c11e15
MK
115.\" It looks like the page-alignment requirement went away with
116.\" commit bd1a68b59c8e3bce45fb76632c64e1e063c3962d
ced56703 117.\"
2bc4bb77
MK
118.\" .... if we expect to later SPLICE_F_MOVE to the cache.
119.SH RETURN VALUE
120Upon successful completion,
121.BR vmsplice ()
c13182ef
MK
122returns the number of bytes transferred to the pipe.
123On error,
d504a994 124.BR vmsplice ()
2bc4bb77
MK
125returns \-1 and
126.I errno
127is set to indicate the error.
128.SH ERRORS
129.TP
56cb0650
MK
130.B EAGAIN
131.B SPLICE_F_NONBLOCK
132was specified in
133.IR flags ,
134and the operation would block.
135.TP
2bc4bb77
MK
136.B EBADF
137.I fd
138either not valid, or doesn't refer to a pipe.
139.TP
140.B EINVAL
141.I nr_segs
a2cf8898 142is greater than
4df883b9 143.BR IOV_MAX ;
2bc4bb77
MK
144or memory not aligned if
145.B SPLICE_F_GIFT
146set.
147.TP
148.B ENOMEM
149Out of memory.
2dd578fd
MK
150.SH VERSIONS
151The
2777b1ca 152.BR vmsplice ()
c95b6ae1
MK
153system call first appeared in Linux 2.6.17;
154library support was added to glibc in version 2.5.
47297adb 155.SH CONFORMING TO
8382f16d 156This system call is Linux-specific.
2bc4bb77
MK
157.SH NOTES
158.BR vmsplice ()
159follows the other vectorized read/write type functions when it comes to
8031e529 160limitations on the number of segments being passed in.
2bc4bb77
MK
161This limit is
162.B IOV_MAX
163as defined in
164.IR <limits.h> .
8031e529
MK
165Currently,
166.\" UIO_MAXIOV in kernel source
167this limit is 1024.
2bc4bb77
MK
168.SH SEE ALSO
169.BR splice (2),
6c97eb40
MK
170.BR tee (2),
171.BR pipe (7)