'\"macro stdmacro
.if n .pH g2.readlink @(#)readlink	40.12 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} readlink 2 "" "\&"
.if \nX=1 .ds x} readlink 2 ""
.if \nX=2 .ds x} readlink 2 "" "\&"
.if \nX=3 .ds x} readlink "" "" "\&"
.TH \*(x}
.SH NAME
\f4readlink\f1 \- read the value of a symbolic link
.SH SYNOPSIS
\f4#include <unistd.h>\f1
.sp
\f4int readlink(const char *path, void *buf, size_t bufsiz);\f1
.IX  readlink  ""  \fLreadlink\fP
.IX  "file system"  readlink  ""  \fLreadlink\fP
.IX  "symbolic link"  "read value of"
.IX  link  "read value of symbolic"
.SH DESCRIPTION
.PP
\f4readlink\fP
places the contents of the symbolic link referred to by
\f2path\f1
in the buffer
\f2buf\f1,
which has size
\f2bufsiz\f1.
The contents of the link are not null-terminated when returned.
.PP
\f4readlink\fP
fails and the buffer remains unchanged if:
.TP 20
\f4EACCES\fP
Search permission is denied for a component of the path prefix of
\f2path\f1.
.TP
\f4EFAULT\fP
\f2path\f1
or
\f2buf\f1
extends outside the allocated address space of the process.
.TP
\f4EINVAL\fP
The named file is not a symbolic link.
.TP
\f4EIO\fP
An I/O error occurs while reading from or writing to the file system.
.TP
\f4ELOOP\fP
Too many symbolic links are encountered in translating
\f2path\f1.
.TP 20
\f4ENAMETOOLONG\fP
The length of the \f2path\f1 argument exceeds {\f4PATH_MAX\f1}, or the
length of a \f2path\f1 component exceeds {\f4NAME_MAX\f1} while
\f4_POSIX_NO_TRUNC\f1 is in effect.
.TP
\f4ENOENT\fP
The named file does not exist.
.TP
\f4ENOSYS\fP
The file system does not support symbolic links.
.SH DIAGNOSTICS 
Upon successful completion
\f4readlink\fP returns the number of characters placed in the buffer;
otherwise, it returns
\-1 and places an error
code in \f4errno\fP.
.SH SEE ALSO
\f4lstat\fP(2), \f4stat\fP(2), \f4symlink\fP(2)
