Table of Contents

Name

realpath - returns the canonicalized absolute pathname.

Synopsis

#include <sys/param.h>

char *realpath(file_name, resolved_name)
char *file_name;
char resolved_name[MAXPATHLEN];

Description

realpath() expands all symbolic links and resolves references to `/./', `/../' and extra `/' characters in the null terminated string named by file_name and stores the canonicalized absolute pathname in the buffer named by resolved_name. The resulting path will have no symbolic links components, nor any `/./' or `/../' components.

Return Value

If there is no error, it returns a pointer to the resolved_name.

Otherwise it returns a NULL pointer and places in resolved_name the absolute pathname of the file_name component which could not be resolved. The global variable errno is set to indicate the error. If any of the parameters are NULL, errno will be set to EINVAL. realpath() indirectly invokes the readlink(2) system call and getwd(3) library call (for relative path names), and errno will be set by them.

See Also

readlink(2) , getwd(3)

Warnings

It indirectly invokes the readlink(2) system call and getwd(3) library call (for relative path names), and hence inherits the possibility of hanging due to inaccessible file system resources.


Table of Contents