READLINK(2) SysV READLINK(2)
NAME
readlink - read value of a symbolic link
SYNOPSIS
cc = readlink(path, buf, bufsiz)
int cc;
const char *path;
char *buf;
int bufsiz;
DESCRIPTION
The readlink function places the contents of the symbolic link named by
the path parameter in buffer, which has size buf_size. If the actual
length of the symbolic link is less than buf_size, the string copied into
the buffer will be null-terminated. If the actual length of the symbolic
link is greater than buf_size, an error will be returned. The length of
a symbolic link will not exceed PATH_MAX.
The return link text is null-terminated if there is space in the output
buffer (that is, strlen(link-text) is less than the buffer-size).
For a readlink function to complete successfully, the calling process
must have search access to the directory containing the link.
DIAGNOSTICS
Upon successful completion, the readlink function returns a count of the
number of characters placed in the buffer (not including any terminating
null). If the readlink function fails, the buffer is not modified, a
value of -1 is returned, and errno is set to indicate the error.
ERRORS
readlink will fail and the mode of the file named by path will be
unchanged if:
[ENOTDIR] A component of the path prefix is not a directory.
[EINVAL] The pathname contains a character with the high-order
bit set.
[ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an
entire path name exceeded 1023 characters.
[ENOENT] The named file does not exist or the path parameter
points to an empty string.
[EACCES] Search permission is denied for a component of the path
prefix.
[ELOOP] The call encountered too many symbolic links in
translating the pathname.
[EINVAL] The named file is not a symbolic link.
[EIO] An I/O error occurred while reading from the file
system.
[EFAULT] buf extends outside the process' allocated address
space.
[ERANGE] The pathname in the symbolic link is longer than
buf_size.
SEE ALSO
stat(2). "Errors."