poll tests: Avoid test failure on BSD and Solaris systems.
[gnulib.git] / doc / posix-functions / readlink.texi
blobd4421380a8e333b49136539d9d527dd8cb9023a9
1 @node readlink
2 @section @code{readlink}
3 @findex readlink
5 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html}
7 Gnulib module: readlink
9 Portability problems fixed by Gnulib:
10 @itemize
11 @item
12 This function is missing on some platforms:
13 mingw, MSVC 14.
14 @item
15 Some platforms mistakenly succeed on file names ending in @file{/}:
16 FreeBSD 7.2, Solaris 9, Mac OS X 10.10.
17 @item
18 On some platforms, this function returns @code{int} instead of
19 @code{ssize_t}:
20 glibc 2.4, FreeBSD 6.0, OpenBSD 6.7, Cygwin 1.5.x, AIX 7.1.
21 @end itemize
23 Portability problems mostly fixed by Gnulib:
24 @itemize
25 @item
26 On some platforms, this function fails and sets @code{errno} to
27 @code{ERANGE} rather than returning truncated contents:
28 AIX 7.2, HP-UX 11.
29 The Gnulib replacement normally works as POSIX requires by returning
30 the truncated contents.  However, if the full link contents are
31 unreasonably large (more than 4000 bytes) the replacement clears the
32 entire buffer and returns the buffer size; although this is not a
33 complete fix, it suffices for typical callers, which ignore the buffer
34 contents anyway.
35 @end itemize
37 Portability problems not fixed by Gnulib:
38 @itemize
39 @item
40 This function always fails on platforms that don't support symlinks:
41 mingw, MSVC 14.
42 @item
43 When this function is called on a directory: In the case of NFS mounted
44 directories, Cygwin sets @code{errno} to @code{ENOENT} or @code{EIO} instead of
45 @code{EINVAL}.  To avoid this problem, check for a directory before calling
46 this function.
47 @item
48 When this function is called on a file that is not a symbolic link:
49 IRIX may set @code{errno} to @code{ENXIO} instead of @code{EINVAL}.  Cygwin
50 may set errno to @code{EACCES} instead of @code{EINVAL}.
51 @item
52 When this function fails because it is called on an existing
53 non-directory's name concatenated to @file{/},
54 it sets @code{errno} to @code{EINVAL}:
55 AIX 7.2.
56 @item
57 Symlink contents do not always have a trailing null byte, and there is
58 no indication if symlink contents were truncated if the return value
59 matches the length.  Furthermore,
60 Linux sets @code{errno} to @code{EINVAL} if the
61 requested length is zero.  Use the gnulib module @code{areadlink} for
62 improved ability to read symlink contents.
63 @end itemize