1readlink(2)                      System Calls                      readlink(2)
2
3
4

NAME

6       readlink - read the contents of a symbolic link
7

SYNOPSIS

9       #include <unistd.h>
10
11       ssize_t readlink(const char *restrict path,
12            char *restrict buf, size_t bufsiz);
13
14

DESCRIPTION

16       The  readlink()  function  places  the  contents  of  the symbolic link
17       referred to by path in the buffer buf which has size  bufsiz.   If  the
18       number  of bytes in the symbolic link is less than bufsiz, the contents
19       of the remainder of buf are left unchanged. If the buf argument is  not
20       large  enough  to contain the link content, the first bufsize bytes are
21       placed in buf.
22

RETURN VALUES

24       Upon successful completion,  readlink()  returns  the  count  of  bytes
25       placed  in  the  buffer.   Otherwise, it returns  −1, leaves the buffer
26       unchanged, and sets errno to indicate the error.
27

ERRORS

29       The readlink() function will fail if:
30
31       EACCES          Search permission is denied for a component of the path
32                       prefix of path.
33
34
35       EFAULT          path or buf points to an illegal address.
36
37
38       EINVAL          The  path  argument names a file that is not a symbolic
39                       link.
40
41
42       EIO             An I/O error occurred while reading from the file  sys‐
43                       tem.
44
45
46       ENOENT          A  component  of path does not name an existing file or
47                       path is an empty string.
48
49
50       ELOOP           A loop exists in symbolic links encountered during res‐
51                       olution of the path argument.
52
53
54       ENAMETOOLONG    The  length  of  path exceeds {PATH_MAX}, or a pathname
55                       component   is    longer    than    {NAME_MAX}    while
56                       _POSIX_NO_TRUNC is in effect.
57
58
59       ENOTDIR         A component of the path prefix is not a directory.
60
61
62       ENOSYS          The file system does not support symbolic links.
63
64
65
66       The readlink() function may fail if:
67
68       EACCES          Read permission is denied for the directory.
69
70
71       ELOOP           More than {SYMLOOP_MAX} symbolic links were encountered
72                       in resolving path.
73
74
75       ENAMETOOLONG    As a result of encountering a symbolic link in  resolu‐
76                       tion  of  the  path argument, the length of the substi‐
77                       tuted pathname string exceeded {PATH_MAX}.
78
79

USAGE

81       Portable applications should not assume that the returned  contents  of
82       the symbolic link are null-terminated.
83

ATTRIBUTES

85       See attributes(5) for descriptions of the following attributes:
86
87
88
89
90       ┌─────────────────────────────┬─────────────────────────────┐
91       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
92       ├─────────────────────────────┼─────────────────────────────┤
93       │Interface Stability          │Standard                     │
94       ├─────────────────────────────┼─────────────────────────────┤
95       │MT-Level                     │Async-Signal-Safe            │
96       └─────────────────────────────┴─────────────────────────────┘
97

SEE ALSO

99       stat(2), symlink(2), attributes(5), standards(5)
100
101
102
103SunOS 5.11                        1 Dec 2003                       readlink(2)
Impressum