OSDN Git Service

(split) LDP: Restore and add Copyrights for draft pages
[linuxjm/LDP_man-pages.git] / draft / man2 / openat.2
1 .\" This manpage is Copyright (C) 2006, Michael Kerrisk
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) 2006 Yuichi SATO
32 .\"         all rights reserved.
33 .\" Translated 2006-09-27 by Yuichi SATO <ysato444@yahoo.co.jp>, LDP v2.39
34 .\"
35 .TH OPENAT 2 2012\-05\-04 Linux "Linux Programmer's Manual"
36 .SH 名前
37 openat \- ディレクトリファイルディスクリプタから相対的な位置にあるファイルをオープンする
38 .SH 書式
39 .nf
40 \fB#include <fcntl.h>\fP
41 .sp
42 \fBint openat(int \fP\fIdirfd\fP\fB, const char *\fP\fIpathname\fP\fB, int \fP\fIflags\fP\fB);\fP
43 \fBint openat(int \fP\fIdirfd\fP\fB, const char *\fP\fIpathname\fP\fB, int \fP\fIflags\fP\fB, mode_t \fP\fImode\fP\fB);\fP
44 .fi
45 .sp
46 .in -4n
47 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
48 .in
49 .sp
50 \fBopenat\fP():
51 .PD 0
52 .ad l
53 .RS 4
54 .TP  4
55 glibc 2.10 以降:
56 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
57 .TP 
58 glibc 2.10 より前:
59 _ATFILE_SOURCE
60 .RE
61 .ad
62 .PD
63 .SH 説明
64 \fBopenat\fP()  システムコールは、この man ページで説明している違いがある以外は、 \fBopen\fP(2)  と全く同じように動作する。
65
66 \fIpathname\fP で指定されるパス名が相対パスである場合、 ファイルディスクリプタ \fIdirfd\fP
67 で参照されるディレクトリからの相対パス名として解釈される (\fBopen\fP(2)
68 では、相対パスは呼び出し元プロセスのカレントワーキングディレクトリからの 相対パスとなる)。
69
70 \fIpathname\fP が相対パスであり、かつ \fIdirfd\fP が特別な値 \fBAT_FDCWD\fP である場合、 \fIpathname\fP は
71 (\fBopen\fP(2)  と同じように) 呼び出し元プロセスの カレントワーキングディレクトリからの相対パス名として解釈される。
72
73 \fIpathname\fP が絶対パスである場合、 \fIdirfd\fP は無視される。
74 .SH 返り値
75 成功した場合、 \fBopenat\fP()  は新しいファイルディスクリプタを返す。 エラーの場合、\-1 が返されて、 \fIerrno\fP
76 にはエラーを示す値が設定される。
77 .SH エラー
78 \fBopen\fP(2)  と同じエラーが \fBopenat\fP()  でも起こる。 \fBopenat\fP()  では、その他に以下のエラーが起こる:
79 .TP 
80 \fBEBADF\fP
81 \fIdirfd\fP が有効なファイルディスクリプタでない。
82 .TP 
83 \fBENOTDIR\fP
84 \fIpathname\fP が相対パスで、かつ \fIdirfd\fP がディレクトリ以外のファイルを参照するファイルディスクリプタである。
85 .SH バージョン
86 \fBopenat\fP()  は Linux カーネル 2.6.16 で追加された。
87 ライブラリによるサポートは glibc バージョン 2.4 で追加された。
88 .SH 準拠
89 .\" The 'at' suffix in Solaris is actually double sensed.  It
90 .\" primarily referred to "extended *at*tributes", which are
91 .\" handled by Solaris' O_XATTR flag, but was also intended
92 .\" to refer to the notion of "at a relative location".
93 .\"
94 .\" See the following for a discussion of the inconsistent
95 .\" naming of the *at() functions:
96 .\" http://www.opengroup.org/austin/mailarchives/ag/msg09103.html
97 .\" Subject:    RE: The naming of at()s is a difficult matter
98 .\" From:       Don Cragun
99 .\" Date:       Tue, 14 Feb 2006 14:56:50 -0800 (PST)
100 .\"
101 POSIX.1\-2008.  Solaris には、これと同じようなシステムコールが存在する。
102 .SH 注意
103 \fBopenat\fP()  や "at" が後ろに付いたその他の同様のシステムコールは、 2 つの理由により提供されている。
104
105 1 つ目の理由は、 カレントワーキングディレクトリ以外のディレクトリにあるファイル群を \fBopen\fP(2)
106 でオープンするときに起こる可能性がある競合状態 (race condition) を、 \fBopenat\fP()
107 によってアプリケーションが回避できるためである。 これらの競合状態は、 \fBopen\fP(2)  に指定されたパスのディレクトリ部分の (/
108 で区切られた) いくつかの構成要素 (をオープンする処理) が、 \fBopen\fP(2)  を並列に呼び出す処理に変換された場合に起こる。
109 このような競合は、対象ディレクトリのファイルディスクリプタをオープンし、 そのファイルディスクリプタを \fBopenat\fP()  の \fIdirfd\fP
110 引き数に指定することで回避できる。
111
112 2 つ目の理由は、 アプリケーションによって管理されるファイルディスクリプタ (群) を使うことで、 \fBopenat\fP()
113 がスレッド毎のいわゆる「カレントワーキングディレクトリ」を実装できるためである。 (この機能は \fI/proc/self/fd/\fPdirfd
114 を使った裏技でも実現できるが、あまり効率的ではない)。
115 .SH 関連項目
116 \fBfaccessat\fP(2), \fBfchmodat\fP(2), \fBfchownat\fP(2), \fBfstatat\fP(2),
117 \fBfutimesat\fP(2), \fBlinkat\fP(2), \fBmkdirat\fP(2), \fBmknodat\fP(2), \fBopen\fP(2),
118 \fBreadlinkat\fP(2), \fBrenameat\fP(2), \fBsymlinkat\fP(2), \fBunlinkat\fP(2),
119 \fButimensat\fP(2), \fBmkfifoat\fP(3), \fBpath_resolution\fP(7)
120 .SH この文書について
121 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
122 である。プロジェクトの説明とバグ報告に関する情報は
123 http://www.kernel.org/doc/man\-pages/ に書かれている。