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 .\" 以下は、あまりにも汚い。 glibc バージョンについてのコメントは
37 .\" 「ヘッダ」ではなく、「注意」に書いておく。
39 .\" .B #include <features.h>
41 .\" .B #if (__GLIBC__==2 && __GLIBC_MINOR__>=1) || __GLIBC__>2
43 .\" .B #include <sys/sendfile.h>
47 .\" .B #include <sys/types.h>
49 .\" .B /* No system prototype before glibc 2.1. */
51 .\" .BI "ssize_t sendfile(int" " out_fd" ", int" " in_fd" ", off_t *" \
52 .\" offset ", size_t" " count" )
59 ファイル・ディスクリプタへのデータのコピーを行う。
70 ではユーザ空間との間でデータの転送が必要となるからである。
73 は読み込みのためにオープンされたファイル・ディスクリプタ、
75 は書き込みのためにオープンされたディスクリプタでなければならない。
84 のどこからデータを読み始めるかを示すファイル・オフセットを保持する変数への
87 は復帰する時、この変数に最後に読み込んだバイトの
94 のファイル・オフセットの現在値を変更しない。
95 NULL の場合は、ファイル・オフセットの現在値を
97 から読み込んだバイト数を反映した位置に調整する。
102 の現在のファイル・オフセットから読み出され、
103 ファイル・オフセットはこの呼び出しで更新される。
106 は、ファイル・ディスクリプタ間でコピーするバイト数である。
108 今のところ (Linux 2.6.9 では)、
112 風の操作ができるファイルを指していなければならない
124 .BR read (2)/ write (2)
129 に書き込まれたバイト数を返す。エラーの場合、\-1 を返し、
136 を用いて非ブロック I/O が選択されたが、書き込みがブロックされた。
139 入力ファイルが読み込みのためにオープンされていないか、
140 出力ファイルが書き込みのためにオープンされていない。
146 ディスクリプタが有効でないか、ロックされている。もしくは
154 から読み込んでいるうちに予期しないエラーが起こった。
161 は Linux 2.2 の新しい機能である。
164 は glibc 2.1 から存在している。
166 POSIX.1-2001 や他の標準では規定されていない。
168 他の UNIX システムでは、異なった方式やプロトタイプで
170 を実装している。移植性を考慮したプログラムでは使用すべきではない。
173 を使って TCP ソケットにファイルを送ろうとしていて、
174 ファイルの内容の前にヘッダ・データを付け加える必要がある場合は、
181 Linux 2.4 とそれ以前のバージョンでは、
185 はそのファイルのオフセットの現在値を変更していた。