man-pages/man2/vmsplice.2.html
2021-03-31 01:06:50 +01:00

284 lines
5.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of VMSPLICE</TITLE>
</HEAD><BODY>
<H1>VMSPLICE</H1>
Section: Linux Programmer's Manual (2)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
vmsplice - splice user pages to/from a pipe
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#define _GNU_SOURCE</B> /* See <A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A>(7) */
<B>#include &lt;<A HREF="file:///usr/include/fcntl.h">fcntl.h</A>&gt;</B>
<B>#include &lt;<A HREF="file:///usr/include/sys/uio.h">sys/uio.h</A>&gt;</B>
<B>ssize_t vmsplice(int </B><I>fd</I><B>, const struct iovec *</B><I>iov</I><B>,</B>
<B> unsigned long </B><I>nr_segs</I><B>, unsigned int </B><I>flags</I><B>);</B>
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
If
<I>fd</I>
is opened for writing, the
<B>vmsplice</B>()
system call maps
<I>nr_segs</I>
ranges of user memory described by
<I>iov</I>
into a pipe.
If
<I>fd</I>
is opened for reading,
the
<B>vmsplice</B>()
system call fills
<I>nr_segs</I>
ranges of user memory described by
<I>iov</I>
from a pipe.
The file descriptor
<I>fd</I>
must refer to a pipe.
<P>
The pointer
<I>iov</I>
points to an array of
<I>iovec</I>
structures as defined in
<I>&lt;<A HREF="file:///usr/include/sys/uio.h">sys/uio.h</A>&gt;</I>:
<P>
struct iovec {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;&nbsp;*iov_base;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Starting&nbsp;address&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;size_t&nbsp;iov_len;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Number&nbsp;of&nbsp;bytes&nbsp;*/
};
<P>
The
<I>flags</I>
argument is a bit mask that is composed by ORing together
zero or more of the following values:
<DL COMPACT>
<DT id="1"><B>SPLICE_F_MOVE</B>
<DD>
Unused for
<B>vmsplice</B>();
see
<B><A HREF="/cgi-bin/man/man2html?2+splice">splice</A></B>(2).
<DT id="2"><B>SPLICE_F_NONBLOCK</B>
<DD>
Do not block on I/O; see
<B><A HREF="/cgi-bin/man/man2html?2+splice">splice</A></B>(2)
for further details.
<DT id="3"><B>SPLICE_F_MORE</B>
<DD>
Currently has no effect for
<B>vmsplice</B>(),
but may be implemented in the future; see
<B><A HREF="/cgi-bin/man/man2html?2+splice">splice</A></B>(2).
<DT id="4"><B>SPLICE_F_GIFT</B>
<DD>
The user pages are a gift to the kernel.
The application may not modify this memory ever,
otherwise the page cache and on-disk data may differ.
Gifting pages to the kernel means that a subsequent
<B><A HREF="/cgi-bin/man/man2html?2+splice">splice</A></B>(2)
<B>SPLICE_F_MOVE</B>
can successfully move the pages;
if this flag is not specified, then a subsequent
<B><A HREF="/cgi-bin/man/man2html?2+splice">splice</A></B>(2)
<B>SPLICE_F_MOVE</B>
must copy the pages.
Data must also be properly page aligned, both in memory and length.
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
Upon successful completion,
<B>vmsplice</B>()
returns the number of bytes transferred to the pipe.
On error,
<B>vmsplice</B>()
returns -1 and
<I>errno</I>
is set to indicate the error.
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
<DL COMPACT>
<DT id="5"><B>EAGAIN</B>
<DD>
<B>SPLICE_F_NONBLOCK</B>
was specified in
<I>flags</I>,
and the operation would block.
<DT id="6"><B>EBADF</B>
<DD>
<I>fd</I>
either not valid, or doesn't refer to a pipe.
<DT id="7"><B>EINVAL</B>
<DD>
<I>nr_segs</I>
is greater than
<B>IOV_MAX</B>;
or memory not aligned if
<B>SPLICE_F_GIFT</B>
set.
<DT id="8"><B>ENOMEM</B>
<DD>
Out of memory.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>VERSIONS</H2>
The
<B>vmsplice</B>()
system call first appeared in Linux 2.6.17;
library support was added to glibc in version 2.5.
<A NAME="lbAH">&nbsp;</A>
<H2>CONFORMING TO</H2>
This system call is Linux-specific.
<A NAME="lbAI">&nbsp;</A>
<H2>NOTES</H2>
<B>vmsplice</B>()
follows the other vectorized read/write type functions when it comes to
limitations on the number of segments being passed in.
This limit is
<B>IOV_MAX</B>
as defined in
<I>&lt;<A HREF="file:///usr/include/limits.h">limits.h</A>&gt;</I>.
Currently,
this limit is 1024.
<P>
<B>vmsplice</B>()
really supports true splicing only from user memory to a pipe.
In the opposite direction, it actually just copies the data to userspace.
But this makes the interface nice and symmetric and enables people to build on
<B>vmsplice</B>()
with room for future improvement in performance.
<A NAME="lbAJ">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+splice">splice</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+tee">tee</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?7+pipe">pipe</A></B>(7)
<A NAME="lbAK">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="9"><A HREF="#lbAB">NAME</A><DD>
<DT id="10"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="11"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="12"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="13"><A HREF="#lbAF">ERRORS</A><DD>
<DT id="14"><A HREF="#lbAG">VERSIONS</A><DD>
<DT id="15"><A HREF="#lbAH">CONFORMING TO</A><DD>
<DT id="16"><A HREF="#lbAI">NOTES</A><DD>
<DT id="17"><A HREF="#lbAJ">SEE ALSO</A><DD>
<DT id="18"><A HREF="#lbAK">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:35 GMT, March 31, 2021
</BODY>
</HTML>