Standard C Library Functions realpath(3C)
NAME
realpath, canonicalize_file_name - resolve pathname
SYNOPSIS
#include
char *realpath(const char *restrict file_name,
char *restrict resolved_name);
char *canonicalize_file_name (const char *path);
DESCRIPTION
The realpath() function derives, from the pathname pointedto by file_name, an absolute pathname that resolves to the
same directory entry, whose resolution does not involve ".","..", or symbolic links. If resolved_name is not null, the
generated pathname is stored as a null-terminated string, up
to a maximum of {PATH_MAX} (defined in limits.h(3HEAD))
bytes in the buffer pointed to by resolved_name. If
resolved_name is null, the generated pathname is stored as a
null-terminated string in a buffer that is allocated as if
malloc(3C) were called.The call canonicalize_file_name(path) is equivalent to the
call realpath(path, NULL).RETURN VALUES
On successful completion, realpath() returns a pointer to the resolved name. Otherwise, realpath() returns a nullpointer and sets errno to indicate the error, and the con-
tents of the buffer pointed to by resolved_name are left in
an indeterminate state.ERRORS
The realpath() function will fail if: EACCES Read or search permission was denied for acomponent of file_name.
EINVAL Either the file_name or resolved_name argu-
ment is a null pointer. EIO An error occurred while reading from the file system.SunOS 5.11 Last change: 11 Oct 2010 1
Standard C Library Functions realpath(3C) ELOOP Too many symbolic links were encountered inresolving file_name.
ELOOP A loop exists in symbolic links encounteredduring resolution of the file_name argument.
ENAMETOOLONG The file_name argument is longer than
{PATH_MAX} or a pathname component is longer
than {NAME_MAX}.
ENOENT A component of file_name does not name an
existing file or file_name points to an
empty string. ENOTDIR A component of the path prefix is not a directory. The realpath() function may fail if:ENAMETOOLONG Pathname resolution of a symbolic link pro-
duced an intermediate result whose lengthexceeds {PATH_MAX}.
ENOMEM Insufficient storage space is available.USAGE
The realpath() function operates on null-terminated strings.
Execute permission is required for all the directories in the given and the resolved path. The realpath() function might fail to return to the current directory if an error occurs.ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:SunOS 5.11 Last change: 11 Oct 2010 2
Standard C Library Functions realpath(3C)____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Interface Stability | Committed ||_____________________________|_____________________________|
| MT-Level | MT-Safe |
|_____________________________|_____________________________|
| Standard | See standards(5). ||_____________________________|_____________________________|
SEE ALSO
getcwd(3C), limits.h(3HEAD), malloc(3C), sysconf(3C), attri-
butes(5), standards(5)SunOS 5.11 Last change: 11 Oct 2010 3