summaryrefslogtreecommitdiff
path: root/m4/getcwd-path-max.m4
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2014-12-16 02:35:19 +0000
committerPádraig Brady <P@draigBrady.com>2014-12-16 09:07:27 +0000
commit4f3dc0beed3e47ce1945dd5f8ff993e9971223c0 (patch)
treef66b9d2884b3d65dd0ca236723fd72740465094f /m4/getcwd-path-max.m4
parent1fafbb302d231d0a28a8445c8f18fcb397021556 (diff)
downloadgnulib-4f3dc0beed3e47ce1945dd5f8ff993e9971223c0.tar.gz
getcwd: fix test failure on OS X 10.9
* m4/getcwd-path-max.m4: Avoid the replacement if it won't be effective due to the PATH_MAX limitation of lstat(). (gl_cv_func_getcwd_path_max): Adjust to indicate this case. * m4/getcwd.m4 (gl_FUNC_GETCWD): Define HAVE_GETCWD_SHORTER for this case for use in tests, and also exclude this case when setting REPLACE_GETCWD. * tests/test-getcwd.c (test_long_name): Restrict the tested path length so that lstat() will not be passed a path greater than PATH_MAX. Also key a test condition on HAVE_OPENAT_SUPPORT rather than AT_FDCWD, since the latter is set unconditionally since Sep 2009 in commit 52c658e9.
Diffstat (limited to 'm4/getcwd-path-max.m4')
-rw-r--r--m4/getcwd-path-max.m413
1 files changed, 13 insertions, 0 deletions
diff --git a/m4/getcwd-path-max.m4 b/m4/getcwd-path-max.m4
index 6b49f1abc9..8395716b12 100644
--- a/m4/getcwd-path-max.m4
+++ b/m4/getcwd-path-max.m4
@@ -122,6 +122,8 @@ main ()
if (PATH_MAX <= cwd_len && cwd_len < PATH_MAX + DIR_NAME_SIZE)
{
+ struct stat sb;
+
c = getcwd (buf, PATH_MAX);
if (!c && errno == ENOENT)
{
@@ -138,6 +140,16 @@ main ()
fail = 21;
break;
}
+
+ /* Our replacement needs to be able to stat() long ../../paths,
+ so generate a path larger than PATH_MAX to check,
+ avoiding the replacement if we can't stat(). */
+ c = getcwd (buf, cwd_len + 1);
+ if (c && !AT_FDCWD && stat (c, &sb) != 0 && is_ENAMETOOLONG (errno))
+ {
+ fail = 32;
+ break;
+ }
}
if (dotdot_max <= cwd_len - initial_cwd_len)
@@ -194,6 +206,7 @@ main ()
[case $? in
10|11|12) gl_cv_func_getcwd_path_max='no, but it is partly working';;
31) gl_cv_func_getcwd_path_max='no, it has the AIX bug';;
+ 32) gl_cv_func_getcwd_path_max='yes, but with shorter paths';;
*) gl_cv_func_getcwd_path_max=no;;
esac],
[case "$host_os" in