changeset 14631:477dcbd7cb5d

save-cwd: reduce default dependency save-cwd generally needs only a working fchdir or a working getcwd(NULL,0). If you are not worried about directories whose absolute name is longer than PATH_MAX, then reducing the default dependencies reduces the bulk for this module. However, there are cases where neither function works on Linux (an unreadable but searchable directory can be opened by O_SEARCH, except that Linux doesn't implement that yet; and Linux getcwd() has issues with long absolute names which glibc does not work around but which the full-blown getcwd module does). So someone desiring a truly robust solution needs to import the 'getcwd' module at the same time as 'save-cwd'. * modules/save-cwd (Depends-on): Use getcwd-lgpl. * lib/save-cwd.c: Update comments. * NEWS: Document the semantic change. Signed-off-by: Eric Blake <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Tue, 26 Apr 2011 15:07:07 -0600
parents d9dece4023b0
children 4843b6870f07
files ChangeLog NEWS lib/save-cwd.c modules/save-cwd
diffstat 4 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-2011-04-26  Eric Blake  <eblake@redhat.com>
+2011-04-27  Eric Blake  <eblake@redhat.com>
+
+	save-cwd: reduce default dependency
+	* modules/save-cwd (Depends-on): Use getcwd-lgpl.
+	* lib/save-cwd.c: Update comments.
+	* NEWS: Document the semantic change.
 
 	getcwd: enhance tests
 	* tests/test-getcwd-lgpl.c: New file, taken from...
@@ -9,8 +14,6 @@
 	* m4/getcwd-abort-bug.m4: Update comment.
 	* m4/getcwd-path-max.m4: Likewise.
 
-2011-04-27  Eric Blake  <eblake@redhat.com>
-
 	getcwd-lgpl: new module
 	* modules/getcwd-lgpl: New module.
 	* lib/getcwd-lgpl.c: New file.
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,11 @@
 
 Date        Modules         Changes
 
+2011-04-27  save-cwd        This module pulls in fewer dependencies by
+                            default; to retain robust handling of directories
+                            with an absolute name longer than PATH_MAX, you
+                            must now explicitly include the 'getcwd' module.
+
 2011-04-19  close-hook      This module has been renamed to 'fd-hook' and
                             generalized.
 
--- a/lib/save-cwd.c
+++ b/lib/save-cwd.c
@@ -50,7 +50,8 @@
    The `raison d'etre' for this interface is that the working directory
    is sometimes inaccessible, and getcwd is not robust or as efficient.
    So, we prefer to use the open/fchdir approach, but fall back on
-   getcwd if necessary.
+   getcwd if necessary.  This module works for most cases with just
+   the getcwd-lgpl module, but to be truly robust, use the getcwd module.
 
    Some systems lack fchdir altogether: e.g., OS/2, pre-2001 Cygwin,
    SCO Xenix.  Also, SunOS 4 and Irix 5.3 provide the function, yet it
--- a/modules/save-cwd
+++ b/modules/save-cwd
@@ -9,7 +9,7 @@
 Depends-on:
 chdir-long
 cloexec
-getcwd
+getcwd-lgpl
 fchdir
 stdbool
 unistd-safer