OSDN Git Service

bea1b201e79cd4037bf2519f872c9d3cb5dea360
[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  2009-02-23 "" "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 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
55 .SH ÀâÌÀ
56 .BR realpath ()
57 ¤Ï
58 .I path
59 ¤È¤·¤ÆÍ¿¤¨¤é¤ì¤¿ NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎóÃæ¤Î
60 ¤¹¤Ù¤Æ¤Î¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤òŸ³«¤·¡¢
61 .IR "/./" ", " "/../"
62 ¤Ë¤è¤ë»²¾È¤ä;ʬ¤Ê \(aq/\(aq
63 ¤ò²ò·è¤·¤Æ¡¢Àµµ¬²½¤µ¤ì¤¿ÀäÂХѥ¹Ì¾¤òÀ¸À®¤¹¤ë¡£
64 ÆÀ¤é¤ì¤¿ÀäÂХѥ¹Ì¾¤Ï¡¢ºÇÂç¤Ç
65 .B PATH_MAX
66 ¥Ð¥¤¥È¤Î NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤È¤·¤Æ¡¢
67 .I resolved_path
68 ¤Ë¤è¤ê»²¾È¤µ¤ì¤ë¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ë¡£
69 ·ë²Ì¤È¤·¤ÆÊÖ¤ë¥Ñ¥¹¤ÎÃæ¤Ë¤Ï¡¢¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤ä
70 .IR "/./" ", " "/../"
71 ¤È¤¤¤Ã¤¿Í×ÁǤϴޤޤì¤Ê¤¤¡£
72 .I resolved_path
73 ¤Ë NULL ¤¬»ØÄꤵ¤ì¤ë¤È¡¢
74 .BR realpath ()
75 ¤Ï
76 .BR malloc (3)
77 ¤ò»È¤Ã¤Æ²ò·è¤·¤¿¥Ñ¥¹Ì¾¤òÊÝ»ý¤¹¤ë¤¿¤á¤Î¥Ð¥Ã¥Õ¥¡¤ò
78 ºÇÂç¤Ç
79 .B PATH_MAX
80 ¥Ð¥¤¥È¤Þ¤Ç³ä¤êÅö¤Æ¡¢¤³¤Î¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
81 ¸Æ¤Ó½Ð¤·¸µ¤Ï¡¢
82 .BR free (3)
83 ¤ò»È¤Ã¤Æ¤³¤Î¥Ð¥Ã¥Õ¥¡¤ò²òÊü¤¹¤Ù¤­¤Ç¤¢¤ë¡£
84 .\" resolved_path == NULL ¤ò»ØÄꤷ¤¿¾ì¹ç¤Ç¤â¡¢²ò·è¤·¤¿¥Ñ¥¹Ì¾¤ÎŤµ¤¬
85 .\" PATH_MAX ¥Ð¥¤¥È¤òĶ¤¨¤¿¤È¤­¤Ë¤Ï¡¢realpath() ¤ÏÁ°¤ÈƱ¤¸¤¯
86 .\" ENAMETOOLONG ¤òÊÖ¤¹¡£-- MTK, Dec 04
87 .\" .SH Îò»Ë
88 .\" .BR realpath ()
89 .\" ´Ø¿ô¤Ï 4.4BSD ¤Ç½é¤á¤ÆÅо줷¤¿ (Jan-Simon Pendry ¤Ë¤è¤êÄ󶡤µ¤ì¤¿)¡£
90 .SH ÊÖ¤êÃÍ
91 ¥¨¥é¡¼¤¬¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
92 .BR realpath ()
93 ¤Ï
94 .I resolved_path
95 ¤Ø¤Î¥Ý¥¤¥ó¥¿¡¼¤òÊÖ¤¹¡£
96
97 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢¥Ì¥ë (NULL) ¥Ý¥¤¥ó¥¿¡¼¤¬Ê֤ꡢÇÛÎó
98 .I resolved_path
99 ¤ÎÆâÍƤÏÉÔÄê¤È¤Ê¤ê¡¢
100 .I errno
101 ¤Ë¥¨¥é¡¼¤ÎÆâÍƤò¼¨¤¹Ãͤ¬¥»¥Ã¥È¤µ¤ì¤ë¡£
102 .SH ¥¨¥é¡¼
103 .TP
104 .B EACCES
105 ¥Ñ¥¹¤Î¥Ç¥£¥ì¥¯¥È¥êÉôʬ¤Ë¡¢Æɤ߽Ф·µö²Ä¤Þ¤¿¤Ï¸¡º÷µö²Ä¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤¡£
106 .TP
107 .B EINVAL
108 .I path
109 ¤«
110 .I resolved_path
111 ¤Î¤¤¤º¤ì¤«¤¬ NULL ¤Ç¤¢¤ë¡£
112 (libc5 ¤Ç¤Ï¡¢¤³¤Î¤è¤¦¤Ê¾ì¹ç segfault ¤òµ¯¤³¤¹¤À¤±¤Ç¤¢¤í¤¦)
113 ⤷¡¢²¼µ­¤Î¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È¤Î¤³¤È¡£
114 .TP
115 .B EIO
116 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤òÆɤà¤È¤­¤Ë¡¢I/O¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£
117 .TP
118 .B ELOOP
119 ¥Ñ¥¹Ì¾¤ÎÊÑ´¹¤Ë¤¢¤¿¤ê¡¢²ò·è¤¹¤Ù¤­¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤Î¿ô¤¬Â¿²á¤®¤¿¡£
120 .TP
121 .B ENAMETOOLONG
122 ¥Ñ¥¹Ì¾¤Î°ìÍ×ÁǤÎʸ»ú¿ô¤¬
123 .B NAME_MAX
124 ¤ò±Û¤¨¤Æ¤¤¤ë¡¢¤Þ¤¿¤Ï¥Ñ¥¹Ì¾Á´ÂΤÎʸ»ú¿ô¤¬
125 .B PATH_MAX
126 ¤ò±Û¤¨¤Æ¤¤¤ë¡£
127 .TP
128 .B ENOENT
129 »ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤¤¡£
130 .TP
131 .B ENOTDIR
132 ¥Ñ¥¹¤Î¥Ç¥£¥ì¥¯¥È¥êÍ×ÁǤ¬¡¢¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ê¤¤¡£
133 .SH ¥Ð¡¼¥¸¥ç¥ó
134 ¤³¤Î´Ø¿ô¤¬ Linux ¤ËÅо줷¤¿¤Î¤Ï libc 4.5.21 ¤Ç¤¢¤ë¡£
135 .SH ½àµò
136 4.4BSD, POSIX.1-2001.
137
138 POSIX.1-2001 ¤Ç¤Ï
139 .I resolved_path
140 ¤¬ NULL ¤Î¾ì¹ç¤ÎÆ°ºî¤Ï¼ÂÁõ¤Ë°Í¸¤¹¤ë¤È¤·¤Æ¤¤¤ë¡£
141 POSIX.1-2008 ¤Ç¤Ï¡¢¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ë½ñ¤«¤ì¤Æ¤¤¤ëÆ°ºî¤¬µ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
142 .SH Ãí°Õ
143 4.4BSD ¤È Solaris ¤Ç¤Ï¡¢¥Ñ¥¹Ì¾¤ÎŤµ¤Î¾å¸Â¤Ï
144 (\fI<sys/param.h>\fP ¤ÎÃæ¤Ë¤¢¤ë)
145 .B MAXPATHLEN
146 ¤Ç¤¢¤ë¡£SUSv2 ¤Ç¤Ï
147 .B PATH_MAX
148 ¤È
149 .B NAME_MAX
150 ¤¬µ¬Äꤵ¤ì¤Æ¤ª¤ê¡¢
151 ¤³¤ì¤é¤Ï \fI<limits.h>\fP ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«¡¢
152 .BR pathconf (3)
153 ´Ø¿ô¤«¤éÆÀ¤é¤ì¤ë¡£°Ê²¼¤Î¤è¤¦¤Ê¥½¡¼¥¹¥³¡¼¥É¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¤¬Â¿¤¤¡£
154 .LP
155 .in +4n
156 .nf
157 #ifdef PATH_MAX
158   path_max = PATH_MAX;
159 #else
160   path_max = pathconf(path, _PC_PATH_MAX);
161   if (path_max <= 0)
162          path_max = 4096;
163 #endif
164 .fi
165 .in
166 .LP
167 (¥Ð¥°¤Î¾Ï¤â»²¾È¤Î¤³¤È¡£) 
168 .LP
169 4.4BSD¡¢Linux¡¢SUSv2 ¤Ç¤Ï¡¢ÊÖ¤êÃͤϾï¤ËÀäÂХѥ¹Ì¾¤Ç¤¢¤ë¡£
170 Solaris ¤Ç¤Ï¡¢
171 °ú¤­¿ô
172 .I path
173 ¤¬ÁêÂХѥ¹¤Î¾ì¹ç¡¢ÊÖ¤êÃͤ¬ÁêÂХѥ¹¤Ë¤Ê¤ë¤³¤È¤¬¤¢¤ë¡£
174 .BR realpath ()
175 ¤Î¥×¥í¥È¥¿¥¤¥×Àë¸À¤Ï¡¢
176 libc4 ¤È libc5 ¤Ç¤Ï \fI<unistd.h>\fP ¤Ë¤¢¤ë¤¬¡¢
177 ¤½¤ì°Ê³°¤Î´Ä¶­¤Ç¤Ï¤¤¤º¤ì¤â \fI<stdlib.h>\fP ¤Ë¤¢¤ë¡£
178 .SH ¥Ð¥°
179 ¤³¤Î´Ø¿ô¤Î POSIX.1-2001 ÈǤϡ¢Àß·×Ãʳ¬¤«¤éÌäÂ꤬¤¢¤ë¡£
180 ½ÐÎϥХåե¡
181 .I resolved_path
182 ¤ÎŬÀڤʥµ¥¤¥º¤ò·èÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
183 POSIX.1-2001 ¤Ç¤Ï¥Ð¥Ã¥Õ¥¡¡¦¥µ¥¤¥º¤È¤·¤Æ
184 .B PATH_MAX
185 ¤Ï½½Ê¬¤À¤È¤µ¤ì¤Æ¤¤¤ë¤¬¡¢
186 .B PATH_MAX
187 ¤ÏÄêµÁºÑ¤ÎÄê¿ô¤Ç¤¢¤ëɬÍפϤʤ¯¡¢
188 .BR pathconf (3)
189 ¤ò»È¤Ã¤ÆÆÀ¤é¤ì¤ëÃͤǤ¢¤Ã¤Æ¤â¤è¤¤¤³¤È¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
190 .BR pathconf (3)
191 ¤«¤é¥Ð¥Ã¥Õ¥¡¡¦¥µ¥¤¥º¤ò¼èÆÀ¤·¤¿¤È¤·¤Æ¤âɬ¤º¤·¤â½½Ê¬¤Ç¤Ï¤Ê¤¤¡£
192 ¤Ê¤¼¤Ê¤é¡¢POSIX ¤Ç·Ù¹ð¤µ¤ì¤Æ¤¤¤ë¤è¤¦¤Ë¡¢
193 .BR pathconf (3)
194 ¤ÎÊÖ¤êÃͤ¬Â礭²á¤®¤ÆŬÀڤ˥á¥â¥ê¤ò³ÎÊݤ¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤
195 ¤«¤â¤·¤ì¤Ê¤¤°ìÊý¤Ç¡¢
196 .BR pathconf (3)
197 ¤Ï
198 .B PATH_MAX
199 ¤ËÀ©¸Â¤¬¤Ê¤¤¤³¤È¤ò¼¨¤¹ \-1 ¤òÊÖ¤¹¤«¤â¤·¤ì¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
200 .I "resolved_path\ ==\ NULL"
201 ¤Îµ¡Ç½¤ò»È¤¦¤È¡¢¤³¤ÎÀß·×¾å¤ÎÌäÂê¤ò²óÈò¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
202 ¤³¤Îµ¡Ç½¤Ï POSIX.1-2001 ¤Ç¤Ïɸ½à²½¤µ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢
203 POSIX.1-2008 ¤Ç¤Ïɸ½à²½¤µ¤ì¤Æ¤¤¤ë¡£
204 .LP
205 libc4 ¤È libc5 ¤Î¼ÂÁõ¤Ï¥Ð¥Ã¥Õ¥¡¡¦¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Î²ÄǽÀ­¤ò»ý¤Ã¤Æ¤¤¤ë
206 (libc-5.4.13 ¤Ç½¤Àµ¤µ¤ì¤¿¤¬)¡£¤·¤¿¤¬¤Ã¤Æ¡¢
207 .BR mount (8)
208 ¤Î¤è¤¦¤Ê set-user-ID ¤µ¤ì¤ë¥×¥í¥°¥é¥à¤Ç¤Ï¡¢
209 ¤³¤Î´Ø¿ôÁêÅö¤Î´Ø¿ô¤ò¼«Á°¤Ç»ý¤ÄɬÍפ¬¤¢¤ë¡£
210 .SH ´ØÏ¢¹àÌÜ
211 .BR readlink (2),
212 .BR canonicalize_file_name (3),
213 .BR getcwd (3),
214 .BR pathconf (3),
215 .BR sysconf (3)