]>
Commit | Line | Data |
---|---|---|
fea681da MK |
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 | .\" | |
cc4615cc | 38 | .TH READLINK 2 2007-07-26 "Linux" "Linux Programmer's Manual" |
fea681da MK |
39 | .SH NAME |
40 | readlink \- read value of a symbolic link | |
41 | .SH SYNOPSIS | |
42 | .B #include <unistd.h> | |
43 | .sp | |
4595d739 | 44 | .BI "ssize_t readlink(const char *" path ", char *" buf ", size_t " bufsiz ); |
cc4615cc MK |
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 | |
fea681da | 55 | .SH DESCRIPTION |
e511ffb6 | 56 | .BR readlink () |
fea681da MK |
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 . | |
e511ffb6 | 63 | .BR readlink () |
28d88c17 | 64 | does not append a null byte to |
fea681da MK |
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" | |
64aae2b1 MK |
70 | On success, |
71 | .BR readlink () | |
72 | returns the number of bytes placed in | |
73 | .IR buf . | |
74 | On error, \-1 is returned and | |
75 | .I errno | |
76 | is set to indicate the error. | |
fea681da MK |
77 | .SH ERRORS |
78 | .TP | |
79 | .B EACCES | |
80 | Search permission is denied for a component of the path prefix. | |
81 | (See also | |
ad7cc990 | 82 | .BR path_resolution (7).) |
fea681da MK |
83 | .TP |
84 | .B EFAULT | |
85 | .I buf | |
86 | extends outside the process's allocated address space. | |
87 | .TP | |
88 | .B EINVAL | |
89 | .I bufsiz | |
90 | is not positive. | |
89cb804a MK |
91 | .\" At the glibc level, bufsiz is unsigned, so this error can only occur |
92 | .\" if bufsiz==0. However, the in the kernel syscall, bufsiz is signed, | |
93 | .\" and this error can also occur if bufsiz < 0. | |
94 | .\" See: http://thread.gmane.org/gmane.linux.man/380 | |
95 | .\" Subject: [patch 0/3] [RFC] kernel/glibc mismatch of "readlink" syscall? | |
fea681da MK |
96 | .TP |
97 | .B EINVAL | |
98 | The named file is not a symbolic link. | |
99 | .TP | |
100 | .B EIO | |
101 | An I/O error occurred while reading from the file system. | |
102 | .TP | |
103 | .B ELOOP | |
104 | Too many symbolic links were encountered in translating the pathname. | |
105 | .TP | |
106 | .B ENAMETOOLONG | |
107 | A pathname, or a component of a pathname, was too long. | |
108 | .TP | |
109 | .B ENOENT | |
110 | The named file does not exist. | |
111 | .TP | |
112 | .B ENOMEM | |
113 | Insufficient kernel memory was available. | |
114 | .TP | |
115 | .B ENOTDIR | |
116 | A component of the path prefix is not a directory. | |
117 | .SH "CONFORMING TO" | |
97c1eac8 | 118 | 4.4BSD (the |
e511ffb6 | 119 | .BR readlink () |
97c1eac8 MK |
120 | function call appeared in 4.2BSD), |
121 | POSIX.1-2001. | |
889829be | 122 | .SH NOTES |
4595d739 MK |
123 | In versions of glibc up to and including glibc 2.4, the return type of |
124 | .BR readlink () | |
125 | was declared as | |
126 | .IR int . | |
127 | Nowadays, the return type is declared as | |
128 | .IR ssize_t , | |
129 | as (newly) required in POSIX.1-2001. | |
fea681da MK |
130 | .SH "SEE ALSO" |
131 | .BR lstat (2), | |
591f90f7 | 132 | .BR readlinkat (2), |
fea681da | 133 | .BR stat (2), |
ad7cc990 | 134 | .BR symlink (2), |
a9cfde1d | 135 | .BR path_resolution (7), |
ad22ad55 | 136 | .BR symlink (7) |