summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/realpath.3
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-04-20 10:16:44 +0000
committerkib <kib@FreeBSD.org>2010-04-20 10:16:44 +0000
commit0be03f320b674f387da392d9e4fece5b67a79ae1 (patch)
tree49cd6b92975d51b11b3034ce84d086a90b7f707b /lib/libc/stdlib/realpath.3
parentdf535bd79d3648211cc1b5783e543ab3c1bea2bc (diff)
downloadFreeBSD-src-0be03f320b674f387da392d9e4fece5b67a79ae1.zip
FreeBSD-src-0be03f320b674f387da392d9e4fece5b67a79ae1.tar.gz
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(). PR: kern/121897 [1] MFC after: 2 weeks
Diffstat (limited to 'lib/libc/stdlib/realpath.3')
-rw-r--r--lib/libc/stdlib/realpath.319
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/libc/stdlib/realpath.3 b/lib/libc/stdlib/realpath.3
index 4205a3d..371ee3b2 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,6 +83,13 @@ 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
@@ -89,6 +97,11 @@ returns
and
.Fa resolved_path
contains the pathname which caused the problem.
+If
+.Fa resolved_path
+was
+.Dv NULL ,
+then information of the failed pathname component is lost.
.Sh ERRORS
The function
.Fn realpath
OpenPOWER on IntegriCloud