summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/realpath.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/realpath.3')
-rw-r--r--src/lib/libc/stdlib/realpath.376
1 files changed, 40 insertions, 36 deletions
diff --git a/src/lib/libc/stdlib/realpath.3 b/src/lib/libc/stdlib/realpath.3
index 9d8b1ff2ce..68ed088161 100644
--- a/src/lib/libc/stdlib/realpath.3
+++ b/src/lib/libc/stdlib/realpath.3
@@ -12,11 +12,7 @@
12.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the 13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution. 14.\" documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software 15.\" 3. Neither the name of the University nor the names of its contributors
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software 16.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission. 17.\" without specific prior written permission.
22.\" 18.\"
@@ -32,20 +28,19 @@
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE. 29.\" SUCH DAMAGE.
34.\" 30.\"
35.\" from: @(#)realpath.3 8.2 (Berkeley) 2/16/94 31.\" $OpenBSD: realpath.3,v 1.17 2011/07/24 22:29:05 jmc Exp $
36.\" $Id: realpath.3,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $
37.\" 32.\"
38.Dd "February 16, 1994" 33.Dd $Mdocdate: July 24 2011 $
39.Dt REALPATH 3 34.Dt REALPATH 3
40.Os 35.Os
41.Sh NAME 36.Sh NAME
42.Nm realpath 37.Nm realpath
43.Nd returns the canonicalized absolute pathname 38.Nd returns the canonicalized absolute pathname
44.Sh SYNOPSIS 39.Sh SYNOPSIS
45.Fd #include <sys/param.h> 40.Fd #include <limits.h>
46.Fd #include <stdlib.h> 41.Fd #include <stdlib.h>
47.Ft "char *" 42.Ft "char *"
48.Fn realpath "const char *pathname" "char resolvedname[MAXPATHLEN]" 43.Fn realpath "const char *pathname" "char *resolved"
49.Sh DESCRIPTION 44.Sh DESCRIPTION
50The 45The
51.Fn realpath 46.Fn realpath
@@ -57,18 +52,18 @@ and
57.Pa /../ 52.Pa /../
58in 53in
59.Fa pathname , 54.Fa pathname ,
60and copies the resulting absolute pathname into 55and copies the resulting absolute pathname into the memory referenced by
61the memory referenced by 56.Fa resolved .
62.Fa resolvedname .
63The 57The
64.Fa resolvedname 58.Fa resolved
65argument 59argument
66.Em must 60.Em must
67refer to a buffer capable of storing at least 61refer to a buffer capable of storing at least
68.Dv MAXPATHLEN 62.Dv PATH_MAX
69characters. 63characters, or be
64.Dv NULL .
70.Pp 65.Pp
71The 66The
72.Fn realpath 67.Fn realpath
73function will resolve both absolute and relative paths 68function will resolve both absolute and relative paths
74and return the absolute pathname corresponding to 69and return the absolute pathname corresponding to
@@ -78,33 +73,49 @@ All but the last component of
78must exist when 73must exist when
79.Fn realpath 74.Fn realpath
80is called. 75is called.
81.Sh "RETURN VALUES" 76.Sh RETURN VALUES
82The 77The
83.Fn realpath 78.Fn realpath
84function returns 79function returns
85.Fa resolved_name 80.Fa resolved
86on success. 81on success.
82If
83.Fa resolved
84is
85.Dv NULL
86and no error occurred, then
87.Fa realpath
88returns a NUL-terminated string in a newly allocated buffer.
87If an error occurs, 89If an error occurs,
88.Fn realpath 90.Fn realpath
89returns 91returns
90.Dv NULL , 92.Dv NULL
91and 93and the contents of
92.Fa resolved_name 94.Fa resolved
93contains the pathname which caused the problem. 95are undefined.
94.Sh ERRORS 96.Sh ERRORS
95The function 97The function
96.Fn realpath 98.Fn realpath
97may fail and set the external variable 99may fail and set the external variable
98.Va errno 100.Va errno
99for any of the errors specified for the library functions 101for any of the errors specified for the library functions
100.Xr chdir 2 ,
101.Xr close 2 ,
102.Xr fchdir 2 ,
103.Xr lstat 2 , 102.Xr lstat 2 ,
104.Xr open 2 , 103.Xr readlink 2 ,
105.Xr readlink 2
106and 104and
107.Xr getcwd 3 . 105.Xr getcwd 3 .
106.Sh SEE ALSO
107.Xr readlink 1 ,
108.Xr getcwd 3
109.Sh STANDARDS
110The
111.Fn realpath
112function conforms to
113.St -p1003.1-2008 .
114.Sh HISTORY
115The
116.Fn realpath
117function call first appeared in
118.Bx 4.4 .
108.Sh CAVEATS 119.Sh CAVEATS
109This implementation of 120This implementation of
110.Fn realpath 121.Fn realpath
@@ -114,13 +125,6 @@ The
114version always returns absolute pathnames, 125version always returns absolute pathnames,
115whereas the Solaris implementation will, 126whereas the Solaris implementation will,
116under certain circumstances, return a relative 127under certain circumstances, return a relative
117.Fa resolved_path 128.Fa resolved
118when given a relative 129when given a relative
119.Fa pathname . 130.Fa pathname .
120.Sh "SEE ALSO"
121.Xr getcwd 3
122.Sh HISTORY
123The
124.Fn realpath
125function call first appeared in
126.Bx 4.4 .