1 .\" This man page is Copyright (C) 1998 Pawel Krawczyk.
2 .\" Permission is granted to distribute possibly modified copies
3 .\" of this page provided the header is included verbatim,
4 .\" and in case of nontrivial modification author and date
5 .\" of the modification is added to the header.
6 .\" $Id: sendfile.2,v 1.5 1999/05/18 11:54:11 freitag Exp $
7 .\" 2000-11-19 bert hubert <ahu@ds9a.nl>: in_fd cannot be socket
10 .\" updated description of in_fd and out_fd for 2.6
11 .\" Various wording and formatting changes
13 .\" 2005-03-31 Martin Pool <mbp@sourcefrog.net> mmap() improvements
15 .\" Japanese Version Copyright (c) 1999 HANATAKA Shinya
16 .\" all rights reserved.
17 .\" Translated 1999-06-26, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
18 .\" Updated 2001-02-16, Kentaro Shirakata <argrath@ub32.org>
19 .\" Updated 2003-09-08, Kentaro Shirakata <argrath@ub32.org>
20 .\" Updated 2005-03-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
21 .\" Updated 2005-04-17, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
22 .\" Updated 2010-04-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.24
24 .\"WORD: descriptor ディスクリプタ
28 .TH SENDFILE 2 2010-02-15 "Linux" "Linux Programmer's Manual"
30 sendfile \- ファイル・ディスクリプタ間でデータを転送する
32 .B #include <sys/sendfile.h>
34 .BI "ssize_t sendfile(int" " out_fd" ", int" " in_fd" ", off_t *" \
35 offset ", size_t" " count" );
36 .\"O .\" The below is too ugly. Comments about glibc versions belong
37 .\"O .\" in the notes, not in the header.
38 .\" 以下は、あまりにも汚い。 glibc バージョンについてのコメントは
39 .\" 「ヘッダ」ではなく、「注意」に書いておく。
41 .\" .B #include <features.h>
43 .\" .B #if (__GLIBC__==2 && __GLIBC_MINOR__>=1) || __GLIBC__>2
45 .\" .B #include <sys/sendfile.h>
49 .\" .B #include <sys/types.h>
51 .\" .B /* No system prototype before glibc 2.1. */
53 .\" .BI "ssize_t sendfile(int" " out_fd" ", int" " in_fd" ", off_t *" \
54 .\" offset ", size_t" " count" )
60 .\"O copies data between one file descriptor and another.
61 .\"O Because this copying is done within the kernel,
63 .\"O is more efficient than the combination of
67 .\"O which would require transferring data to and from user space.
70 ファイル・ディスクリプタへのデータのコピーを行う。
81 ではユーザ空間との間でデータの転送が必要となるからである。
84 .\"O should be a file descriptor opened for reading and
86 .\"O should be a descriptor opened for writing.
88 は読み込みのためにオープンされたファイル・ディスクリプタ、
90 は書き込みのためにオープンされたディスクリプタでなければならない。
94 .\"O is not NULL, then it points
95 .\"O to a variable holding the file offset from which
97 .\"O will start reading data from
101 .\"O returns, this variable
102 .\"O will be set to the offset of the byte following the last byte that was read.
110 のどこからデータを読み始めるかを示すファイル・オフセットを保持する変数への
113 は復帰する時、この変数に最後に読み込んだバイトの
117 .\"O is not NULL, then
119 .\"O does not modify the current file offset of
121 .\"O otherwise the current file offset is adjusted to reflect
122 .\"O the number of bytes read from
129 のファイル・オフセットの現在値を変更しない。
130 NULL の場合は、ファイル・オフセットの現在値を
132 から読み込んだバイト数を反映した位置に調整する。
136 .\"O is NULL, then data will be read from
138 .\"O starting at the current file offset,
139 .\"O and the file offset will be updated by the call.
143 の現在のファイル・オフセットから読み出され、
144 ファイル・オフセットはこの呼び出しで更新される。
147 .\"O is the number of bytes to copy between the file descriptors.
149 は、ファイル・ディスクリプタ間でコピーするバイト数である。
151 .\"O Presently (Linux 2.6.9):
153 .\"O must correspond to a file which supports
154 .\"O .BR mmap (2)-like
156 .\"O (i.e., it cannot be a socket);
159 .\"O must refer to a socket.
160 今のところ (Linux 2.6.9 では)、
164 風の操作ができるファイルを指していなければならない
169 .\"O Applications may wish to fall back to
170 .\"O .BR read (2)/ write (2)
171 .\"O in the case where
184 .BR read (2)/ write (2)
186 .\"O .SH "RETURN VALUE"
188 .\"O If the transfer was successful, the number of bytes written to
191 .\"O On error, \-1 is returned, and
193 .\"O is set appropriately.
196 に書き込まれたバイト数を返す。エラーの場合、\-1 を返し、
203 .\"O Nonblocking I/O has been selected using
205 .\"O and the write would block.
207 を用いて非ブロック I/O が選択されたが、書き込みがブロックされた。
210 .\"O The input file was not opened for reading or the output file
211 .\"O was not opened for writing.
212 入力ファイルが読み込みのためにオープンされていないか、
213 出力ファイルが書き込みのためにオープンされていない。
220 .\"O Descriptor is not valid or locked, or an
221 .\"O .BR mmap (2)-like
222 .\"O operation is not available for
224 ディスクリプタが有効でないか、ロックされている。もしくは
231 .\"O Unspecified error while reading from
234 から読み込んでいるうちに予期しないエラーが起こった。
237 .\"O Insufficient memory to read from
244 .\"O is a new feature in Linux 2.2.
246 は Linux 2.2 の新しい機能である。
247 .\"O The include file
248 .\"O .I <sys/sendfile.h>
249 .\"O is present since glibc 2.1.
252 は glibc 2.1 から存在している。
253 .\"O .SH "CONFORMING TO"
255 .\"O Not specified in POSIX.1-2001, or other standards.
256 POSIX.1-2001 や他の標準では規定されていない。
258 .\"O Other UNIX systems implement
260 .\"O with different semantics and prototypes.
261 .\"O It should not be used in portable programs.
262 他の UNIX システムでは、異なった方式やプロトタイプで
264 を実装している。移植性を考慮したプログラムでは使用すべきではない。
267 .\"O If you plan to use
269 .\"O for sending files to a TCP socket, but need
270 .\"O to send some header data in front of the file contents, you will find
271 .\"O it useful to employ the
273 .\"O option, described in
275 .\"O to minimize the number of packets and to tune performance.
277 を使って TCP ソケットにファイルを送ろうとしていて、
278 ファイルの内容の前にヘッダ・データを付け加える必要がある場合は、
285 .\"O In Linux 2.4 and earlier,
287 .\"O could refer to a regular file, and
289 .\"O changed the current offset of that file.
290 Linux 2.4 とそれ以前のバージョンでは、
294 はそのファイルのオフセットの現在値を変更していた。