poll tests: Avoid test failure on BSD and Solaris systems.
[gnulib.git] / doc / posix-functions / renameat.texi
blob45e2a4ab921a38cd3d98d10488164cb5b2aba65b
1 @node renameat
2 @section @code{renameat}
3 @findex renameat
5 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/renameat.html}
7 Gnulib module: renameat
9 Portability problems fixed by Gnulib:
10 @itemize
11 @item
12 This function is missing on some platforms:
13 glibc 2.3.6, Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Cygwin 1.5.x, mingw, MSVC 14.
14 But the replacement function is not safe to be used in libraries and is not
15 multithread-safe.
16 @item
17 This function is declared in @code{<unistd.h>}, not in @code{<stdio.h>},
18 on some platforms:
19 NetBSD 7.0, Solaris 11.4.
20 @item
21 This function is declared in @code{<sys/stat.h>}, not in @code{<stdio.h>},
22 on some platforms:
23 Android 4.3.
24 @item
25 This function does not reject trailing slashes on non-directories on
26 some platforms, as in @code{renameat(fd,"file",fd,"new/")}:
27 Solaris 11.4.
28 @item
29 This function ignores trailing slashes on symlinks on some platforms,
30 such that @code{renameat(fd,"link/",fd,"new")} corrupts @file{link}:
31 Solaris 9.
32 @end itemize
34 Portability problems not fixed by Gnulib:
35 @itemize
36 @item
37 POSIX requires that @code{renameat(fd,"symlink-to-dir/",fd,"dir2")} rename
38 @file{dir} and leave @file{symlink-to-dir} dangling; likewise, it
39 requires that @code{renameat(fd,"dir",fd,"dangling/")} rename @file{dir} so
40 that @file{dangling} is no longer a dangling symlink.  This behavior
41 is counter-intuitive, so on some systems, @code{renameat} fails with
42 @code{ENOTDIR} if either argument is a symlink with a trailing slash:
43 glibc, OpenBSD, Cygwin 1.7.
44 @item
45 POSIX requires that @code{renameat} do nothing and return 0 if the
46 source and destination are hard links to the same file.  This behavior
47 is counterintuitive, and on some systems @code{renameat} is a no-op in
48 this way only if the source and destination identify the same
49 directory entry.  On these systems, for example, although renaming
50 @file{./f} to @file{f} is a no-op, renaming @file{f} to @file{g}
51 deletes @file{f} when @file{f} and @file{g} are hard links to the same
52 file:
53 NetBSD 7.0.
54 @item
55 After renaming a non-empty directory over an existing empty directory,
56 the old directory name is still visible through the @code{stat} function
57 for 30 seconds after the rename, on NFS file systems, on some platforms:
58 Linux 2.6.18.
59 @item
60 This function will not rename a source that is currently opened
61 by any process:
62 mingw, MSVC 14.
63 @end itemize