READLINK(2) | System Calls | READLINK(2) |
readlink - read the contents of a symbolic link
#include <unistd.h> ssize_t readlink(const char *restrict path,
char *restrict buf, size_t bufsiz);
ssize_t readlinkat(int fd, const char *restrict path,
char *restrict buf, size_t bufsiz);
The readlink() and readlinkat() functions place the contents of the symbolic link referred to by path in the buffer buf which has size bufsiz. If the number of bytes in the symbolic link is less than bufsiz, the contents of the remainder of buf are left unchanged. If the buf argument is not large enough to contain the link content, the first bufsize bytes are placed in buf.
The realinkat() function behaves similarly to readlink(); however, when path is a relative path, it is resolved relative to the directory referred to by fd. To use the current working directory, fd should be the special value AT_FDCWD.
Upon successful completion, readlink() and readlinkat() return the count of bytes placed in the buffer. Otherwise, they returns −1, leave the buffer unchanged, and set errno to indicate the error.
The readlink() and readlinkat() functions will fail if:
EACCES
EFAULT
EINVAL
EIO
ENOENT
ELOOP
ENAMETOOLONG
ENOTDIR
ENOSYS
The readlinkat() function will fail if:
EBADF
The readlink() function may fail if:
EACCES
ELOOP
ENAMETOOLONG
Portable applications should not assume that the returned contents of the symbolic link are null-terminated.
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Standard |
MT-Level | Async-Signal-Safe |
December 23, 2014 | OmniOS |