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

NAME

6       readlink - read value of a symbolic link
7

SYNOPSIS

9       #include <unistd.h>
10
11       ssize_t readlink(const char *path, char *buf, size_t bufsiz);
12
13   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15       readlink(): _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
16       _POSIX_C_SOURCE >= 200112L
17

DESCRIPTION

19       readlink() places the contents of the symbolic link path in the  buffer
20       buf,  which has size bufsiz.  readlink() does not append a null byte to
21       buf.  It will truncate the contents (to a length of bufsiz characters),
22       in case the buffer is too small to hold all of the contents.
23

RETURN VALUE

25       On  success,  readlink() returns the number of bytes placed in buf.  On
26       error, -1 is returned and errno is set to indicate the error.
27

ERRORS

29       EACCES Search permission is denied for a component of the path  prefix.
30              (See also path_resolution(7).)
31
32       EFAULT buf extends outside the process's allocated address space.
33
34       EINVAL bufsiz is not positive.
35
36       EINVAL The named file is not a symbolic link.
37
38       EIO    An I/O error occurred while reading from the file system.
39
40       ELOOP  Too  many  symbolic  links  were  encountered in translating the
41              pathname.
42
43       ENAMETOOLONG
44              A pathname, or a component of a pathname, was too long.
45
46       ENOENT The named file does not exist.
47
48       ENOMEM Insufficient kernel memory was available.
49
50       ENOTDIR
51              A component of the path prefix is not a directory.
52

CONFORMING TO

54       4.4BSD (the readlink() function call appeared in 4.2BSD), POSIX.1-2001.
55

NOTES

57       In versions of glibc up to and including glibc 2.4, the return type  of
58       readlink()  was declared as int.  Nowadays, the return type is declared
59       as ssize_t, as (newly) required in POSIX.1-2001.
60

SEE ALSO

62       lstat(2), readlinkat(2), stat(2), symlink(2), path_resolution(7),  sym‐
63       link(7)
64

COLOPHON

66       This  page  is  part of release 3.22 of the Linux man-pages project.  A
67       description of the project, and information about reporting  bugs,  can
68       be found at http://www.kernel.org/doc/man-pages/.
69
70
71
72Linux                             2007-07-26                       READLINK(2)
Impressum