85 lines
2.3 KiB
Groff
85 lines
2.3 KiB
Groff
'\"macro stdmacro
|
|
.if n .pH g2.readlink @(#)readlink 41.7 of 5/26/91
|
|
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 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, char \(**buf, size_t bufsiz);\f1
|
|
.IX readlink "" \f4readlink\fP
|
|
.IX "file system" readlink "" \f4readlink\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 20
|
|
\f4EACCES\fP
|
|
Read permission is denied on the file named by \f2path\fP.
|
|
.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 NOTES
|
|
\f4readlink\fP updates the time of last access (see \f4stat\fP(2)) of the
|
|
link.
|
|
.P
|
|
If the buffer passed to \f4readlink\fP is smaller than the
|
|
symbolic link file being read, \f4readlink\fP returns only as many
|
|
characters as will fit in the buffer.
|
|
Using a buffer of size \s-1\f4PATH_MAX\fP\s+1 or greater
|
|
eliminates the possibility of reading an incomplete link value.
|
|
.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), \f4realpath\fP(3).
|