OSDN Git Service

bb88ab14100450df79fdbe50eda15cec333c80ea
[linuxjm/LDP_man-pages.git] / release / man3 / realpath.3
1 .\" Copyright (C), 1994, Graeme W. Wilford. (Wilf.)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Rewritten old page, 990824, aeb@cwi.nl
24 .\" 2004-12-14, mtk, added discussion of resolved_path == NULL
25 .\"
26 .\" Japanese Version Copyright (c) 1998 SHOJI Yasushi all rights reserved.
27 .\" Translated 1998-03-22, SHOJI Yasushi <yashi@yashi.com>
28 .\" Updated 1999-03-07, Shouichi Saito
29 .\" Updated 2003-01-17, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
30 .\" Updated 2005-02-27, Akihiro MOTOKI
31 .\" Updated 2005-09-06, Akihiro MOTOKI
32 .\" Updated 2009-04-24, Akihiro MOTOKI, LDP v3.20
33 .\"
34 .\"WORD: bounded        À©¸Â¤¬¤Ê¤¤
35 .\"
36 .TH REALPATH 3  2010-09-20 "" "Linux Programmer's Manual"
37 .SH Ì¾Á°
38 realpath \- Àµµ¬²½¤µ¤ì¤¿ÀäÂХѥ¹Ì¾¤òÊÖ¤¹
39 .SH ½ñ¼°
40 .nf
41 .B #include <limits.h>
42 .B #include <stdlib.h>
43 .sp
44 .BI "char *realpath(const char *" path ", char *" resolved_path );
45 .fi
46 .sp
47 .in -4n
48 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
49 .RB ( feature_test_macros (7)
50 »²¾È):
51 .in
52 .sp
53 .BR realpath ():
54 .ad l
55 .RS 4
56 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
57 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
58 .RE
59 .ad
60 .SH ÀâÌÀ
61 .BR realpath ()
62 ¤Ï
63 .I path
64 ¤È¤·¤ÆÍ¿¤¨¤é¤ì¤¿ NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎóÃæ¤Î
65 ¤¹¤Ù¤Æ¤Î¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤òŸ³«¤·¡¢
66 .IR "/./" ", " "/../"
67 ¤Ë¤è¤ë»²¾È¤ä;ʬ¤Ê \(aq/\(aq
68 ¤ò²ò·è¤·¤Æ¡¢Àµµ¬²½¤µ¤ì¤¿ÀäÂХѥ¹Ì¾¤òÀ¸À®¤¹¤ë¡£
69 ÆÀ¤é¤ì¤¿ÀäÂХѥ¹Ì¾¤Ï¡¢ºÇÂç¤Ç
70 .B PATH_MAX
71 ¥Ð¥¤¥È¤Î NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤È¤·¤Æ¡¢
72 .I resolved_path
73 ¤Ë¤è¤ê»²¾È¤µ¤ì¤ë¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ë¡£
74 ·ë²Ì¤È¤·¤ÆÊÖ¤ë¥Ñ¥¹¤ÎÃæ¤Ë¤Ï¡¢¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤ä
75 .IR "/./" ", " "/../"
76 ¤È¤¤¤Ã¤¿Í×ÁǤϴޤޤì¤Ê¤¤¡£
77 .I resolved_path
78 ¤Ë NULL ¤¬»ØÄꤵ¤ì¤ë¤È¡¢
79 .BR realpath ()
80 ¤Ï
81 .BR malloc (3)
82 ¤ò»È¤Ã¤Æ²ò·è¤·¤¿¥Ñ¥¹Ì¾¤òÊÝ»ý¤¹¤ë¤¿¤á¤Î¥Ð¥Ã¥Õ¥¡¤ò
83 ºÇÂç¤Ç
84 .B PATH_MAX
85 ¥Ð¥¤¥È¤Þ¤Ç³ä¤êÅö¤Æ¡¢¤³¤Î¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
86 ¸Æ¤Ó½Ð¤·¸µ¤Ï¡¢
87 .BR free (3)
88 ¤ò»È¤Ã¤Æ¤³¤Î¥Ð¥Ã¥Õ¥¡¤ò²òÊü¤¹¤Ù¤­¤Ç¤¢¤ë¡£
89 .\" resolved_path == NULL ¤ò»ØÄꤷ¤¿¾ì¹ç¤Ç¤â¡¢²ò·è¤·¤¿¥Ñ¥¹Ì¾¤ÎŤµ¤¬
90 .\" PATH_MAX ¥Ð¥¤¥È¤òĶ¤¨¤¿¤È¤­¤Ë¤Ï¡¢realpath() ¤ÏÁ°¤ÈƱ¤¸¤¯
91 .\" ENAMETOOLONG ¤òÊÖ¤¹¡£-- MTK, Dec 04
92 .\" .SH Îò»Ë
93 .\" .BR realpath ()
94 .\" ´Ø¿ô¤Ï 4.4BSD ¤Ç½é¤á¤ÆÅо줷¤¿ (Jan-Simon Pendry ¤Ë¤è¤êÄ󶡤µ¤ì¤¿)¡£
95 .SH ÊÖ¤êÃÍ
96 ¥¨¥é¡¼¤¬¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
97 .BR realpath ()
98 ¤Ï
99 .I resolved_path
100 ¤Ø¤Î¥Ý¥¤¥ó¥¿¡¼¤òÊÖ¤¹¡£
101
102 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢¥Ì¥ë (NULL) ¥Ý¥¤¥ó¥¿¡¼¤¬Ê֤ꡢÇÛÎó
103 .I resolved_path
104 ¤ÎÆâÍƤÏÉÔÄê¤È¤Ê¤ê¡¢
105 .I errno
106 ¤Ë¥¨¥é¡¼¤ÎÆâÍƤò¼¨¤¹Ãͤ¬¥»¥Ã¥È¤µ¤ì¤ë¡£
107 .SH ¥¨¥é¡¼
108 .TP
109 .B EACCES
110 ¥Ñ¥¹¤Î¥Ç¥£¥ì¥¯¥È¥êÉôʬ¤Ë¡¢Æɤ߽Ф·µö²Ä¤Þ¤¿¤Ï¸¡º÷µö²Ä¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤¡£
111 .TP
112 .B EINVAL
113 .I path
114 ¤«
115 .I resolved_path
116 ¤Î¤¤¤º¤ì¤«¤¬ NULL ¤Ç¤¢¤ë¡£
117 (libc5 ¤Ç¤Ï¡¢¤³¤Î¤è¤¦¤Ê¾ì¹ç segfault ¤òµ¯¤³¤¹¤À¤±¤Ç¤¢¤í¤¦)
118 ⤷¡¢²¼µ­¤Î¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È¤Î¤³¤È¡£
119 .TP
120 .B EIO
121 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤òÆɤà¤È¤­¤Ë¡¢I/O¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£
122 .TP
123 .B ELOOP
124 ¥Ñ¥¹Ì¾¤ÎÊÑ´¹¤Ë¤¢¤¿¤ê¡¢²ò·è¤¹¤Ù¤­¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤Î¿ô¤¬Â¿²á¤®¤¿¡£
125 .TP
126 .B ENAMETOOLONG
127 ¥Ñ¥¹Ì¾¤Î°ìÍ×ÁǤÎʸ»ú¿ô¤¬
128 .B NAME_MAX
129 ¤ò±Û¤¨¤Æ¤¤¤ë¡¢¤Þ¤¿¤Ï¥Ñ¥¹Ì¾Á´ÂΤÎʸ»ú¿ô¤¬
130 .B PATH_MAX
131 ¤ò±Û¤¨¤Æ¤¤¤ë¡£
132 .TP
133 .B ENOENT
134 »ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤¤¡£
135 .TP
136 .B ENOTDIR
137 ¥Ñ¥¹¤Î¥Ç¥£¥ì¥¯¥È¥êÍ×ÁǤ¬¡¢¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ê¤¤¡£
138 .SH ¥Ð¡¼¥¸¥ç¥ó
139 ¤³¤Î´Ø¿ô¤¬ Linux ¤ËÅо줷¤¿¤Î¤Ï libc 4.5.21 ¤Ç¤¢¤ë¡£
140 .SH ½àµò
141 4.4BSD, POSIX.1-2001.
142
143 POSIX.1-2001 ¤Ç¤Ï
144 .I resolved_path
145 ¤¬ NULL ¤Î¾ì¹ç¤ÎÆ°ºî¤Ï¼ÂÁõ¤Ë°Í¸¤¹¤ë¤È¤·¤Æ¤¤¤ë¡£
146 POSIX.1-2008 ¤Ç¤Ï¡¢¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ë½ñ¤«¤ì¤Æ¤¤¤ëÆ°ºî¤¬µ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
147 .SH Ãí°Õ
148 4.4BSD ¤È Solaris ¤Ç¤Ï¡¢¥Ñ¥¹Ì¾¤ÎŤµ¤Î¾å¸Â¤Ï
149 (\fI<sys/param.h>\fP ¤ÎÃæ¤Ë¤¢¤ë)
150 .B MAXPATHLEN
151 ¤Ç¤¢¤ë¡£SUSv2 ¤Ç¤Ï
152 .B PATH_MAX
153 ¤È
154 .B NAME_MAX
155 ¤¬µ¬Äꤵ¤ì¤Æ¤ª¤ê¡¢
156 ¤³¤ì¤é¤Ï \fI<limits.h>\fP ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«¡¢
157 .BR pathconf (3)
158 ´Ø¿ô¤«¤éÆÀ¤é¤ì¤ë¡£°Ê²¼¤Î¤è¤¦¤Ê¥½¡¼¥¹¥³¡¼¥É¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¤¬Â¿¤¤¡£
159 .LP
160 .in +4n
161 .nf
162 #ifdef PATH_MAX
163   path_max = PATH_MAX;
164 #else
165   path_max = pathconf(path, _PC_PATH_MAX);
166   if (path_max <= 0)
167          path_max = 4096;
168 #endif
169 .fi
170 .in
171 .LP
172 (¥Ð¥°¤Î¾Ï¤â»²¾È¤Î¤³¤È¡£) 
173 .LP
174 4.4BSD¡¢Linux¡¢SUSv2 ¤Ç¤Ï¡¢ÊÖ¤êÃͤϾï¤ËÀäÂХѥ¹Ì¾¤Ç¤¢¤ë¡£
175 Solaris ¤Ç¤Ï¡¢
176 °ú¤­¿ô
177 .I path
178 ¤¬ÁêÂХѥ¹¤Î¾ì¹ç¡¢ÊÖ¤êÃͤ¬ÁêÂХѥ¹¤Ë¤Ê¤ë¤³¤È¤¬¤¢¤ë¡£
179 .BR realpath ()
180 ¤Î¥×¥í¥È¥¿¥¤¥×Àë¸À¤Ï¡¢
181 libc4 ¤È libc5 ¤Ç¤Ï \fI<unistd.h>\fP ¤Ë¤¢¤ë¤¬¡¢
182 ¤½¤ì°Ê³°¤Î´Ä¶­¤Ç¤Ï¤¤¤º¤ì¤â \fI<stdlib.h>\fP ¤Ë¤¢¤ë¡£
183 .SH ¥Ð¥°
184 ¤³¤Î´Ø¿ô¤Î POSIX.1-2001 ÈǤϡ¢Àß·×Ãʳ¬¤«¤éÌäÂ꤬¤¢¤ë¡£
185 ½ÐÎϥХåե¡
186 .I resolved_path
187 ¤ÎŬÀڤʥµ¥¤¥º¤ò·èÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
188 POSIX.1-2001 ¤Ç¤Ï¥Ð¥Ã¥Õ¥¡¡¦¥µ¥¤¥º¤È¤·¤Æ
189 .B PATH_MAX
190 ¤Ï½½Ê¬¤À¤È¤µ¤ì¤Æ¤¤¤ë¤¬¡¢
191 .B PATH_MAX
192 ¤ÏÄêµÁºÑ¤ÎÄê¿ô¤Ç¤¢¤ëɬÍפϤʤ¯¡¢
193 .BR pathconf (3)
194 ¤ò»È¤Ã¤ÆÆÀ¤é¤ì¤ëÃͤǤ¢¤Ã¤Æ¤â¤è¤¤¤³¤È¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
195 .BR pathconf (3)
196 ¤«¤é¥Ð¥Ã¥Õ¥¡¡¦¥µ¥¤¥º¤ò¼èÆÀ¤·¤¿¤È¤·¤Æ¤âɬ¤º¤·¤â½½Ê¬¤Ç¤Ï¤Ê¤¤¡£
197 ¤Ê¤¼¤Ê¤é¡¢POSIX ¤Ç·Ù¹ð¤µ¤ì¤Æ¤¤¤ë¤è¤¦¤Ë¡¢
198 .BR pathconf (3)
199 ¤ÎÊÖ¤êÃͤ¬Â礭²á¤®¤ÆŬÀڤ˥á¥â¥ê¤ò³ÎÊݤ¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤
200 ¤«¤â¤·¤ì¤Ê¤¤°ìÊý¤Ç¡¢
201 .BR pathconf (3)
202 ¤Ï
203 .B PATH_MAX
204 ¤ËÀ©¸Â¤¬¤Ê¤¤¤³¤È¤ò¼¨¤¹ \-1 ¤òÊÖ¤¹¤«¤â¤·¤ì¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
205 .I "resolved_path\ ==\ NULL"
206 ¤Îµ¡Ç½¤ò»È¤¦¤È¡¢¤³¤ÎÀß·×¾å¤ÎÌäÂê¤ò²óÈò¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
207 ¤³¤Îµ¡Ç½¤Ï POSIX.1-2001 ¤Ç¤Ïɸ½à²½¤µ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢
208 POSIX.1-2008 ¤Ç¤Ïɸ½à²½¤µ¤ì¤Æ¤¤¤ë¡£
209 .LP
210 libc4 ¤È libc5 ¤Î¼ÂÁõ¤Ï¥Ð¥Ã¥Õ¥¡¡¦¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Î²ÄǽÀ­¤ò»ý¤Ã¤Æ¤¤¤ë
211 (libc-5.4.13 ¤Ç½¤Àµ¤µ¤ì¤¿¤¬)¡£¤·¤¿¤¬¤Ã¤Æ¡¢
212 .BR mount (8)
213 ¤Î¤è¤¦¤Ê set-user-ID ¤µ¤ì¤ë¥×¥í¥°¥é¥à¤Ç¤Ï¡¢
214 ¤³¤Î´Ø¿ôÁêÅö¤Î´Ø¿ô¤ò¼«Á°¤Ç»ý¤ÄɬÍפ¬¤¢¤ë¡£
215 .SH ´ØÏ¢¹àÌÜ
216 .BR readlink (2),
217 .BR canonicalize_file_name (3),
218 .BR getcwd (3),
219 .BR pathconf (3),
220 .BR sysconf (3)