]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/readlink.2
Added/updated glibc feature test macro requirements
[thirdparty/man-pages.git] / man2 / readlink.2
1 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\" @(#)readlink.2 6.8 (Berkeley) 3/10/91
33 .\"
34 .\" Modified Sat Jul 24 00:10:21 1993 by Rik Faith (faith@cs.unc.edu)
35 .\" Modified Tue Jul 9 23:55:17 1996 by aeb
36 .\" Modified Fri Jan 24 00:26:00 1997 by aeb
37 .\"
38 .TH READLINK 2 2007-07-26 "Linux" "Linux Programmer's Manual"
39 .SH NAME
40 readlink \- read value of a symbolic link
41 .SH SYNOPSIS
42 .B #include <unistd.h>
43 .sp
44 .BI "ssize_t readlink(const char *" path ", char *" buf ", size_t " bufsiz );
45 .sp
46 .in -4n
47 Feature Test Macro Requirements for glibc (see
48 .BR feature_test_macros (7)):
49 .in
50 .sp
51 .ad l
52 .BR readlink ():
53 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _POSIX_C_SOURCE\ >=\ 200112L
54 .ad b
55 .SH DESCRIPTION
56 .BR readlink ()
57 places the contents of the symbolic link
58 .I path
59 in the buffer
60 .IR buf ,
61 which has size
62 .IR bufsiz .
63 .BR readlink ()
64 does not append a null byte to
65 .IR buf .
66 It will truncate the contents (to a length of
67 .I bufsiz
68 characters), in case the buffer is too small to hold all of the contents.
69 .SH "RETURN VALUE"
70 The call returns the count of characters placed in the buffer
71 if it succeeds, or a \-1 if an error occurs, placing the error
72 code in
73 .IR errno .
74 .SH ERRORS
75 .TP
76 .B EACCES
77 Search permission is denied for a component of the path prefix.
78 (See also
79 .BR path_resolution (7).)
80 .TP
81 .B EFAULT
82 .I buf
83 extends outside the process's allocated address space.
84 .TP
85 .B EINVAL
86 .I bufsiz
87 is not positive.
88 .TP
89 .B EINVAL
90 The named file is not a symbolic link.
91 .TP
92 .B EIO
93 An I/O error occurred while reading from the file system.
94 .TP
95 .B ELOOP
96 Too many symbolic links were encountered in translating the pathname.
97 .TP
98 .B ENAMETOOLONG
99 A pathname, or a component of a pathname, was too long.
100 .TP
101 .B ENOENT
102 The named file does not exist.
103 .TP
104 .B ENOMEM
105 Insufficient kernel memory was available.
106 .TP
107 .B ENOTDIR
108 A component of the path prefix is not a directory.
109 .SH "CONFORMING TO"
110 4.4BSD (the
111 .BR readlink ()
112 function call appeared in 4.2BSD),
113 POSIX.1-2001.
114 .SH NOTES
115 In versions of glibc up to and including glibc 2.4, the return type of
116 .BR readlink ()
117 was declared as
118 .IR int .
119 Nowadays, the return type is declared as
120 .IR ssize_t ,
121 as (newly) required in POSIX.1-2001.
122 .SH "SEE ALSO"
123 .BR lstat (2),
124 .BR readlinkat (2),
125 .BR stat (2),
126 .BR symlink (2),
127 .BR path_resolution (7)