1READLINK(2) Linux Programmer's Manual READLINK(2)
2
3
4
6 readlink - read value of a symbolic link
7
9 #include <unistd.h>
10
11 ssize_t readlink(const char *path, char *buf, size_t bufsiz);
12
14 readlink() places the contents of the symbolic link path in the buffer
15 buf, which has size bufsiz. readlink() does not append a null byte to
16 buf. It will truncate the contents (to a length of bufsiz characters),
17 in case the buffer is too small to hold all of the contents.
18
20 The call returns the count of characters placed in the buffer if it
21 succeeds, or a -1 if an error occurs, placing the error code in errno.
22
24 EACCES Search permission is denied for a component of the path prefix.
25 (See also path_resolution(2).)
26
27 EFAULT buf extends outside the process's allocated address space.
28
29 EINVAL bufsiz is not positive.
30
31 EINVAL The named file is not a symbolic link.
32
33 EIO An I/O error occurred while reading from the file system.
34
35 ELOOP Too many symbolic links were encountered in translating the
36 pathname.
37
38 ENAMETOOLONG
39 A pathname, or a component of a pathname, was too long.
40
41 ENOENT The named file does not exist.
42
43 ENOMEM Insufficient kernel memory was available.
44
45 ENOTDIR
46 A component of the path prefix is not a directory.
47
49 4.4BSD (the readlink() function call appeared in 4.2BSD), POSIX.1-2001.
50
52 In versions of glibc up to and including glibc 2.4, the return type of
53 readlink() was declared as int. Nowadays, the return type is declared
54 as ssize_t, as (newly) required in POSIX.1-2001.
55
57 lstat(2), path_resolution(2), readlinkat(2), stat(2), symlink(2)
58
59
60
61Linux 2.0.30 1997-08-21 READLINK(2)