diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2010-05-04 05:34:18 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2010-05-04 05:34:18 +0000 |
| commit | 14d447de525f9e398a09b0354cc7a216aa64561c (patch) | |
| tree | 8d52fe16daa7d57ea1120185988372695ae793f5 /lib/libc/stdlib/realpath.3 | |
| parent | 22df1496d2c8f9946206b721706e563bc087f795 (diff) | |
MFC r206893:
Slightly modernize realpath(3).
SUSv4 requires that implementation returns EINVAL if supplied path is NULL,
and ENOENT if path is empty string [1].
Bring prototype in conformance with SUSv4, adding restrict keywords.
Allow the resolved path buffer pointer be NULL, in which case realpath(3)
allocates storage with malloc().
MFC r206898:
Free() is not allowed to modify errno, remove safety brackets around it.
Add small optimization, do not copy a string to the buffer that is
to be freed immediately after.
MFC r206997:
Move realpath(3) prototype to a POSIX section.
MFC r206998:
Add standards section, improve wording, taking into account the handling
of NULL and changed type in declaration.
Notes
svn path=/stable/8/; revision=207599
Diffstat (limited to 'lib/libc/stdlib/realpath.3')
| -rw-r--r-- | lib/libc/stdlib/realpath.3 | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/libc/stdlib/realpath.3 b/lib/libc/stdlib/realpath.3 index 4205a3d6bbc6..aee65f7600f8 100644 --- a/lib/libc/stdlib/realpath.3 +++ b/lib/libc/stdlib/realpath.3 @@ -31,7 +31,7 @@ .\" @(#)realpath.3 8.2 (Berkeley) 2/16/94 .\" $FreeBSD$ .\" -.Dd February 16, 1994 +.Dd April 19, 2010 .Dt REALPATH 3 .Os .Sh NAME @@ -43,7 +43,7 @@ .In sys/param.h .In stdlib.h .Ft "char *" -.Fn realpath "const char *pathname" "char resolved_path[PATH_MAX]" +.Fn realpath "const char *pathname" "char *resolved_path" .Sh DESCRIPTION The .Fn realpath @@ -64,7 +64,8 @@ argument .Em must refer to a buffer capable of storing at least .Dv PATH_MAX -characters. +characters, or be +.Dv NULL . .Pp The .Fn realpath @@ -82,13 +83,22 @@ The function returns .Fa resolved_path on success. +If the function was supplied +.Dv NULL +as +.Fa resolved_path , +and operation did not cause errors, the returned value is +a null-terminated string in a buffer allocated by a call to +.Fn malloc 3 . If an error occurs, .Fn realpath returns .Dv NULL , -and +and if .Fa resolved_path -contains the pathname which caused the problem. +is not +.Dv NULL , +the array that it points to contains the pathname which caused the problem. .Sh ERRORS The function .Fn realpath @@ -113,6 +123,11 @@ when given a relative .Fa pathname . .Sh "SEE ALSO" .Xr getcwd 3 +.Sh STANDARDS +The +.Fn realpath +function conforms to +.St -p1003.1-2001 . .Sh HISTORY The .Fn realpath |
