realpath

NAME

realpath() - resolve pathnames

SYNOPSIS

#include <stdlib.h>

char * realpath(const char *path, char *resolved)

DESCRIPTION

The realpath(3) call takes a path as an argument and returns (in the resolved buffer) the actual path. It resolves multiple concurrent slashes, directory components such as . and .. and symbolic links. It resolves the path by executing chdir(2) and stat(2).

The realpath(3) call takes the following arguments:

path
A buffer containing the path name to be resolved.
resolved
A buffer to contain the resolved path name. The buffer is assumed to be at least {PATH_MAX} bytes in size.

DIAGNOSTICS

On success, the realpath(3) call returns a pointer to resolved; on failure, it returns NULL and sets errno to indicate the error. The resolved buffer will contain the intermediate pathname which caused the error.

ERRORS

The realpath(3) call can fail for the following reasons:

[EINVAL]
Either path or resolved was NULL.
[ELOOP]
The pathname in path involved a links in a loop.
[ENAMETOOLONG]
The resolved pathname would have been more than {PATH_MAX} characters long.
[ENOENT]
The path was invalid.

SEE ALSO

chdir(2)

stat(2)