1READLINK(2)                Linux Programmer's Manual               READLINK(2)
2
3
4

NAME

6       readlink, readlinkat - read value of a symbolic link
7

SYNOPSIS

9       #include <unistd.h>
10
11       ssize_t readlink(const char *pathname, char *buf, size_t bufsiz);
12
13       #include <fcntl.h>           /* Definition of AT_* constants */
14       #include <unistd.h>
15
16       ssize_t readlinkat(int dirfd, const char *pathname,
17                          char *buf, size_t bufsiz);
18
19   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
20
21       readlink():
22           _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L
23               || /* Glibc versions <= 2.19: */ _BSD_SOURCE
24
25       readlinkat():
26           Since glibc 2.10:
27               _POSIX_C_SOURCE >= 200809L
28           Before glibc 2.10:
29               _ATFILE_SOURCE
30

DESCRIPTION

32       readlink()  places  the  contents  of the symbolic link pathname in the
33       buffer buf, which has size bufsiz.  readlink() does not append  a  null
34       byte  to buf.  It will (silently) truncate the contents (to a length of
35       bufsiz characters), in case the buffer is too small to hold all of  the
36       contents.
37
38   readlinkat()
39       The  readlinkat() system call operates in exactly the same way as read‐
40       link(), except for the differences described here.
41
42       If the pathname given in pathname is relative, then it  is  interpreted
43       relative  to  the  directory  referred  to by the file descriptor dirfd
44       (rather than relative to the current working directory of  the  calling
45       process, as is done by readlink() for a relative pathname).
46
47       If  pathname  is relative and dirfd is the special value AT_FDCWD, then
48       pathname is interpreted relative to the current  working  directory  of
49       the calling process (like readlink()).
50
51       If pathname is absolute, then dirfd is ignored.
52
53       Since  Linux 2.6.39, pathname can be an empty string, in which case the
54       call operates on the symbolic link referred to by dirfd  (which  should
55       have been obtained using open(2) with the O_PATH and O_NOFOLLOW flags).
56
57       See openat(2) for an explanation of the need for readlinkat().
58

RETURN VALUE

60       On  success, these calls return the number of bytes placed in buf.  (If
61       the returned value equals bufsiz, then truncation may  have  occurred.)
62       On error, -1 is returned and errno is set to indicate the error.
63

ERRORS

65       EACCES Search  permission is denied for a component of the path prefix.
66              (See also path_resolution(7).)
67
68       EFAULT buf extends outside the process's allocated address space.
69
70       EINVAL bufsiz is not positive.
71
72       EINVAL The named file (i.e., the final filename component of  pathname)
73              is not a symbolic link.
74
75       EIO