OSDN Git Service

Update draft pages
[linuxjm/LDP_man-pages.git] / draft / 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 .\"
34 .\" Japanese Version Copyright (c) 1998 SHOJI Yasushi all rights reserved.
35 .\" Translated 1998-03-22, SHOJI Yasushi <yashi@yashi.com>
36 .\" Updated 1999-03-07, Shouichi Saito
37 .\" Updated 2003-01-17, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
38 .\" Updated 2005-02-27, Akihiro MOTOKI
39 .\" Updated 2005-09-06, Akihiro MOTOKI
40 .\" Updated 2009-04-24, Akihiro MOTOKI, LDP v3.20
41 .\" Updated 2012-05-29, Akihiro MOTOKI <amotoki@gmail.com>
42 .\" Updated 2013-03-27, Akihiro MOTOKI <amotoki@gmail.com>
43 .\"
44 .TH REALPATH 3 2014\-10\-02 "" "Linux Programmer's Manual"
45 .SH 名前
46 realpath \- 正規化された絶対パス名を返す
47 .SH 書式
48 .nf
49 \fB#include <limits.h>\fP
50 \fB#include <stdlib.h>\fP
51 .sp
52 \fBchar *realpath(const char *\fP\fIpath\fP\fB, char *\fP\fIresolved_path\fP\fB);\fP
53 .fi
54 .sp
55 .in -4n
56 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
57 .in
58 .sp
59 \fBrealpath\fP():
60 .ad l
61 .RS 4
62 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
63 .RE
64 .ad
65 .SH 説明
66 \fBrealpath\fP()  は \fIpath\fP として与えられたヌル終端された文字列中の すべてのシンボリックリンクを展開し、 \fI/./\fP,
67 \fI/../\fP による参照や余分な \(aq/\(aq を解決して、正規化された絶対パス名を生成する。 得られた絶対パス名は、最大で
68 \fBPATH_MAX\fP バイトのヌル終端された文字列として、 \fIresolved_path\fP により参照されるバッファに格納される。
69 結果として返るパスの中には、シンボリックリンクや \fI/./\fP, \fI/../\fP といった要素は含まれない。
70
71 .\" Even if we use resolved_path == NULL, then realpath() will still
72 .\" return ENAMETOOLONG if the resolved pathname would exceed PATH_MAX
73 .\" bytes -- MTK, Dec 04
74 .\" .SH HISTORY
75 .\" The
76 .\" .BR realpath ()
77 .\" function first appeared in 4.4BSD, contributed by Jan-Simon Pendry.
78 \fIresolved_path\fP に NULL が指定されると、 \fBrealpath\fP()  は \fBmalloc\fP(3)
79 を使って解決したパス名を保持するためのバッファを 最大で \fBPATH_MAX\fP バイトまで割り当て、このバッファへのポインタを返す。 呼び出し元は、
80 \fBfree\fP(3)  を使ってこのバッファを解放すべきである。
81 .SH 返り値
82 エラーがなかった場合、 \fBrealpath\fP()  は \fIresolved_path\fP へのポインターを返す。
83
84 それ以外の場合は NULL が返り、配列 \fIresolved_path\fP の内容は不定となり、 \fIerrno\fP
85 にエラーの内容を示す値がセットされる。
86 .SH エラー
87 .TP 
88 \fBEACCES\fP
89 パスのディレクトリ部分に、読み出し許可または検索許可が与えられていない。
90 .TP 
91 \fBEINVAL\fP
92 .\" (In libc5 this would just cause a segfault.)
93 \fIpath\fP が NULL である。 (バージョン 2.3 より前の glibc では、 \fIresolved_path\fP が NULL
94 の場合にもこのエラーが返される。)
95 .TP 
96 \fBEIO\fP
97 ファイルシステムを読むときに、I/Oエラーが起こった。
98 .TP 
99 \fBELOOP\fP
100 パス名の変換にあたり、解決すべきシンボリック・リンクの数が多過ぎた。
101 .TP 
102 \fBENAMETOOLONG\fP
103 パス名の一要素の文字数が \fBNAME_MAX\fP を越えている、またはパス名全体の文字数が \fBPATH_MAX\fP を越えている。
104 .TP 
105 \fBENOENT\fP
106 指定されたファイルが存在しない。
107 .TP 
108 \fBENOTDIR\fP
109 パスのディレクトリ要素が、ディレクトリでない。
110 .SH 準拠
111 4.4BSD, POSIX.1\-2001.
112
113 POSIX.1\-2001 では \fIresolved_path\fP が NULL の場合の動作は実装に依存するとしている。 POSIX.1\-2008
114 では、このマニュアルページに書かれている動作が規定されている。
115 .SH 注意
116 4.4BSD と Solaris では、パス名の長さの上限は (\fI<sys/param.h>\fP の中にある)
117 \fBMAXPATHLEN\fP である。SUSv2 では \fBPATH_MAX\fP と \fBNAME_MAX\fP が規定されており、 これらは
118 \fI<limits.h>\fP で定義されているか、 \fBpathconf\fP(3)
119 関数から得られる。以下のようなソースコードになっていることが多い。
120 .LP
121 .in +4n
122 .nf
123 #ifdef PATH_MAX
124   path_max = PATH_MAX;
125 #else
126   path_max = pathconf(path, _PC_PATH_MAX);
127   if (path_max <= 0)
128          path_max = 4096;
129 #endif
130 .fi
131 .in
132 .LP
133 (バグの章も参照のこと。)
134 .LP
135 .\"     2012-05-05, According to Casper Dik, the statement about
136 .\"     Solaris was not true at least as far back as 1997, and
137 .\"     may never have been true.
138 .\"
139 .\" The 4.4BSD, Linux and SUSv2 versions always return an absolute
140 .\" pathname.
141 .\" Solaris may return a relative pathname when the
142 .\" .I path
143 .\" argument is relative.
144 .\" The prototype of
145 .\" .BR realpath ()
146 .\" is given in \fI<unistd.h>\fP in libc4 and libc5,
147 .\" but in \fI<stdlib.h>\fP everywhere else.
148 .SS "GNU による拡張"
149 呼び出しが \fBEACCES\fP か \fBENOENT\fP で失敗し \fIresolved_path\fP が NULL
150 でない場合、読むことができない、もしくは存在しない \fIpath\fP のディレクトリ要素 (prefix) が \fIresolved_path\fP
151 で返される。
152 .SH バグ
153 .\" .LP
154 .\" The libc4 and libc5 implementation contained a buffer overflow
155 .\" (fixed in libc-5.4.13).
156 .\" Thus, set-user-ID programs like
157 .\" .BR mount (8)
158 .\" needed a private version.
159 この関数の POSIX.1\-2001 版は、設計段階から問題がある。 出力バッファ \fIresolved_path\fP
160 の適切なサイズを決定することができないからである。 POSIX.1\-2001 ではバッファ・サイズとして \fBPATH_MAX\fP
161 は十分だとされているが、 \fBPATH_MAX\fP は定義済の定数である必要はなく、 \fBpathconf\fP(3)
162 を使って得られる値であってもよいことになっている。 \fBpathconf\fP(3)  からバッファ・サイズを取得したとしても必ずしも十分ではない。
163 なぜなら、POSIX で警告されているように、 \fBpathconf\fP(3)  の返り値が大き過ぎて適切にメモリを確保することができない
164 かもしれない一方で、 \fBpathconf\fP(3)  は \fBPATH_MAX\fP に制限がないことを示す \-1 を返すかもしれないからである。
165 \fIresolved_path\ ==\ NULL\fP の機能を使うと、この設計上の問題を回避することができる。 この機能は POSIX.1\-2001
166 では標準化されていないが、 POSIX.1\-2008 では標準化されている。
167 .SH 関連項目
168 \fBrealpath\fP(1), \fBreadlink\fP(2), \fBcanonicalize_file_name\fP(3), \fBgetcwd\fP(3),
169 \fBpathconf\fP(3), \fBsysconf\fP(3)
170 .SH この文書について
171 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.78 の一部
172 である。プロジェクトの説明とバグ報告に関する情報は
173 http://www.kernel.org/doc/man\-pages/ に書かれている。