File: readv.2

package info (click to toggle)
manpages-ja 0.5.0.0.20080615-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 20,508 kB
  • ctags: 1
  • sloc: sh: 13,690; perl: 157; makefile: 114
file content (237 lines) | stat: -rw-r--r-- 6,377 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
.\" and (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\" License.
.\" Modified Sat Jul 24 18:34:44 1993 by Rik Faith (faith@cs.unc.edu)
.\" Merged readv.[23], 2002-10-17, aeb
.\" 2007-04-30 mtk, A fairly major rewrite to fix errors and
.\"     add more details.
.\"
.\" 1996-04-12 Tom Bjorkholm <tomb@mydata.se>
.\"            First version written
.\" Modified Tue Oct 22 17:41:07 1996 by Eric S. Raymond <esr@thyrsus.com>
.\"
.\" Japanese Version Copyright (c) 1997-1999 HANATAKA Shinya
.\"         all rights reserved.
.\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 1999-04-03, HANATAKA Shinya
.\" Updated 2003-01-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2005-10-07, Akihiro MOTOKI
.\" Updated 2007-06-01, Akihiro MOTOKI, LDP v2.50
.\"
.\"WORD:	vector			٥ (vector)
.\"WORD:	file descriptor		եǥץ
.\"WORD:	buffer			Хåե
.\"
.TH READV 2  2002-10-17 "Linux" "Linux Programmer's Manual"
.SH ̾
readv, writev \- ʣΥХåեؤɤ߽񤭤Ԥʤ
.SH 
.nf
.B #include <sys/uio.h>
.sp
.BI "ssize_t readv(int " fd ", const struct iovec *" iov ", int " iovcnt );
.sp
.BI "ssize_t writev(int " fd ", const struct iovec *" iov ", int " iovcnt );
.fi
.SH 
.BR readv ()
ؿϡեǥץ
.I fd
˴Ϣդ줿ե뤫顢
.I iovcnt
ĤΥХåեʬΥǡɤ߹ߡ
.I iov
ǻꤵ줿Хåե˳Ǽ
("scatter input";֤Фޤϡ)
.PP
.BR writev ()
ؿϡ
.I iov
ǻꤵ줿Хåե
.I iovcnt
ĤΥХåեʬΥǡФ
եǥץ
.I fd
˴Ϣդ줿ե˽񤭹
("gather output";֤ϡ)
.PP
ݥ
.I iov

.I iovec
¤ΤؤΥݥ󥿤Ǥ롣
.I iovec
¤Τ
.I <sys/uio.h>
ǰʲΤ褦Ƥ:
.PP
.br
.in +4n
.nf
struct iovec {
    void  *iov_base;    /* Starting address */
    size_t iov_len;     /* Number of bytes to transfer */
};
.fi
.in
.PP
.BR readv ()
ؿϡʣΥХåե˥ǡɤ߹
.BR read (2)
ƱͤưԤ
.PP
.BR writev ()
ؿϡʣΥХåեΥǡ񤭽Фʳ
.BR write (2)
ƱͤưԤ
.PP
Хåեνǽ롣ϡ
.BR readv ()

.IR iov [0]
˰դˤʤޤǥǡͤƤ顢
.IR iov [0]
ʤɤ˿ʤळȤ̣
(ǡʬʤϡ
.I iov
ؤХåեΤդˤʤʤ)
Ʊͤˡ
.BR writev ()

.IR iov [0]
Ƥ񤭽ФƤ
.IR iov [1]
ʤɤ˿ʤࡣ
.PP
.BR readv ()

.BR writev ()
ˤǡž atomic ˹Ԥ롣Ĥޤꡢ
.BR writev ()
ˤǡ񤭹ߤϰĤΥ֥åȤƹԤ졢¾Υץ
write ˤ񤭹ߤȺ礦ȤϤʤ
(㳰˴ؤƤ
.BR pipe (7)
򻲾ȤΤ)Ʊͤˡ
.BR readv ()
ϥե뤫Ϣ³ǡ֥åɤ߽ФȤݾڤ졢
Ʊե뵭 (file description;
.BR open (2)
) 򻲾Ȥեǥץ¾Υåɤץ
¹Ԥ read αƶ뤳ȤϤʤ
.SH ֤
.BR readv ()
ؿɤ߹Хȿ֤
.BR writev ()
ؿϽ񤭹Хȿ֤
顼ξ \-1 ֤\fIerrno\fP Ŭڤꤹ롣
.SH 顼
.BR read (2)

.BR write (2)
Ʊ顼Ƥ롣
˰ʲΥ顼Ƥ:
.TP
.B EINVAL
.I iov_len
ιפ
.I ssize_t
ϰϤ򥪡Сե⤷ϡ
٥ \fIiovcnt\fP  0 꾮Ĥ줿ͤ礭ä
.SH 
4.4BSD
.RB ( readv ()

.BR writev ()
ؿ 4.2BSD Ǻǽ˸줿)POSIX.1-2001
Linux libc5 Ǥ \fIiovcnt\fP ηȤ \fIsize_t\fP 
δؿ֤ͤȤ \fIint\fP ѤƤ
.\" readv/writev ƥॳ Linux 1.3.40 ϥХ餱Ǥä
.\" ( release.libc ˽񤫤Ƥ)
.SH 
.SS "Linux Ǥ"
POSIX.1-2001 Ǥϡ
.I iov
ϤȤǤǿ˾¤ߤǧƤ롣
ϡ
.I <limits.h>

.B IOV_MAX
뤳Ȥ䡢¹Ի
.I sysconf(_SC_IOV_MAX)
֤ͷͳǡξ¤򹭹𤹤뤳ȤǤ롣
Linux ǤϡλȤߤˤ깭𤵤¤ 1024 Ǥꡢ
ͤϥͥǤξ¤ΤΤǤ롣
ǡglibc ΥåѡؿϡδؿǸƤФ륫ͥ롦
ƥॳ뤬ξ¤ĶᤷƼԤȤ򸡽Фȡ
ɲäư򤹤롣
.BR readv ()
ξ硢åѡؿ
.I iov
ǻꤵ줿ƤǤǼǤ礭ΰХåեơ
.BR read (2)
ƤӽФݤˤΥХåեϤ
ΥХåեΥǡ
.I iov
γǤ
.I iov_base
եɤꤹ˥ԡƤ顢
ΥХåե롣
.BR writev ()
Υåѡؿ⡢Ʊ褦˰ХåեȤä
.BR write (2)
ƤӽФ
.SH Х
.BR readv ()

.BR writev ()
Τ褦ʥեǥץФԤؿȡ
ɸϥ饤֥δؿ򤴤ޤˤƸƤ֤ΤϤᤷʤ
ɤʷ̤ˤʤ뤫Ƥ餺
餯ߤ̤ʤ
.SH 
ʲΥץ륳ɤ
.BR writev ()
λˡ򼨤ΤǤ롣

.in +4n
.nf
char *str0 = "hello ";
char *str1 = "world\\n";
struct iovec iov[2];
ssize_t nwritten;

iov[0].iov_base = str0;
iov[0].iov_len = strlen(str0);
iov[1].iov_base = str1;
iov[1].iov_len = strlen(str1);

nwritten = writev(STDOUT_FILENO, iov, 2);
.fi
.in
.SH Ϣ
.BR read (2),
.BR write (2)