1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" and Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" Modified Sat Jul 24 18:34:44 1993 by Rik Faith (faith@cs.unc.edu)
27 .\" Merged readv.[23], 2002-10-17, aeb
28 .\" 2007-04-30 mtk, A fairly major rewrite to fix errors and
31 .\" 1996-04-12 Tom Bjorkholm <tomb@mydata.se>
32 .\" First version written
33 .\" Modified Tue Oct 22 17:41:07 1996 by Eric S. Raymond <esr@thyrsus.com>
35 .\" Japanese Version Copyright (c) 1997-1999 HANATAKA Shinya
36 .\" all rights reserved.
37 .\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
38 .\" Updated 1999-04-03, HANATAKA Shinya
39 .\" Updated 2003-01-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
40 .\" Updated 2005-10-07, Akihiro MOTOKI
41 .\" Updated 2007-06-01, Akihiro MOTOKI, LDP v2.50
43 .\"WORD: vector ¥Ù¥¯¥¿ (vector)
44 .\"WORD: file descriptor ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
45 .\"WORD: buffer ¥Ð¥Ã¥Õ¥¡
47 .TH READV 2 2002-10-17 "Linux" "Linux Programmer's Manual"
49 readv, writev \- Ê£¿ô¤Î¥Ð¥Ã¥Õ¥¡¤Ø¤ÎÆɤ߽ñ¤¤ò¹Ô¤Ê¤¦
52 .B #include <sys/uio.h>
54 .BI "ssize_t readv(int " fd ", const struct iovec *" iov ", int " iovcnt );
56 .BI "ssize_t writev(int " fd ", const struct iovec *" iov ", int " iovcnt );
60 ´Ø¿ô¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
62 ¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥Õ¥¡¥¤¥ë¤«¤é¡¢
64 ¸Ä¤Î¥Ð¥Ã¥Õ¥¡Ê¬¤Î¥Ç¡¼¥¿¤òÆɤ߹þ¤ß¡¢
66 ¤Ç»ØÄꤵ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë
67 ("scatter input";¡Ö¤Ð¤é¤Þ¤ÆþÎÏ¡×)¡£
72 ¤Ç»ØÄꤵ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤«¤éºÇÂç
74 ¸Ä¤Î¥Ð¥Ã¥Õ¥¡Ê¬¤Î¥Ç¡¼¥¿¤ò¼è¤ê½Ð¤·¡¢
75 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
77 ¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤à
78 ("gather output";¡Ö¤«¤½¸¤á½ÐÎÏ¡×)¡£
84 ¹½Â¤ÂΤÎÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
88 ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
94 void *iov_base; /* Starting address */
95 size_t iov_len; /* Number of bytes to transfer */
101 ´Ø¿ô¤Ï¡¢Ê£¿ô¤Î¥Ð¥Ã¥Õ¥¡¤Ë¥Ç¡¼¥¿¤òÆɤ߹þ¤àÅÀ¤ò½ü¤¤¤Æ
103 ¤ÈÁ´¤¯Æ±ÍͤÎÆ°ºî¤ò¹Ô¤¦¡£
106 ´Ø¿ô¤Ï¡¢Ê£¿ô¤Î¥Ð¥Ã¥Õ¥¡¤Î¥Ç¡¼¥¿¤ò½ñ¤½Ð¤¹ÅÀ°Ê³°¤Ï
108 ¤ÈÁ´¤¯Æ±ÍͤÎÆ°ºî¤ò¹Ô¤¦¡£
110 ¥Ð¥Ã¥Õ¥¡¤ÏÇÛÎó¤Î½ç½ø¤Ç½èÍý¤µ¤ì¤ë¡£¤³¤ì¤Ï¡¢
114 ¤¬´°Á´¤Ë°ìÇդˤʤë¤Þ¤Ç¥Ç¡¼¥¿¤òµÍ¤á¤Æ¤«¤é¡¢
116 ¤Ê¤É¤Ë¿Ê¤à¤³¤È¤ò°ÕÌ£¤¹¤ë
117 (¥Ç¡¼¥¿¤¬½½Ê¬¤Ê¤¤¾ì¹ç¤Ï¡¢
119 ¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Î¤¤¤º¤ì¤â°ìÇդˤʤé¤Ê¤¤)¡£
124 ¤ÎÆâÍƤòÁ´Éô½ñ¤½Ð¤·¤Æ¤«¤é
131 ¤Ë¤è¤ë¥Ç¡¼¥¿Å¾Á÷¤Ï atomic ¤Ë¹Ô¤ï¤ì¤ë¡£¤Ä¤Þ¤ê¡¢
133 ¤Ë¤è¤ë¥Ç¡¼¥¿½ñ¤¹þ¤ß¤Ï°ì¤Ä¤Î¥Ö¥í¥Ã¥¯¤È¤·¤Æ¹Ô¤ï¤ì¡¢Â¾¤Î¥×¥í¥»¥¹¤Î
134 write ¤Ë¤è¤ë½ñ¤¹þ¤ß¤Èº®¤¶¤ê¹ç¤¦¤³¤È¤Ï¤Ê¤¤
137 ¤ò»²¾È¤Î¤³¤È)¡£Æ±Íͤˡ¢
139 ¤Ï¥Õ¥¡¥¤¥ë¤«¤éϢ³¤¹¤ë¥Ç¡¼¥¿¥Ö¥í¥Ã¥¯¤¬Æɤ߽Ф¹¤³¤È¤¬Êݾڤµ¤ì¡¢
140 Ʊ¤¸¥Õ¥¡¥¤¥ëµ½Ò (file description;
142 »²¾È) ¤ò»²¾È¤¹¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò»ý¤Ä¾¤Î¥¹¥ì¥Ã¥É¤ä¥×¥í¥»¥¹¤¬
143 ¼Â¹Ô¤·¤¿ read Áàºî¤Î±Æ¶Á¤ò¼õ¤±¤ë¤³¤È¤Ï¤Ê¤¤¡£
147 ´Ø¿ô¤ÏÆɤ߹þ¤ó¤À¥Ð¥¤¥È¿ô¤òÊÖ¤·¡¢
149 ´Ø¿ô¤Ï½ñ¤¹þ¤ó¤À¥Ð¥¤¥È¿ô¤òÊÖ¤¹¡£
150 ¥¨¥é¡¼¤Î¾ì¹ç \-1 ¤òÊÖ¤·¡¢\fIerrno\fP ¤òŬÀÚ¤ËÀßÄꤹ¤ë¡£
155 ¤ÈƱ¤¸¥¨¥é¡¼¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
156 ¤µ¤é¤Ë°Ê²¼¤Î¥¨¥é¡¼¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
162 ¤ÎÈϰϤò¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤·¤¿¡£¤â¤·¤¯¤Ï¡¢
163 ¥Ù¥¯¥¿¿ô \fIiovcnt\fP ¤¬ 0 ¤è¤ê¾®¤µ¤¤¤«µö²Ä¤µ¤ì¤¿ºÇÂçÃͤè¤ê¤âÂ礤«¤Ã¤¿¡£
169 ´Ø¿ô¤Ï 4.2BSD ¤ÇºÇ½é¤Ë¸½¤ï¤ì¤¿)¡¢POSIX.1-2001¡£
170 Linux libc5 ¤Ç¤Ï \fIiovcnt\fP °ú¤¿ô¤Î·¿¤È¤·¤Æ \fIsize_t\fP ¤ò¡¢
171 ¤³¤ì¤é¤Î´Ø¿ô¤ÎÊÖ¤êÃͤȤ·¤Æ \fIint\fP ¤ò»ÈÍѤ·¤Æ¤¤¤¿¡£
172 .\" readv/writev ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux 1.3.40 °ÊÁ°¤Ï¥Ð¥°¤À¤é¤±¤Ç¤¢¤Ã¤¿
173 .\" (¤È release.libc ¤Ë½ñ¤«¤ì¤Æ¤¤¤ë)¡£
178 ¤ÇÅϤ¹¤³¤È¤¬¤Ç¤¤ëÍ×ÁÇ¿ô¤Ë¾å¸Â¤òÀߤ±¤ë¼ÂÁõ¤¬Ç§¤á¤é¤ì¤Æ¤¤¤ë¡£
183 ¤òÄêµÁ¤¹¤ë¤³¤È¤ä¡¢¼Â¹Ô»þ¤Ë
184 .I sysconf(_SC_IOV_MAX)
185 ¤ÎÊÖ¤êÃÍ·Ðͳ¤Ç¡¢¤³¤Î¾å¸Â¤ò¹¹ð¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
186 Linux ¤Ç¤Ï¡¢¤³¤Î»ÅÁȤߤˤè¤ê¹¹ð¤µ¤ì¤ë¾å¸Â¤Ï 1024 ¤Ç¤¢¤ê¡¢
187 ¤³¤ÎÃͤϥ«¡¼¥Í¥ë¤Ç¤Î¾å¸Â¤½¤Î¤â¤Î¤Ç¤¢¤ë¡£
188 °ìÊý¤Ç¡¢glibc ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï¡¢¤½¤Î´Ø¿ô¤ÎÆâÉô¤Ç¸Æ¤Ð¤ì¤ë¥«¡¼¥Í¥ë¡¦
189 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬¤³¤Î¾å¸Â¤òĶ²á¤·¤Æ¼ºÇÔ¤·¤¿¤³¤È¤ò¸¡½Ð¤¹¤ë¤È¡¢
192 ¤Î¾ì¹ç¡¢¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï
194 ¤Ç»ØÄꤵ¤ì¤¿Á´¤Æ¤ÎÍ×ÁǤò³ÊǼ¤Ç¤¤ëÂ礤µ¤Î°ì»þ¥Ð¥Ã¥Õ¥¡¤ò³ä¤êÅö¤Æ¡¢
196 ¤ò¸Æ¤Ó½Ð¤¹ºÝ¤Ë¤½¤Î¥Ð¥Ã¥Õ¥¡¤òÅϤ·¡¢
197 ¤½¤Î¥Ð¥Ã¥Õ¥¡¤Î¥Ç¡¼¥¿¤ò
201 ¥Õ¥£¡¼¥ë¥É¤¬»ØÄꤹ¤ë¾ì½ê¤Ë¥³¥Ô¡¼¤·¤Æ¤«¤é¡¢
202 ¤½¤Î¥Ð¥Ã¥Õ¥¡¤ò²òÊü¤¹¤ë¡£
204 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤â¡¢Æ±¤¸¤è¤¦¤Ë°ì»þ¥Ð¥Ã¥Õ¥¡¤ò»È¤Ã¤Æ
211 ¤Î¤è¤¦¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ¹¤ëÁàºî¤ò¹Ô¤¦´Ø¿ô¤È¡¢
212 ɸ½àÆþ½ÐÎϥ饤¥Ö¥é¥ê¤Î´Ø¿ô¤ò¤´¤Á¤ã¤Þ¤¼¤Ë¤·¤Æ¸Æ¤Ö¤Î¤Ï¤ªÁ¦¤á¤·¤Ê¤¤¡£
213 ¤É¤ó¤Ê·ë²Ì¤Ë¤Ê¤ë¤«¤ÏÄêµÁ¤µ¤ì¤Æ¤ª¤é¤º¡¢
214 ¤ª¤½¤é¤¯Íߤ·¤¤·ë²Ì¤ÏÆÀ¤é¤ì¤Ê¤¤¤À¤í¤¦¡£
216 °Ê²¼¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤Ï
218 ¤Î»ÈÍÑÊýË¡¤ò¼¨¤¹¤â¤Î¤Ç¤¢¤ë¡£
222 char *str0 = "hello ";
223 char *str1 = "world\\n";
227 iov[0].iov_base = str0;
228 iov[0].iov_len = strlen(str0);
229 iov[1].iov_base = str1;
230 iov[1].iov_len = strlen(str1);
232 nwritten = writev(STDOUT_FILENO, iov, 2);