+2004-05-11 Jim Meyering <jim@meyering.net>
+
+ Prior to this change, the save_cwd caller required read access to the
+ current directory on most systems (ones with the fchdir function).
+
+ * save-cwd.c (save_cwd) [HAVE_FCHDIR]: If opening `.' read-only
+ fails, try write-only, and finally, resort to using xgetcwd.
+
2004-05-06 Paul Eggert <eggert@cs.ucla.edu>
* obstack.c, obstack.h: Import changes from libc.
/* save-cwd.c -- Save and restore current working directory.
- Copyright (C) 1995, 1997, 1998, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1997, 1998, 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#if HAVE_FCHDIR
cwd->desc = open (".", O_RDONLY | O_DIRECTORY);
if (cwd->desc < 0)
- return 1;
+ cwd->desc = open (".", O_WRONLY | O_DIRECTORY);
+ if (cwd->desc < 0)
+ {
+ cwd->name = xgetcwd ();
+ return cwd->name == NULL;
+ }
# if __sun__ || sun
/* On SunOS 4 and IRIX 5.3, fchdir returns EINVAL when auditing