version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
REALPATH |
|
|
2 |
!!!REALPATH |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
ERRORS |
|
|
8 |
BUGS |
|
|
9 |
HISTORY |
|
|
10 |
CONFORMING TO |
|
|
11 |
SEE ALSO |
|
|
12 |
---- |
|
|
13 |
!!NAME |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
realpath - return the canonicalized absolute pathname |
|
|
17 |
!!SYNOPSIS |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
__#include |
|
|
21 |
__''path''__, char *__''resolved_path''__); |
|
|
22 |
__ |
|
|
23 |
!!DESCRIPTION |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
__realpath__ expands all symbolic links and resolves |
|
|
27 |
references to '''/./''', '''/../''' and extra |
|
|
28 |
'''/''' characters in the null terminated string named by |
|
|
29 |
''path'' and stores the canonicalized absolute pathname |
|
|
30 |
in the buffer of size __PATH_MAX__ named by |
|
|
31 |
''resolved_path''. The resulting path will have no |
|
|
32 |
symbolic link, '''/./''' or '''/../''' |
|
|
33 |
components. |
|
|
34 |
!!RETURN VALUE |
|
|
35 |
|
|
|
36 |
|
|
|
37 |
If there is no error, it returns a pointer to the |
|
|
38 |
''resolved_path''. |
|
|
39 |
|
|
|
40 |
|
|
|
41 |
Otherwise it returns a NULL pointer, and the contents of the |
|
|
42 |
array ''resolved_path'' are undefined. The global |
|
|
43 |
variable ''errno'' is set to indicate the |
|
|
44 |
error. |
|
|
45 |
!!ERRORS |
|
|
46 |
|
|
|
47 |
|
|
|
48 |
__EACCES__ |
|
|
49 |
|
|
|
50 |
|
|
|
51 |
Read or search permission was denied for a component of the |
|
|
52 |
path prefix. |
|
|
53 |
|
|
|
54 |
|
|
|
55 |
__EINVAL__ |
|
|
56 |
|
|
|
57 |
|
|
|
58 |
Either ''path'' or ''resolved_path'' is NULL. (In |
|
|
59 |
libc5 this would just cause a segfault.) |
|
|
60 |
|
|
|
61 |
|
|
|
62 |
__EIO__ |
|
|
63 |
|
|
|
64 |
|
|
|
65 |
An I/O error occurred while reading from the file |
|
|
66 |
system. |
|
|
67 |
|
|
|
68 |
|
|
|
69 |
__ELOOP__ |
|
|
70 |
|
|
|
71 |
|
|
|
72 |
Too many symbolic links were encountered in translating the |
|
|
73 |
pathname. |
|
|
74 |
|
|
|
75 |
|
|
|
76 |
__ENAMETOOLONG__ |
|
|
77 |
|
|
|
78 |
|
|
|
79 |
A component of a path name exceeded __NAME_MAX__ |
|
|
80 |
characters, or an entire path name exceeded __PATH_MAX__ |
|
|
81 |
characters. |
|
|
82 |
|
|
|
83 |
|
|
|
84 |
__ENOENT__ |
|
|
85 |
|
|
|
86 |
|
|
|
87 |
The named file does not exist. |
|
|
88 |
|
|
|
89 |
|
|
|
90 |
__ENOTDIR__ |
|
|
91 |
|
|
|
92 |
|
|
|
93 |
A component of the path prefix is not a |
|
|
94 |
directory. |
|
|
95 |
!!BUGS |
|
|
96 |
|
|
|
97 |
|
|
|
98 |
The libc4 and libc5 implementation contains a buffer |
|
|
99 |
overflow (fixed in libc-5.4.13). Thus, suid programs like |
|
|
100 |
mount need a private version. |
|
|
101 |
|
|
|
102 |
|
|
|
103 |
The length of the output buffer should have been an |
|
|
104 |
additional parameter, especially since pathconf(3) |
|
|
105 |
warns that the result of ''pathconf()'' may be huge and |
|
|
106 |
unsuitable for mallocing memory. |
|
|
107 |
!!HISTORY |
|
|
108 |
|
|
|
109 |
|
|
|
110 |
The __realpath__ function first appeared in BSD 4.4, |
|
|
111 |
contributed by Jan-Simon Pendry. In Linux this function |
|
|
112 |
appears in libc 4.5.21. |
|
|
113 |
!!CONFORMING TO |
|
|
114 |
|
|
|
115 |
|
|
|
116 |
In BSD 4.4 and Solaris the limit on the pathname length is |
|
|
117 |
MAXPATHLEN (found in |
|
|
118 |
pathconf()'' |
|
|
119 |
function. A typical source fragment would be |
|
|
120 |
|
|
|
121 |
|
|
|
122 |
#ifdef PATH_MAX |
|
|
123 |
path_max = PATH_MAX; |
|
|
124 |
#else |
|
|
125 |
path_max = pathconf (path, _PC_PATH_MAX); |
|
|
126 |
if (path_max |
|
|
127 |
|
|
|
128 |
|
|
|
129 |
The BSD 4.4, Linux and SUSv2 versions always return an |
|
|
130 |
absolute path name. Solaris may return a relative path name |
|
|
131 |
when the ''path'' argument is relative. The prototype of |
|
|
132 |
__realpath__ is given in |
|
|
133 |
__ |
|
|
134 |
!!SEE ALSO |
|
|
135 |
|
|
|
136 |
|
|
|
137 |
readlink(2), getcwd(3), pathconf(3), |
|
|
138 |
sysconf(3) |
|
|
139 |
---- |