rename, fchdir: don't ignore chdir failure
authorEric Blake <ebb9@byu.net>
Fri, 2 Oct 2009 18:05:02 +0000 (12:05 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 2 Oct 2009 18:05:02 +0000 (12:05 -0600)
commit2763d20edded7c1434d58e36c5dd05ed68784f90
treead4823f88cbeab16e102ed11f2b950b4259b4d6f
parent4ab62b551bab5c917005c7155c4976e5db5a3c4c
rename, fchdir: don't ignore chdir failure

Although we just checked that chdir(cwd) worked, there is a
race where it could disappear while we are temporarily away.
If that happens, forcefully give up rather than proceeding
in the wrong directory.

* lib/fchdir.c (get_name): Abort on unexpected chdir failure.
* lib/rename.c (rpl_rename) [W32]: Likewise.
(rpl_rename) [RENAME_DEST_EXISTS_BUG]: Avoid one case of losing
an empty destination directory if source cannot be renamed,
although there is still possibility for failure.
* doc/posix-functions/rename.texi (rename): Document the race.
Reported by Jim Meyering.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/posix-functions/rename.texi
lib/fchdir.c
lib/rename.c