rename, fchdir: don't ignore chdir failure
[gnulib.git] / doc / posix-functions / rename.texi
1 @node rename
2 @section @code{rename}
3 @findex rename
4
5 POSIX specification: @url{http://www.opengroup.org/onlinepubs/9699919799/functions/rename.html}
6
7 Gnulib module: rename
8
9 Portability problems fixed by Gnulib:
10 @itemize
11 @item
12 This function does not allow trailing slashes when creating a
13 destination directory, as in @code{rename("dir","new/")}:
14 NetBSD 1.6.
15 @item
16 This function does not reject trailing slashes on non-directories on
17 some platforms, as in @code{rename("file","new/")}:
18 Solaris 10, Cygwin 1.5.x, mingw.
19 @item
20 This function ignores trailing slashes on symlinks on some platforms,
21 such that @code{rename("link/","new")} corrupts @file{link}:
22 Solaris 9.
23 @item
24 This function incorrectly reduces the link count when comparing two
25 spellings of a hard link on some platforms:
26 NetBSD 1.6, Cygwin 1.5.x.
27 @item
28 This function will not always replace an existing destination on some
29 platforms:
30 Cygwin 1.5.x, mingw.
31 However, the replacement is not atomic for directories, and may end up
32 losing the empty destination if the source could not be renamed.
33 @item
34 This function mistakenly allows names ending in @samp{.} or @samp{..}
35 on some platforms:
36 Cygwin 1.5.x, mingw.
37 @item
38 This function does not reject attempts to rename existing directories
39 and non-directories onto one another on some platforms:
40 Cygwin 1.5.x, mingw.
41 @item
42 This function does not allow trailing slashes on source directories on
43 older platforms, as in @samp{rename("dir/","new")}:
44 SunOS 4.1.
45 @end itemize
46
47 Portability problems not fixed by Gnulib:
48 @itemize
49 @item
50 POSIX requires that @code{rename("symlink-to-dir/","dir2")} rename
51 @file{dir} and leave @file{symlink-to-dir} dangling; likewise, it
52 requires that @code{rename("dir","dangling/")} rename @file{dir} so
53 that @file{dangling} is no longer a dangling symlink.  This behavior
54 is counter-intuitive, so on some systems, @code{rename} fails with
55 @code{ENOTDIR} if either argument is a symlink with a trailing slash:
56 glibc, OpenBSD, Cygwin 1.7.
57 @item
58 This function will not rename a source that is currently opened
59 by any process:
60 mingw.
61 @end itemize