|REALPATH(3)||Library Functions Manual||REALPATH(3)|
char *pathname, char
realpath() function resolves all symbolic links, extra “/” characters and references to /./ and /../ in pathname, and copies the resulting absolute pathname into the memory referenced by resolved. The resolved argument must refer to a buffer capable of storing at least
PATH_MAXcharacters, or be
realpath() function will resolve both
absolute and relative paths and return the absolute pathname corresponding
to pathname. All but the last component of
pathname must exist when
realpath() is called.
realpath() function returns resolved on success. If resolved is
NULLand no error occurred, then
realpath() returns a NUL-terminated string in a newly allocated buffer. If an error occurs,
NULLand the contents of resolved are undefined.
realpath() will fail if:
NAME_MAXcharacters, or the entire pathname (including the terminating NUL) exceeded
realpath() function conforms to IEEE Std 1003.1-2008 (“POSIX.1”).
realpath() function call first appeared in 4.4BSD.
In OpenBSD 6.6, it was reimplemented on
top of the
__realpath() system call. Its calling
convention differs from the standard function by requiring
resolved to not be
NULL and by
returning an integer, zero on success, and -1 with corresponding errno on
failure. This is visible in the output of
|July 5, 2019||OpenBSD-current|