xref: /openbsd/lib/libc/sys/readlink.2 (revision fc8533a3)
1.\"	$OpenBSD: readlink.2,v 1.8 1999/05/23 14:10:55 aaron Exp $
2.\"	$NetBSD: readlink.2,v 1.7 1995/02/27 12:35:54 cgd Exp $
3.\"
4.\" Copyright (c) 1983, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"	This product includes software developed by the University of
18.\"	California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\"    may be used to endorse or promote products derived from this software
21.\"    without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\"     @(#)readlink.2	8.1 (Berkeley) 6/4/93
36.\"
37.Dd June 4, 1993
38.Dt READLINK 2
39.Os
40.Sh NAME
41.Nm readlink
42.Nd read value of a symbolic link
43.Sh SYNOPSIS
44.Fd #include <unistd.h>
45.Ft int
46.Fn readlink "const char *path" "char *buf" "size_t bufsiz"
47.Sh DESCRIPTION
48.Fn readlink
49places the contents of the symbolic link
50.Fa path
51in the buffer
52.Fa buf ,
53which has size
54.Fa bufsiz .
55.Nm readlink
56does not append a
57.Dv NUL
58character to
59.Fa buf .
60.Sh RETURN VALUES
61The call returns the count of characters placed in the buffer
62if it succeeds, or a -1 if an error occurs, placing the error
63code in the global variable
64.Va errno .
65.Sh ERRORS
66.Fn readlink
67will fail if:
68.Bl -tag -width Er
69.It Bq Er ENOTDIR
70A component of the path prefix is not a directory.
71.It Bq Er ENAMETOOLONG
72A component of a pathname exceeded
73.Dv {NAME_MAX}
74characters, or an entire path name exceeded
75.Dv {PATH_MAX}
76characters.
77.It Bq Er ENOENT
78The named file does not exist.
79.It Bq Er EACCES
80Search permission is denied for a component of the path prefix.
81.It Bq Er ELOOP
82Too many symbolic links were encountered in translating the pathname.
83.It Bq Er EINVAL
84The named file is not a symbolic link.
85.It Bq Er EIO
86An I/O error occurred while reading from the file system.
87.It Bq Er EFAULT
88.Fa buf
89extends outside the process's allocated address space.
90.El
91.Sh SEE ALSO
92.Xr lstat 2 ,
93.Xr stat 2 ,
94.Xr symlink 2 ,
95.Xr symlink 7
96.Sh HISTORY
97The
98.Fn readlink
99function call appeared in
100.Bx 4.2 .
101