X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=draft%2Fman3%2Ffopen.3;h=38090a061383e6c71c2d022437362dca1c456310;hb=c1dfa2f6ab1bbed84992d3c59ee9925f4d453668;hp=936ed40a865746146332c26303cc19b5d3bc8104;hpb=ce024239a1d8e74a7a44f7c24cee4375cb13b3ef;p=linuxjm%2FLDP_man-pages.git diff --git a/draft/man3/fopen.3 b/draft/man3/fopen.3 index 936ed40a..38090a06 100644 --- a/draft/man3/fopen.3 +++ b/draft/man3/fopen.3 @@ -5,6 +5,7 @@ .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" +.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB) .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -32,6 +33,7 @@ .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. +.\" %%%LICENSE_END .\" .\" @(#)fopen.3 6.8 (Berkeley) 6/29/91 .\" @@ -39,492 +41,167 @@ .\" Modified, aeb, 960421, 970806 .\" Modified, joey, aeb, 2002-01-03 .\" -.\" Japanese Version Copyright (c) 1997 YOSHINO Takashi -.\" all rights reserved. -.\" Translated Thu Feb 13 12:10:38 JST 1997 -.\" by YOSHINO Takashi -.\" Updated & Modified Mon Mar 1 1999 -.\" by NAKANO Takeo -.\" Updated 1999-12-08, Kentaro Shirakata -.\" Updated 2001-12-13, Kentaro Shirakata -.\" Updated 2002-03-23, Kentaro Shirakata -.\" Updated 2005-10-15, Kentaro Shirakata -.\" Updated 2006-07-20, Akihiro MOTOKI +.\"******************************************************************* .\" -.\"WORD: file descriptor ファイル記述子 -.\"WORD: file position indicator ファイル位置指示子 -.\"WORD: indicator 指示子 -.\"WORD: global variable 大域変数 -.\"WORD: cancellation points 取り消しポイント +.\" This file was generated with po4a. Translate the source file. .\" -.TH FOPEN 3 2009-02-23 "GNU" "Linux Programmer's Manual" +.\"******************************************************************* +.TH FOPEN 3 2012\-04\-22 GNU "Linux Programmer's Manual" .SH 名前 -.\"O fopen, fdopen, freopen \- stream open functions fopen, fdopen, freopen \- ストリームを開く関数 .SH 書式 .nf -.B #include +\fB#include \fP .sp -.BI "FILE *fopen(const char *" path ", const char *" mode ); +\fBFILE *fopen(const char *\fP\fIpath\fP\fB, const char *\fP\fImode\fP\fB);\fP -.BI "FILE *fdopen(int " fd ", const char *" mode ); +\fBFILE *fdopen(int \fP\fIfd\fP\fB, const char *\fP\fImode\fP\fB);\fP -.BI "FILE *freopen(const char *" path ", const char *" mode ", FILE *" stream ); +\fBFILE *freopen(const char *\fP\fIpath\fP\fB, const char *\fP\fImode\fP\fB, FILE *\fP\fIstream\fP\fB);\fP .fi .sp .in -4n -.\"O Feature Test Macro Requirements for glibc (see -.\"O .BR feature_test_macros (7)): -glibc 向けの機能検査マクロの要件 -.RB ( feature_test_macros (7) -参照): +glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp -.BR fdopen (): -_POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE +\fBfdopen\fP(): _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE .SH 説明 -.\"O The -.\"O .BR fopen () -.\"O function opens the file whose name is the string pointed to by -.\"O .I path -.\"O and associates a stream with it. -.BR fopen () -関数は、 -.I path -で指定された名前のファイルを開き、ストリームと結びつける。 +\fBfopen\fP() 関数は、 \fIpath\fP で指定された名前のファイルを開き、ストリームと結びつける。 .PP -.\"O The argument -.\"O .I mode -.\"O points to a string beginning with one of the following sequences -.\"O (Additional characters may follow these sequences.): -引数 -.I mode -は、以下に続く文字のひとつから始まる文字列へのポインタである -(追加の文字がこの文字の後に続くこともある): -.TP -.B r -.\"O Open text file for reading. -.\"O The stream is positioned at the beginning of the file. -テキストファイルを読み出すために開く。 +引数 \fImode\fP は、以下に続く文字のひとつから始まる文字列へのポインタであ +る (以下の述べる、追加の文字が後に続くこともある): +.TP +\fBr\fP +テキストファイルを読み出すために開く。 ストリームはファイルの先頭に位置される。 +.TP +\fBr+\fP +読み出しおよび書き込みするために開く。 ストリームはファイルの先頭に位置される。 +.TP +\fBw\fP +ファイルを書き込みのために開く。 ファイルが既に存在する場合には長さゼロに切り詰める。 ファイルがなかった場合には新たに作成する。 ストリームはファイルの先頭に位置される。 -.TP -.B r+ -.\"O Open for reading and writing. -.\"O The stream is positioned at the beginning of the file. -読み出しおよび書き込みするために開く。 +.TP +\fBw+\fP +読み出しおよび書き込みのために開く。 ファイルが存在していない場合には新たに作成する。 存在している場合には長さゼロに切り詰められる。 ストリームはファイルの先頭に位置される。 -.TP -.B w -.\"O Truncate file to zero length or create text file for writing. -.\"O The stream is positioned at the beginning of the file. -ファイルを書き込みのために開く。 -ファイルが既に存在する場合には長さゼロに切り詰める。 -ファイルがなかった場合には新たに作成する。 -ストリームはファイルの先頭に位置される。 -.TP -.B w+ -.\"O Open for reading and writing. -.\"O The file is created if it does not exist, otherwise it is truncated. -.\"O The stream is positioned at the beginning of the file. -読み出しおよび書き込みのために開く。 -ファイルが存在していない場合には新たに作成する。 -存在している場合には長さゼロに切り詰められる。 -ストリームはファイルの先頭に位置される。 -.TP -.B a -.\"O Open for appending (writing at end of file). -.\"O The file is created if it does not exist. -.\"O The stream is positioned at the end of the file. -追加 (ファイルの最後に書き込む) のために開く。 -ファイルが存在していない場合には新たに作成する。 -ストリームはファイルの最後に位置される。 -.TP -.B a+ -.\"O Open for reading and appending (writing at end of file). -.\"O The file is created if it does not exist. -.\"O The initial file position for reading is at the beginning of the file, -.\"O but output is always appended to the end of the file. -読み出しおよび追加 (ファイルの最後に書き込む) のために開く。 -ファイルが存在していない場合には新たに作成する。 -読み出しの初期ファイル位置はファイルの先頭であるが、 -書き込みは常にファイルの最後に追加される。 +.TP +\fBa\fP +追加 (ファイルの最後に書き込む) のために開く。 ファイルが存在していない場合には新たに作成する。 ストリームはファイルの最後に位置される。 +.TP +\fBa+\fP +読み出しおよび追加 (ファイルの最後に書き込む) のために開く。 ファイルが存在していない場合には新たに作成する。 +読み出しの初期ファイル位置はファイルの先頭であるが、 書き込みは常にファイルの最後に追加される。 .PP -.\"O The -.\"O .I mode -.\"O string can also include the letter \(aqb\(aq either as a last character or as -.\"O a character between the characters in any of the two-character strings -.\"O described above. -.\"O This is strictly for compatibility with C89 -.\"O and has no effect; the \(aqb\(aq is ignored on all POSIX -.\"O conforming systems, including Linux. -.I mode -文字列には文字 \(aqb\(aq を追加指定することができ、 -.I mode -文字列の最後の文字として指定する。 -上記のうち 2 文字のモードの場合には 2 つの文字の間に指定することもできる。 -これは C89 との互換性のためだけに用意された -ものであり、関数の実行に対してはいかなる影響も持たない。 -すなわち、Linux を含む全ての POSIX 準拠システムでは、 -この \(aqb\(aq は無視される。 -.\"O (Other systems may treat text files and binary files differently, -.\"O and adding the \(aqb\(aq may be a good idea if you do I/O to a binary -.\"O file and expect that your program may be ported to non-UNIX -.\"O environments.) -(その他のシステムではテキストファイルとバイナリファイルを別々に扱うものもあるので、 -もしバイナリファイルの入出力を行い、 -そのプログラムが非 UNIX 環境へ移植されると予測するなら、 -\(aqb\(aqを付けておくのは良い考えである) +\fImode\fP 文字列には文字 \(aqb\(aq を追加指定することができ、 \fImode\fP 文字列の最後の文字として指定する。 上記のうち 2 +文字のモードの場合には 2 つの文字の間に指定することもできる。 これは C89 との互換性のためだけに用意された +ものであり、関数の実行に対してはいかなる影響も持たない。 すなわち、Linux を含む全ての POSIX 準拠システムでは、 この \(aqb\(aq +は無視される。 (その他のシステムではテキストファイルとバイナリファイルを別々に扱うものもあるので、 もしバイナリファイルの入出力を行い、 +そのプログラムが非 UNIX 環境へ移植されると予測するなら、 \(aqb\(aqを付けておくのは良い考えである) .PP -.\"O See NOTES below for details of glibc extensions for -.\"O .IR mode . -.I mode -の glibc による拡張の詳細については下記の「注意」を参照。 +\fImode\fP の glibc による拡張の詳細については下記の「注意」を参照。 .PP -.\"O Any created files will have mode -.\"O .BR S_IRUSR " | " S_IWUSR " | " S_IRGRP " | " S_IWGRP " | " S_IROTH " | " S_IWOTH -.\"O (0666), as modified by the process's umask value (see -.\"O .BR umask (2)). -すべての生成されたファイルは、 -.BR S_IRUSR " | " S_IWUSR " | " S_IRGRP " | " S_IWGRP " | " S_IROTH " | " S_IWOTH -(0666) のモードを -そのプロセスの umask 値によって修正したモードを持つ -.RB ( umask (2) -を見よ)。 +すべての生成されたファイルは、 \fBS_IRUSR\fP | \fBS_IWUSR\fP | \fBS_IRGRP\fP | \fBS_IWGRP\fP | +\fBS_IROTH\fP | \fBS_IWOTH\fP (0666) のモードを そのプロセスの umask 値によって修正したモードを持つ +(\fBumask\fP(2) を見よ)。 .PP -.\"O Reads and writes may be intermixed on read/write streams in any order. -.\"O Note that ANSI C requires that a file positioning function intervene -.\"O between output and input, unless an input operation encounters end-of-file. -.\"O (If this condition is not met, then a read is allowed to return the -.\"O result of writes other than the most recent.) -.\"O Therefore it is good practice (and indeed sometimes necessary -.\"O under Linux) to put an -.\"O .BR fseek (3) -.\"O or -.\"O .BR fgetpos (3) -.\"O operation between write and read operations on such a stream. -.\"O This operation may be an apparent no-op -.\"O (as in \fIfseek(..., 0L, SEEK_CUR)\fP -.\"O called for its synchronizing side effect. -読み出し/書き込みストリームに対しては任意の順序で読み書きを行うことができる。 -ただし ANSI C では、 -(入力操作がファイルの末尾に到達した場合を除いて) -出力と入力の間にはファイルの位置決め関数を -挟まなければならないことになっていることに注意されたい -(この条件を満足しない場合には、読み込み操作は、 -最後に書き込まれたものでなく、以前に書き込まれた -値を返すことを許されている)。 -したがって、このようなストリームでの読み書き操作の間には -.BR fseek (3) -または -.BR fgetpos (3) -操作を挟んでおくと良いだろう -(Linux では本当に必要となることもときどきある)。 -この操作は見かけ上何もしない操作 (no-op) でも良い -(例えば \fIfseek(..., 0L, SEEK_CUR)\fP を -その副次的効果である同期のためだけに呼べば良い)。 +読み出し/書き込みストリームに対しては任意の順序で読み書きを行うことができる。 ただし ANSI C では、 +(入力操作がファイルの末尾に到達した場合を除いて) 出力と入力の間にはファイルの位置決め関数を 挟まなければならないことになっていることに注意されたい +(この条件を満足しない場合には、読み込み操作は、 最後に書き込まれたものでなく、以前に書き込まれた 値を返すことを許されている)。 +したがって、このようなストリームでの読み書き操作の間には \fBfseek\fP(3) または \fBfgetpos\fP(3) 操作を挟んでおくと良いだろう +(Linux では本当に必要となることもときどきある)。 この操作は見かけ上何もしない操作 (no\-op) でも良い (例えば \fIfseek(..., +0L, SEEK_CUR)\fP を その副次的効果である同期のためだけに呼べば良い)。 .PP -.\"O Opening a file in append mode (\fBa\fP as the first character of -.\"O .IR mode ) -.\"O causes all subsequent write operations to this stream to occur -.\"O at end-of-file, as if preceded by an -.\"O .nf -.\"O -.\"O fseek(stream,0,SEEK_END); -.\"O .fi -.\"O .PP -.\"O call. -ファイルを追加モード -.RI ( mode -の最初の文字を \fBa\fP にする) で開くと、 -このストリームに対する書き込み操作は (先に +ファイルを追加モード (\fImode\fP の最初の文字を \fBa\fP にする) で開くと、 +このストリームに対する書き込み操作は全て (先に以下の呼び出しを行った +かのように) ファイルの末尾で行われる。 .nf - fseek(stream,0,SEEK_END); - + fseek(stream, 0, SEEK_END); .fi -の呼び出しを実行したかのように) ファイル末尾に対して行われる。 .PP -.\"O The -.\"O .BR fdopen () -.\"O function associates a stream with the existing file descriptor, -.\"O .IR fd . -.BR fdopen () -関数は、既存のファイル記述子 -.I fd -にストリームを結びつける。 -.\"O The -.\"O .I mode -.\"O of the stream (one of the values "r", "r+", "w", "w+", "a", "a+") -.\"O must be compatible with the mode of the file descriptor. -ストリームの -.I mode -("r", "r+", "w", "w+", "a", "a+" のいずれか) は -ファイル記述子のモードと互換のものでなければならない。 -.\"O The file position indicator of the new stream is set to that -.\"O belonging to -.\"O .IR fd , -.\"O and the error and end-of-file indicators are cleared. -.\"O Modes "w" or "w+" do not cause truncation of the file. -新しいストリームのファイル位置指示子は -.I fd -に属している値に設定される。 -error と end-of-file の各指示子はクリアされる。 -"w" および "w+" モードでのファイルの切り詰めは行われない。 -.\"O The file descriptor is not dup'ed, and will be closed when -.\"O the stream created by -.\"O .BR fdopen () -.\"O is closed. -.\"O The result of applying -.\"O .BR fdopen () -.\"O to a shared memory object is undefined. -ファイル記述子の複製は行なわれない。 -.BR fdopen () -で作成されたストリームが閉じられたときにファイル記述子も -閉じられる。 -共有メモリのオブジェクトへ -.BR fdopen () +\fBfdopen\fP() 関数は、既存のファイル記述子 \fIfd\fP にストリームを結びつける。 ストリームの \fImode\fP ("r", "r+", +"w", "w+", "a", "a+" のいずれか) は ファイル記述子のモードと互換のものでなければならない。 +新しいストリームのファイル位置指示子は \fIfd\fP に属している値に設定される。 error と end\-of\-file の各指示子はクリアされる。 +"w" および "w+" モードでのファイルの切り詰めは行われない。 ファイル記述子の複製は行なわれない。 \fBfdopen\fP() +で作成されたストリームが閉じられたときにファイル記述子も 閉じられる。 共有メモリのオブジェクトへ \fBfdopen\fP() を行ったときの結果は定義されていない。 .PP -.\"O The -.\"O .BR freopen () -.\"O function opens the file whose name is the string pointed to by -.\"O .I path -.\"O and associates the stream pointed to by -.\"O .I stream -.\"O with it. -.\"O The original stream (if it exists) is closed. -.\"O The -.\"O .I mode -.\"O argument is used just as in the -.\"O .BR fopen () -.\"O function. -.\"O The primary use of the -.\"O .BR freopen () -.\"O function is to change the file associated with a standard text stream -.\"O .RI ( stderr ", " stdin ", or " stdout ). -.BR freopen () -関数は -.I path -で名前が指定されたファイルを開き、 -.I stream -で指定されたストリームに、そのファイルを結びつける。 -もとのストリームは (もし存在する場合には) 閉じられる。 -.I mode -引数は -.BR fopen () -関数と同じ形で使われる。 -.BR freopen () -関数の主な用途は、標準テキストストリーム -.RI ( stderr ", " stdin ", " stdout ) -と対応付けられているファイルを変更することである。 +\fBfreopen\fP() 関数は \fIpath\fP で名前が指定されたファイルを開き、 \fIstream\fP +で指定されたストリームに、そのファイルを結びつける。 もとのストリームは (もし存在する場合には) 閉じられる。 \fImode\fP 引数は +\fBfopen\fP() 関数と同じ形で使われる。 \fBfreopen\fP() 関数の主な用途は、標準テキストストリーム (\fIstderr\fP, +\fIstdin\fP, \fIstdout\fP) と対応付けられているファイルを変更することである。 .SH 返り値 -.\"O Upon successful completion -.\"O .BR fopen (), -.\"O .BR fdopen () -.\"O and -.\"O .BR freopen () -.\"O return a -.\"O .I FILE -.\"O pointer. -.\"O Otherwise, NULL is returned and -.\"O .I errno -.\"O is set to indicate the error. -.BR fopen (), -.BR fdopen (), -.BR freopen () -は成功すると -.I FILE -型のポインタを返す。 -失敗すると NULL が返され、 -.I errno -がエラーを示す値にセットされる。 +\fBfopen\fP(), \fBfdopen\fP(), \fBfreopen\fP() は成功すると \fIFILE\fP 型のポインタを返す。 失敗すると NULL +が返され、 \fIerrno\fP がエラーを示す値にセットされる。 .SH エラー -.TP -.B EINVAL -.\"O The -.\"O .I mode -.\"O provided to -.\"O .BR fopen (), -.\"O .BR fdopen (), -.\"O or -.\"O .BR freopen () -.\"O was invalid. -.BR fopen (), -.BR fdopen (), -.BR freopen () -で与えられた -.I mode -が不適切である。 +.TP +\fBEINVAL\fP +\fBfopen\fP(), \fBfdopen\fP(), \fBfreopen\fP() で与えられた \fImode\fP が不適切である。 .PP -.\"O The -.\"O .BR fopen (), -.\"O .BR fdopen () -.\"O and -.\"O .BR freopen () -.\"O functions may also fail and set -.\"O .I errno -.\"O for any of the errors specified for the routine -.\"O .BR malloc (3). -.BR fopen (), -.BR fdopen (), -.BR freopen () -関数は -.BR malloc (3) -ルーチンで規定されているエラーでも失敗することがあり、 -その時は対応する値に -.I errno -をセットする。 +\fBfopen\fP(), \fBfdopen\fP(), \fBfreopen\fP() 関数は \fBmalloc\fP(3) +ルーチンで規定されているエラーでも失敗することがあり、 その時は対応する値に \fIerrno\fP をセットする。 .PP -.\"O The -.\"O .BR fopen () -.\"O function may also fail and set -.\"O .I errno -.\"O for any of the errors specified for the routine -.\"O .BR open (2). -.BR fopen () -関数は -.BR open (2) -ルーチンで規定されているエラーでも失敗することがあり、 -その時は対応する値に -.I errno +\fBfopen\fP() 関数は \fBopen\fP(2) ルーチンで規定されているエラーでも失敗することがあり、 その時は対応する値に \fIerrno\fP をセットする。 .PP -.\"O The -.\"O .BR fdopen () -.\"O function may also fail and set -.\"O .I errno -.\"O for any of the errors specified for the routine -.\"O .BR fcntl (2). -.BR fdopen () -関数は -.BR fcntl (2) -ルーチンで規定されているエラーでも失敗することがあり、 -その時は対応する値に -.I errno -をセットする。 +\fBfdopen\fP() 関数は \fBfcntl\fP(2) ルーチンで規定されているエラーでも失敗することがあり、 その時は対応する値に +\fIerrno\fP をセットする。 .PP -.\"O The -.\"O .BR freopen () -.\"O function may also fail and set -.\"O .I errno -.\"O for any of the errors specified for the routines -.\"O .BR open (2), -.\"O .BR fclose (3) -.\"O and -.\"O .BR fflush (3). -.BR freopen () -関数は -.BR open (2), -.BR fclose (3), -.BR fflush (3) -各ルーチンで規定されているエラーでも失敗することがあり、 -その時は対応する値に -.I errno -をセットする。 +\fBfreopen\fP() 関数は \fBopen\fP(2), \fBfclose\fP(3), \fBfflush\fP(3) +各ルーチンで規定されているエラーでも失敗することがあり、 その時は対応する値に \fIerrno\fP をセットする。 .SH 準拠 -.\"O The -.\"O .BR fopen () -.\"O and -.\"O .BR freopen () -.\"O functions conform to C89. -.\"O The -.\"O .BR fdopen () -.\"O function conforms to POSIX.1-1990. -.BR fopen () -関数と -.BR freopen () -関数は C89に準拠している。 -.BR fdopen () -関数は POSIX.1-1990 に準拠している。 -.\"O .SH NOTES -.\"O .SS Glibc Notes +\fBfopen\fP() 関数と \fBfreopen\fP() 関数は C89に準拠している。 \fBfdopen\fP() 関数は POSIX.1\-1990 +に準拠している。 .SH 注意 -.SS glibc での注意 -.\"O The GNU C library allows the following extensions for the string specified in -.\"O .IR mode : -GNU C ライブラリでは、 -.I mode -に指定できる文字列として、以下の拡張が行われている: -.TP -.\"O .BR c " (since glibc 2.3.3)" -.BR c " (glibc 2.3.3 以降)" -.\"O Do not make the open operation, -.\"O or subsequent read and write operations, -.\"O thread cancellation points. -open 操作、それに続く read/write 操作の、 -スレッドの取り消しポイント (cancellation points) -を作成しない。 -.TP -.\"O .BR e " (since glibc 2.7)" -.BR e " (glibc 2.7 以降)" -.\"O Open the file with the -.\"O .B O_CLOEXEC -.\"O flag. -.\"O See -.\"O .BR open (2) -.\"O for more information. -.B O_CLOEXEC -フラグを有効にしてファイルをオープンする。 -詳細は -.BR open (2) -を参照。 -.TP -.\"O .BR m " (since glibc 2.3)" -.BR m " (glibc 2.3 以降)" -.\"O Attempt to access the file using -.\"O .BR mmap (2), -.\"O rather than I/O system calls -.\"O .RB ( read (2), -.\"O .BR write (2)). -.\"O Currently, -.\"O .\" As at glibc 2.4: -.\"O use of -.\"O .BR mmap (2) -.\"O is only attempted for a file opened for reading. -I/O システムコール -.RB ( read (2), -.BR write (2)) -ではなく、 -.BR mmap (2) -を使ってファイルにアクセスしようとする。 -.\" glibc 2.4 では -.BR mmap (2) -を使おうとするのは、読み出し用にオープンするファイルについてだけである。 -.TP -.B x -.\"O Open the file exclusively -.\"O (like the -.\"O .B O_EXCL -.\"O flag of -.\"O .BR open (2)). -.\"O If the file already exists, -.\"O .BR fopen () -.\"O fails, and sets -.\"O .I errno -.\"O to -.\"O .BR EEXIST . -ファイルを排他的にオープンする -.RB ( open (2) -の -.B O_EXCL -フラグと同様)。 -ファイルがすでに存在する場合、 -.BR fopen () -は失敗し、 -.I errno -に -.B EEXIST -がセットされる。 -.\"O This flag is ignored for -.\"O .BR fdopen (). -このフラグは -.BR fdopen () -では無視される。 -.\" FIXME document /,ccs= charset/ -.\"O .SH "SEE ALSO" +.SS "glibc での注意" +GNU C ライブラリでは、 \fImode\fP に指定できる文字列として、以下の拡張が行われている: +.TP +\fBc\fP (glibc 2.3.3 以降) +open 操作、それに続く read/write 操作の、 スレッドの取り消しポイント +(cancellation points) を作成しない。 +このフラグは \fBfdopen\fP() では無視される。 +.TP +\fBe\fP (glibc 2.7 以降) +\fBO_CLOEXEC\fP フラグを有効にしてファイルをオープンする。詳細は +\fBopen\fP(2) を参照。このフラグは \fBfdopen\fP() では無視される。 +.TP +\fBm\fP (glibc 2.3 以降) +.\" As at glibc 2.4: +I/O システムコール (\fBread\fP(2), \fBwrite\fP(2)) ではなく、 \fBmmap\fP(2) +を使ってファイルにアクセスしようとする。 \fBmmap\fP(2) を使おうとするのは、読み出し用にオープンするファイルについてだけである。 +.TP +\fBx\fP +.\" Since glibc 2.0? +.\" FIXME C11 specifies this flag +ファイルを排他的にオープンする (\fBopen\fP(2) の \fBO_EXCL\fP フラグと同様)。 ファイルがすでに存在する場合、 \fBfopen\fP() +は失敗し、 \fIerrno\fP に \fBEEXIST\fP がセットされる。 このフラグは \fBfdopen\fP() では無視される。 +.PP +上記の文字に加えて、 +\fBfopen\fP() と \fBfreopen\fP() では \fImode\fP に +以下の書式を 指定することができる。 + +\fB ,ccs=\fP\fIstring\fP + +指定された \fIstring\fP は、符号化文字集合の名前と解釈され、 +ストリームではワイド文字のストリームとして扱われる。 +内部変換関数で入出力時に文字集合 \fIstring\fP との変換が行われる。 +書式 \fB,ccs=\fP\fIstring\fP が指定されない場合は、 +ストリームをワイド文字のストリームとして扱うかは +最初のファイル操作時に決定される。 +最初のファイル操作がワイド文字操作であった場合は、 +そのストリームはワイド文字のストリームとして扱われ、 +符号化文字集合との変換を行う関数が読み込まれる。 +.SH バグ +.\" FIXME http://sourceware.org/bugzilla/show_bug.cgi?id=12685 +\fImode\fP の個々のフラグ文字 ("ccs" 指定の前の文字) を解釈する際に、 +glibc の \fBfopen\fP() と \fBfreopen\fP() の実装では、 +\fImode\fP の確認を最大 7 文字しか行わないという制限がある +(バージョン 2.14 より前の glibc では最大 6 文字だが、 +6 文字では "rb+cmxe" などの指定を行うには不十分であった)。 +\fBfdopen\fP() の現在の実装では最大 5 文字の \fImode\fP しか解釈されない。 .SH 関連項目 -.BR open (2), -.BR fclose (3), -.BR fileno (3), -.BR fmemopen (3), -.BR fopencookie (3) +\fBopen\fP(2), \fBfclose\fP(3), \fBfileno\fP(3), \fBfmemopen\fP(3), \fBfopencookie\fP(3) +.SH この文書について +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部 +である。プロジェクトの説明とバグ報告に関する情報は +http://www.kernel.org/doc/man\-pages/ に書かれている。