readlink () - read the contents of a symbolic link
#include <unistd.h>
int readlink(const char *path, char *buf, size_t bufsize)
The readlink(2) function stores the contents of the symbolic link file path in the buffer buf, which is of size bufsize. On INTERIX, the contents of buf are null-terminated, though portable programs should not assume this is so.
If the symlink data are longer than bufsiz, then only the first bufsiz bytes of the symlink data are written into the buffer, and the value bufsiz is returned; errno is not set.
However, if you lstat(2) the symbolic link, then the st_size field is set to the total number of bytes of symlink data.
On success, the readlink(2) call returns the number of bytes stored in bufsize; otherwise it returns -1 and sets errno.
The readlink(2) call can fail for the following reasons: