readlink(2) readlink(2)
NAME
readlink - read the value of a symbolic link
SYNOPSIS
#include <unistd.h>
int readlink(const char *path, char *buf, sizet bufsiz);
DESCRIPTION
readlink() places the contents of the symbolic link referred to by
path in the buffer buf, which has size bufsiz. The contents of the
link are not null-terminated when returned.
ERRORS
The following error code descriptions are function-specific. You will
find a general description in introprm2(2) or in errno(5).
readlink() fails and the buffer remains unchanged if:
EACCES Search permission is denied for a component of the path
prefix of path.
EFAULT path or buf extends outside the allocated address space
of the process.
EINVAL The named file is not a symbolic link.
EIO An I/O error occurs while reading from or writing to the
file system.
ELOOP Too many symbolic links are encountered in translating
path.
ENAMETOOLONG The length of the path argument exceeds PATHMAX or the
length of a path component exceeds NAMEMAX.
ENOENT The named file does not exist.
ENOSYS The file system does not support symbolic links.
ENOTDIR A component of the path prefix is not a directory.
The readlink() function may fail if:
EACCES Read permission is denied for the directory.
ENAMETOOLONG Pathname resolution of a symbolic link produced an
intermediate result whose length exceeds PATHMAX.
Page 1 Reliant UNIX 5.44 Printed 11/98
readlink(2) readlink(2)
RESULT
Upon successful completion readlink() returns the number of characters
placed in the buffer; otherwise, it returns -1 and places an error
code in errno.
SEE ALSO
lstat(2), stat(2), symlink(2), unistd(4).
Page 2 Reliant UNIX 5.44 Printed 11/98