OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man2 / vmsplice.2
1 .\" This manpage is Copyright (C) 2006 Jens Axboe
2 .\" and Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
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.
13 .\"
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.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH VMSPLICE 2 2012-05-04 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 vmsplice \- splice user pages into a pipe
29 .SH SYNOPSIS
30 .nf
31 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
32 .B #include <fcntl.h>
33 .B #include <sys/uio.h>
34
35 .BI "ssize_t vmsplice(int " fd ", const struct iovec *" iov ,
36 .BI "                 unsigned long " nr_segs ", unsigned int " flags );
37 .fi
38 .\" Return type was long before glibc 2.7
39 .SH DESCRIPTION
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
43 .\" be careful not to reuse the user-space buffer it spliced into
44 .\" the kernel-space one (contrast this to "write()", which copies
45 .\" the actual data, and you can thus reuse the buffer immediately
46 .\" after a successful write), but that is often easy to do.
47 The
48 .BR vmsplice ()
49 system call maps
50 .I nr_segs
51 ranges of user memory described by
52 .I iov
53 into a pipe.
54 The file descriptor
55 .I fd
56 must refer to a pipe.
57
58 The pointer
59 .I iov
60 points to an array of
61 .I iovec
62 structures as defined in
63 .IR <sys/uio.h> :
64
65 .in +4n
66 .nf
67 struct iovec {
68     void  *iov_base;            /* Starting address */
69     size_t iov_len;             /* Number of bytes */
70 };
71 .in
72 .fi
73
74 The
75 .I flags
76 argument is a bit mask that is composed by ORing together
77 zero or more of the following values:
78 .TP 1.9i
79 .B SPLICE_F_MOVE
80 Unused for
81 .BR vmsplice ();
82 see
83 .BR splice (2).
84 .TP
85 .B SPLICE_F_NONBLOCK
86 .\" Not used for vmsplice
87 .\" May be in the future -- therefore EAGAIN
88 Do not block on I/O; see
89 .BR splice (2)
90 for further details.
91 .TP
92 .B SPLICE_F_MORE
93 Currently has no effect for
94 .BR vmsplice (),
95 but may be implemented in the future; see
96 .BR splice (2).
97 .TP
98 .B SPLICE_F_GIFT
99 The user pages are a gift to the kernel.
100 The application may not modify this memory ever,
101 .\" FIXME Explain the following line in a little more detail:
102 or page cache and on-disk data may differ.
103 Gifting pages to the kernel means that a subsequent
104 .BR splice (2)
105 .B SPLICE_F_MOVE
106 can successfully move the pages;
107 if this flag is not specified, then a subsequent
108 .BR splice (2)
109 .B SPLICE_F_MOVE
110 must copy the pages.
111 Data must also be properly page aligned, both in memory and length.
112 .\" .... if we expect to later SPLICE_F_MOVE to the cache.
113 .SH RETURN VALUE
114 Upon successful completion,
115 .BR vmsplice ()
116 returns the number of bytes transferred to the pipe.
117 On error,
118 .BR vmsplice ()
119 returns \-1 and
120 .I errno
121 is set to indicate the error.
122 .SH ERRORS
123 .TP
124 .B EBADF
125 .I fd
126 either not valid, or doesn't refer to a pipe.
127 .TP
128 .B EINVAL
129 .I nr_segs
130 is 0 or greater than
131 .BR IOV_MAX ;
132 or memory not aligned if
133 .B SPLICE_F_GIFT
134 set.
135 .TP
136 .B ENOMEM
137 Out of memory.
138 .SH VERSIONS
139 The
140 .BR vmsplice ()
141 system call first appeared in Linux 2.6.17;
142 library support was added to glibc in version 2.5.
143 .SH CONFORMING TO
144 This system call is Linux-specific.
145 .SH NOTES
146 .BR vmsplice ()
147 follows the other vectorized read/write type functions when it comes to
148 limitations on number of segments being passed in.
149 This limit is
150 .B IOV_MAX
151 as defined in
152 .IR <limits.h> .
153 At the time of this writing, that limit is 1024.
154 .SH SEE ALSO
155 .BR splice (2),
156 .BR tee (2)
157 .SH COLOPHON
158 This page is part of release 3.68 of the Linux
159 .I man-pages
160 project.
161 A description of the project,
162 information about reporting bugs,
163 and the latest version of this page,
164 can be found at
165 \%http://www.kernel.org/doc/man\-pages/.