realpath - resolve pathname
char *realpath(const char *file_name, char *resolved_name);
The realpath() function derives, from the pathname pointed
to by file_name, an absolute pathname that names the same
file, whose resolution does not involve ".", "..", or sym-
bolic links. The generated pathname, using PATH_MAX bytes,
is stored in the buffer pointed to by resolved_name.
The realpath() function can handle both relative and abso-
lute path names. For absolute path names and the relative
names whose resolved name cannot be expressed relatively
(for example, ../../reldir), it returns the resolved abso-
lute name. For the other relative path names, it returns the
resolved relative name.
On successful completion, realpath() returns a pointer to
the resolved name. Otherwise, realpath() returns a null
pointer and sets errno to indicate the error, and the con-
tents of the buffer pointed to by resolved_name are unde-
The realpath() function will fail if:
Read or search permission was denied for a component
Either the file_name or resolved_name argument is a
EIO An error occurred while reading from the file system.
ELOOP Too many symbolic links were encountered in resolving
The file_name argument is longer than PATH_MAX or a
pathname component is longer than NAME_MAX.
A component of file_name does not name an existing
file or file_name points to an empty string.
A component of the path prefix is not a directory.
The realpath() function may fail if:
Pathname resolution of a symbolic link produced an
intermediate result whose length exceeds PATH_MAX.
Insufficient storage space is available.
The realpath() function operates on null-terminated strings.
One should have execute permission on all the directories in
the given and the resolved path.
The realpath() function may fail to return to the current
directory if an error occurs.
See attributes(5) for descriptions of the following attri-
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
| MT-Level | MT-Safe |
getcwd(3C), sysconf(3C), attributes(5)
Man(1) output converted with