OSDN Git Service

(split) DP: release pages (catch up to 3.50).
[linuxjm/LDP_man-pages.git] / release / man3 / realpath.3
1 .\" Copyright (C) 1999 Andries Brouwer (aeb@cwi.nl)
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 .\" Rewritten old page, 990824, aeb@cwi.nl
26 .\" 2004-12-14, mtk, added discussion of resolved_path == NULL
27 .\"
28 .\"*******************************************************************
29 .\"
30 .\" This file was generated with po4a. Translate the source file.
31 .\"
32 .\"*******************************************************************
33 .TH REALPATH 3 2013\-03\-15 "" "Linux Programmer's Manual"
34 .SH 名前
35 realpath \- 正規化された絶対パス名を返す
36 .SH 書式
37 .nf
38 \fB#include <limits.h>\fP
39 \fB#include <stdlib.h>\fP
40 .sp
41 \fBchar *realpath(const char *\fP\fIpath\fP\fB, char *\fP\fIresolved_path\fP\fB);\fP
42 .fi
43 .sp
44 .in -4n
45 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
46 .in
47 .sp
48 \fBrealpath\fP():
49 .ad l
50 .RS 4
51 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
52 .RE
53 .ad
54 .SH 説明
55 \fBrealpath\fP()  は \fIpath\fP として与えられた NULL 終端された文字列中の すべてのシンボリックリンクを展開し、 \fI/./\fP,
56 \fI/../\fP による参照や余分な \(aq/\(aq を解決して、正規化された絶対パス名を生成する。 得られた絶対パス名は、最大で
57 \fBPATH_MAX\fP バイトの NULL 終端された文字列として、 \fIresolved_path\fP により参照されるバッファに格納される。
58 結果として返るパスの中には、シンボリックリンクや \fI/./\fP, \fI/../\fP といった要素は含まれない。
59
60 .\" Even if we use resolved_path == NULL, then realpath() will still
61 .\" return ENAMETOOLONG if the resolved pathname would exceed PATH_MAX
62 .\" bytes -- MTK, Dec 04
63 .\" .SH HISTORY
64 .\" The
65 .\" .BR realpath ()
66 .\" function first appeared in 4.4BSD, contributed by Jan-Simon Pendry.
67 \fIresolved_path\fP に NULL が指定されると、 \fBrealpath\fP()  は \fBmalloc\fP(3)
68 を使って解決したパス名を保持するためのバッファを 最大で \fBPATH_MAX\fP バイトまで割り当て、このバッファへのポインタを返す。 呼び出し元は、
69 \fBfree\fP(3)  を使ってこのバッファを解放すべきである。
70 .SH 返り値
71 エラーがなかった場合、 \fBrealpath\fP()  は \fIresolved_path\fP へのポインターを返す。
72
73 Otherwise, it returns a NULL pointer, the contents of the array
74 \fIresolved_path\fP are undefined, and \fIerrno\fP is set to indicate the error.
75 .SH エラー
76 .TP 
77 \fBEACCES\fP
78 パスのディレクトリ部分に、読み出し許可または検索許可が与えられていない。
79 .TP 
80 \fBEINVAL\fP
81 .\" (In libc5 this would just cause a segfault.)
82 \fIpath\fP が NULL である。 (バージョン 2.3 より前の glibc では、 \fIresolved_path\fP が NULL
83 の場合にもこのエラーが返される。)
84 .TP 
85 \fBEIO\fP
86 ファイルシステムを読むときに、I/Oエラーが起こった。
87 .TP 
88 \fBELOOP\fP
89 パス名の変換にあたり、解決すべきシンボリック・リンクの数が多過ぎた。
90 .TP 
91 \fBENAMETOOLONG\fP
92 パス名の一要素の文字数が \fBNAME_MAX\fP を越えている、またはパス名全体の文字数が \fBPATH_MAX\fP を越えている。
93 .TP 
94 \fBENOENT\fP
95 指定されたファイルが存在しない。
96 .TP 
97 \fBENOTDIR\fP
98 パスのディレクトリ要素が、ディレクトリでない。
99 .SH バージョン
100 On Linux, this function appeared in libc 4.5.21.
101 .SH 準拠
102 4.4BSD, POSIX.1\-2001.
103
104 POSIX.1\-2001 では \fIresolved_path\fP が NULL の場合の動作は実装に依存するとしている。 POSIX.1\-2008
105 では、このマニュアルページに書かれている動作が規定されている。
106 .SH 注意
107 In 4.4BSD and Solaris, the limit on the pathname length is \fBMAXPATHLEN\fP
108 (found in \fI<sys/param.h>\fP).  SUSv2 prescribes \fBPATH_MAX\fP and
109 \fBNAME_MAX\fP, as found in \fI<limits.h>\fP or provided by the
110 \fBpathconf\fP(3)  function.  A typical source fragment would be
111 .LP
112 .in +4n
113 .nf
114 #ifdef PATH_MAX
115   path_max = PATH_MAX;
116 #else
117   path_max = pathconf(path, _PC_PATH_MAX);
118   if (path_max <= 0)
119          path_max = 4096;
120 #endif
121 .fi
122 .in
123 .LP
124 (バグの章も参照のこと。)
125 .LP
126 .\"     2012-05-05, According to Casper Dik, the statement about
127 .\"     Solaris was not true at least as far back as 1997, and
128 .\"     may never have been true.
129 .\"
130 .\" The 4.4BSD, Linux and SUSv2 versions always return an absolute
131 .\" pathname.
132 .\" Solaris may return a relative pathname when the
133 .\" .I path
134 .\" argument is relative.
135 \fBrealpath\fP() のプロトタイプ宣言は、 libc4 と libc5 では
136 \fI<unistd.h>\fP にあるが、それ以外の環境ではいずれも
137 \fI<stdlib.h>\fP にある。
138 .SS "GNU extensions"
139 If the call fails with either \fBEACCES\fP or \fBENOENT\fP and \fIresolved_path\fP is
140 not NULL, then the prefix of \fIpath\fP that is not readable or does not exist
141 is returned in \fIresolved_path\fP.
142 .SH バグ
143 この関数の POSIX.1\-2001 版は、設計段階から問題がある。 出力バッファ \fIresolved_path\fP
144 の適切なサイズを決定することができないからである。 POSIX.1\-2001 ではバッファ・サイズとして \fBPATH_MAX\fP
145 は十分だとされているが、 \fBPATH_MAX\fP は定義済の定数である必要はなく、 \fBpathconf\fP(3)
146 を使って得られる値であってもよいことになっている。 \fBpathconf\fP(3)  からバッファ・サイズを取得したとしても必ずしも十分ではない。
147 なぜなら、POSIX で警告されているように、 \fBpathconf\fP(3)  の返り値が大き過ぎて適切にメモリを確保することができない
148 かもしれない一方で、 \fBpathconf\fP(3)  は \fBPATH_MAX\fP に制限がないことを示す \-1 を返すかもしれないからである。
149 \fIresolved_path\ ==\ NULL\fP の機能を使うと、この設計上の問題を回避することができる。 この機能は POSIX.1\-2001
150 では標準化されていないが、 POSIX.1\-2008 では標準化されている。
151 .LP
152 The libc4 and libc5 implementation contained a buffer overflow (fixed in
153 libc\-5.4.13).  Thus, set\-user\-ID programs like \fBmount\fP(8)  needed a private
154 version.
155 .SH 関連項目
156 \fBreadlink\fP(2), \fBcanonicalize_file_name\fP(3), \fBgetcwd\fP(3), \fBpathconf\fP(3),
157 \fBsysconf\fP(3)
158 .SH この文書について
159 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.50 の一部
160 である。プロジェクトの説明とバグ報告に関する情報は
161 http://www.kernel.org/doc/man\-pages/ に書かれている。