OSDN Git Service

(split) LDP: Update release pages
[linuxjm/LDP_man-pages.git] / release / man2 / pread.2
1 .\" Copyright (C) 1999 Joseph Samuel Myers.
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\"*******************************************************************
26 .\"
27 .\" This file was generated with po4a. Translate the source file.
28 .\"
29 .\"*******************************************************************
30 .\"
31 .\" Japanese Version Copyright (c) 1999 HANATAKA Shinya
32 .\"         all rights reserved.
33 .\" Translated Fri Jun 25 23:32:20 JST 1999
34 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
35 .\" Updated 2012-04-30, Akihiro MOTOKI <amotoki@gmail.com>
36 .\" Updated 2012-05-29, Akihiro MOTOKI <amotoki@gmail.com>
37 .\" Updated 2013-05-01, Akihiro MOTOKI <amotoki@gmail.com>
38 .\" Updated 2013-07-24, Akihiro MOTOKI <amotoki@gmail.com>
39 .\"
40 .TH PREAD 2 2013\-06\-21 Linux "Linux Programmer's Manual"
41 .SH 名前
42 pread, pwrite \- 指定したオフセットでファイルディスクリプタを読み書きする
43 .SH 書式
44 \fB#include <unistd.h>\fP
45 .sp
46 \fBssize_t pread(int \fP\fIfd\fP\fB, void *\fP\fIbuf\fP\fB, size_t \fP\fIcount\fP\fB, off_t
47 \fP\fIoffset\fP\fB);\fP
48 .sp
49 \fBssize_t pwrite(int \fP\fIfd\fP\fB, const void *\fP\fIbuf\fP\fB, size_t \fP\fIcount\fP\fB,
50 off_t \fP\fIoffset\fP\fB);\fP
51 .sp
52 .in -4n
53 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
54 .in
55 .PD 0
56 .ad l
57 .sp
58 \fBpread\fP(), \fBpwrite\fP():
59 .RS 4
60 _XOPEN_SOURCE\ >=\ 500
61 .br
62 || /* glibc 2.12 以降: */ _POSIX_C_SOURCE\ >=\ 200809L
63 .RE
64 .ad
65 .PD
66 .SH 説明
67 \fBpread\fP()  は、ファイルディスクリプタ \fIfd\fP の (ファイルの先頭からの) オフセット \fIoffset\fP から最大 \fIcount\fP
68 バイトをバッファ \fIbuf\fP へ読み込む。ファイルオフセットは変化しない。
69 .PP
70 \fBpwrite\fP()  は、バッファ \fIbuf\fP から最大 \fIcount\fP バイトをファイルディスクリプタ \fIfd\fP のオフセット
71 \fIoffset\fP に書き込む。ファイルオフセットは変化しない。
72 .PP
73 \fIfd\fP で参照されるファイルはシーク (seek) 可能でなければならない。
74 .SH 返り値
75 成功した場合、読み書きを行ったバイト数が返される (ゼロは、 \fBpwrite\fP()  の場合には何も書かれなかったことを意味し、 \fBpread\fP()
76 の場合にはファイル の末尾に達したことを意味する)。 エラーの場合は \-1 が返され、 \fIerrno\fP がそのエラーを示すように設定される。
77 .SH エラー
78 \fBpread\fP()  では、 \fBread\fP(2)  および \fBlseek\fP(2)  で規定された全てのエラーが発生する可能性があり、
79 \fIerror\fP にはエラーを示す値が設定される。 \fBpwrite\fP()  では、 \fBwrite\fP(2)  および \fBlseek\fP(2)
80 で規定された全てのエラーが発生する可能性があり、 \fIerror\fP にはエラーを示す値が設定される。
81 .SH バージョン
82 システムコール \fBpread\fP()  と \fBpwrite\fP()  は Linux にバージョン 2.1.60 で追加された。 i386
83 のシステムコールのエントリは 2.1.69 で追加された。 (システムコールを持たない古いカーネルでの \fBlseek\fP(2)
84 を使ったエミュレーションを含めると)  C ライブラリにおけるサポートは glibc 2.1 で追加された。
85 .SH 準拠
86 POSIX.1\-2001.
87 .SH 注意
88 システムコール \fBpread\fP() と \fBpwrite\fP() は、特にマルチスレッドアプリケーションで役に立つ。 これらを使うと、
89 他のスレッドによるファイルオフセットの変更の影響を受けることなく、 複数のスレッドが同じファイルディスクリプタに対して入出力を行うことができる。
90
91 Linux では、裏で呼び出されるシステムコールの名前がカーネル 2.6 で変更された。
92 \fBpread\fP() は \fBpread64\fP() になり、 \fBpwrite\fP() は \fBpwrite64\fP() になった。
93 システムコールの番号は変更されていない。
94 glibc の \fBpread\fP() と \fBpwrite\fP() のラッパー関数はこれらの変更を吸収している。
95
96 いくつかの 32 ビットアーキテクチャでは、これらのシステムコールの呼び出し時のシグネチャーが違っています。理由は \fBsyscall\fP(2)
97 で説明されている通りです。
98 .SH バグ
99 .\" FIXME https://bugzilla.kernel.org/show_bug.cgi?id=43178
100 POSIX では、\fBO_APPEND\fP フラグを指定してファイルをオープンした場合、
101 \fBpwrite\fP() がデータを書き込む位置に影響を及ぼさないことが
102 求められている。しかし、 Linux では、ファイルを \fBO_APPEND\fP 付きで
103 オープンした場合、 \fIoffset\fP の値に関わらず、
104 \fBpwrite\fP() はファイルの末尾にデータを追記する。
105 .SH 関連項目
106 \fBlseek\fP(2), \fBread\fP(2), \fBreadv\fP(2), \fBwrite\fP(2)
107 .SH この文書について
108 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.54 の一部
109 である。プロジェクトの説明とバグ報告に関する情報は
110 http://www.kernel.org/doc/man\-pages/ に書かれている。