a /./ and
a /../ in .Fa pathname , and copies the resulting absolute pathname into the memory referenced by .Fa resolvedname . The .Fa resolvedname argument .Em must refer to a buffer capable of storing at least .Dv MAXPATHLEN characters, or be .Dv NULL .
p
The
.Fn realpath
function will resolve both absolute and relative paths
and return the absolute pathname corresponding to
.Fa pathname .
.Sh RETURN VALUES
If
.Fa resolvedname
is
.Dv NULL ,
it will be allocated and the returned pointer can be deallocated using
.Xr free 3 .
The
.Fn realpath
function returns
.Fa resolvedname
on success.
If an error occurs,
.Fn realpath
returns
.Dv NULL ,
and if
.Fa resolvedname
was not allocated by
.Fn realpath ,
it will contain the pathname which caused the problem.
.Sh ERRORS
The function
.Fn realpath
may fail and set the external variable
.Va errno
for any of the errors specified for the library functions
First sorted by section, then by name.
.Xr lstat 2 ,
.Xr readlink 2 ,
.Xr getcwd 3
and
.Xr malloc 3 .
p In addition, the following errors may be reported: l -tag -width Er t Bq Er EINVAL The value of the .Fa pathname argument is .Dv NULL . t Bq Er ELOOP Too many symbolic links were encountered in translating the .Fa pathname . t Bq Er ENAMETOOLONG The resulting absolute pathname exceeds .Dv MAXPATHLEN characters. t Bq Er ENOENT The value of the .Fa pathname argument is an empty string; or a symbolic link to an empty string is encountered. t Bq Er ENOTDIR A component of the path prefix is not a directory. .El .Sh SEE ALSO .Xr getcwd 3 .Sh STANDARDS .Fn realpath first appeared in .St -xpg4.2 and is part of .St -p1003.1-2001 . .Sh HISTORY The .Fn realpath function call first appeared in x 4.4 . In .Nx 7.0 the function was updated to accept a .Dv NULL pointer for the .Fa resolvedname argument. .Sh BUGS This implementation of .Fn realpath differs slightly from the Solaris implementation. The x 4.4 version always returns absolute pathnames, whereas the Solaris implementation will, under certain circumstances, return a relative .Fa resolvedname when given a relative .Fa pathname .