CVS coreutils rm failed "make check" due to the following scenario in tests/rm/inaccessible:
can't get the working directory initially; ... chdir ("/foo/bar/abs1"); ... opendir, readdir, remove all entries here; then: ... chdir ("."); // because we couldn't get the working directory initially rmdir ("/foo/bar/abs1"); ... Solaris doesn't let you remove the working directory, so rmdir fails. The fix is to replace that chdir (".") with a chdir ("/"), so I installed the following patch. However, I'd like other pairs of eyes to verify this one, as I'm a bit leery of executing chdir ("/") in a program that is removing everything in sight! I thought of using chdir ("..") instead but worried it might fail too, e.g., if two rm processes are running simultaneously -- perhaps I was worrying too much? 2004-07-28 Paul Eggert <[EMAIL PROTECTED]> * src/remove.c (remove_dir): If we can't save the state of the working directory, pretend we started from "/", not ".". This avoids a bug on hosts like Solaris that don't let you remove the working directory. Index: src/remove.c =================================================================== RCS file: /home/eggert/coreutils/cu/src/remove.c,v retrieving revision 1.113 retrieving revision 1.114 diff -p -u -r1.113 -r1.114 --- src/remove.c 20 Jun 2004 13:44:12 -0000 1.113 +++ src/remove.c 28 Jul 2004 14:50:06 -0000 1.114 @@ -1008,9 +1008,12 @@ remove_dir (Dirstack_state *ds, char con (*cwd_state)->saved_errno = errno; assert (errno != 0); - /* Pretend we started from ".". That is fine as long as there - is no requirement to return to the original working directory. */ - (*cwd_state)->saved_cwd.name = xstrdup ("."); + /* Pretend we started from "/". That is fine as long as there + is no requirement to return to the original working directory. + Use "/", not ".", so that we chdir out of a non-root target + directory before attempting to remove it: some hosts don't let + you remove a working directory. */ + (*cwd_state)->saved_cwd.name = xstrdup ("/"); } else (*cwd_state)->saved_errno = 0; _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-coreutils