2 @section @code{readlinkat}
5 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlinkat.html}
7 Gnulib module: readlinkat
9 Portability problems fixed by Gnulib:
12 This function is missing on some platforms:
13 glibc 2.3.6, Mac OS X 10.9, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10, Cygwin 1.5.x, mingw, MSVC 14, Android 4.4.
14 But the replacement function is not safe to be used in libraries and is not multithread-safe.
16 Some platforms mistakenly succeed on file names ending in @file{/}:
19 On some platforms, this function returns @code{int} instead of
24 Portability problems mostly fixed by Gnulib:
27 On some platforms, this function fails and sets @code{errno} to
28 @code{ERANGE} rather than returning truncated contents:
30 The Gnulib replacement normally works as POSIX requires by returning
31 the truncated contents. However, if the full link contents are
32 unreasonably large (more than 4000 bytes) the replacement clears the
33 entire buffer and returns the buffer size; although this is not a
34 complete fix, it suffices for typical callers, which ignore the buffer
38 Portability problems not fixed by Gnulib:
41 This function always fails on platforms that don't support symlinks:
44 When this function is called on a directory: In the case of NFS mounted
45 directories, Cygwin sets @code{errno} to @code{ENOENT} or @code{EIO} instead of
46 @code{EINVAL}. To avoid this problem, check for a directory before calling
49 When this function is called on a file that is not a symbolic link:
50 IRIX may set @code{errno} to @code{ENXIO} instead of @code{EINVAL}. Cygwin
51 may set errno to @code{EACCES} instead of @code{EINVAL}.
53 When this function fails because it is called on an existing
54 non-directory's name concatenated to @file{/},
55 it sets @code{errno} to @code{EINVAL}:
58 Symlink contents do not always have a trailing null byte, and there is
59 no indication if symlink contents were truncated if the return value
60 matches the length. Furthermore,
61 Linux sets @code{errno} to @code{EINVAL} if the
62 requested length is zero. Use the gnulib module @code{areadlink} for
63 improved ability to read symlink contents.