man page macro and text revisions (-mdoc version 3)
[unix-history] / usr / src / lib / libc / sys / readlink.2
.\" Copyright (c) 1983, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" %sccs.include.redist.man%
.\"
.\" @(#)readlink.2 6.8 (Berkeley) %G%
.\"
.Dd
.Dt READLINK 2
.Os BSD 4.2
.Sh NAME
.Nm readlink
.Nd read value of a symbolic link
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Ft int
.Fn readlink "const char *path" "char *buf" "int bufsiz"
.Sh DESCRIPTION
.Fn Readlink
places the contents of the symbolic link
.Fa path
in the buffer
.Fa buf ,
which has size
.Fa bufsiz .
.Nm Readlink
does not append a
.Dv NUL
character to
.Fa buf .
.Sh RETURN VALUES
The call returns the count of characters placed in the buffer
if it succeeds, or a -1 if an error occurs, placing the error
code in the global variable
.Va errno .
.Sh ERRORS
.Fn Readlink
will fail if:
.Bl -tag -width ENAMETOOLONG
.It Bq Er ENOTDIR
A component of the path prefix is not a directory.
.It Bq Er EINVAL
The pathname contains a character with the high-order bit set.
.It Bq Er ENAMETOOLONG
A component of a pathname exceeded 255 characters,
or an entire path name exceeded 1023 characters.
.It Bq Er ENOENT
The named file does not exist.
.It Bq Er EACCES
Search permission is denied for a component of the path prefix.
.It Bq Er ELOOP
Too many symbolic links were encountered in translating the pathname.
.It Bq Er EINVAL
The named file is not a symbolic link.
.It Bq Er EIO
An I/O error occurred while reading from the file system.
.It Bq Er EFAULT
.Fa Buf
extends outside the process's allocated address space.
.El
.Sh SEE ALSO
.Xr stat 2 ,
.Xr lstat 2 ,
.Xr symlink 2
.Sh HISTORY
The
.Nm
function call appeared in
.Bx 4.2 .