From 66d86350c4d8342e77af86fe2e99b63e27815b54 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 5 Mar 2003 08:35:36 +0000 Subject: name changes add comments fix logic --- m4/getcwd-robust.m4 | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'm4') diff --git a/m4/getcwd-robust.m4 b/m4/getcwd-robust.m4 index 9531bae4d..e91fa64f5 100644 --- a/m4/getcwd-robust.m4 +++ b/m4/getcwd-robust.m4 @@ -1,12 +1,18 @@ #serial 1 -# Check whether getcwd can return a path longer than PATH_MAX. -# If not, arrange to compile the wrapper function. +# Check whether getcwd has the bug that it succeeds for a working directory +# longer than PATH_MAX, yet returns a truncated directory name. +# If so, arrange to compile the wrapper function. + +# This is necessary for at least GNU libc on linux-2.4.19 and 2.4.20. +# I've heard that this is due to a Linux kernel bug, and that it has +# been fixed between 2.4.21-pre3 and 2.4.21-pre4. */ + # From Jim Meyering -AC_DEFUN([GL_FUNC_GETCWD_ROBUST], +AC_DEFUN([GL_FUNC_GETCWD_PATH_MAX], [ - AC_CACHE_CHECK([whether getcwd can return a path longer than PATH_MAX], - utils_cv_func_getcwd_robust, + AC_CACHE_CHECK([whether getcwd properly handles paths longer than PATH_MAX], + utils_cv_func_getcwd_vs_path_max, [ # Arrange for deletion of the temporary directory this test creates. ac_clean_files="$ac_clean_files confdir3" @@ -71,10 +77,12 @@ main () size_t len; cwd_len += 1 + strlen (DIR_NAME); + /* If mkdir or chdir fails, be pessimistic and consider that + as a failure, too. */ if (mkdir (DIR_NAME, 0700) < 0 || chdir (DIR_NAME) < 0 - || (c = getcwd (buf, PATH_MAX)) == NULL - || (len = strlen (c)) != cwd_len) + || ((c = getcwd (buf, PATH_MAX)) != NULL + && (len = strlen (c)) != cwd_len)) { fail = 1; break; @@ -104,11 +112,11 @@ main () #endif } ]])], - [utils_cv_func_getcwd_robust=yes], - [utils_cv_func_getcwd_robust=no], - [utils_cv_func_getcwd_robust=no])]) + [utils_cv_func_getcwd_vs_path_max=yes], + [utils_cv_func_getcwd_vs_path_max=no], + [utils_cv_func_getcwd_vs_path_max=no])]) - if test $utils_cv_func_getcwd_robust = yes; then + if test $utils_cv_func_getcwd_vs_path_max = yes; then AC_LIBOBJ(getcwd) AC_DEFINE(getcwd, rpl_getcwd, [Define to rpl_getcwd if the wrapper function should be used.]) -- cgit v1.2.3-54-g00ecf