hi, the test that checks wether getcwd accepts paths longer than PATH_MAX works badly on systems where PATH_MAX is undefined, like GNU (aka GNU/Hurd). when PATH_MAX is not defined, it means there's no generic limit on the length of a path, and thus this kind of bug in getcwd cannot exist, so it should not be tested for it. see the comments added in the patch below, they're quite explanative: diff -ur coreutils-5.0.old/aclocal.m4 coreutils-5.0/aclocal.m4 --- coreutils-5.0.old/aclocal.m4 2003-04-02 16:28:30.000000000 +0200 +++ coreutils-5.0/aclocal.m4 2003-04-25 19:05:04.000000000 +0200 @@ -3739,23 +3739,25 @@ # define INT_MAX TYPE_MAXIMUM (int) #endif -#ifndef PATH_MAX -/* There might be a better way to handle this case, but note: - - the value shouldn't be anywhere near INT_MAX, and - - the value shouldn't be so big that the local declaration, below, - blows the stack. */ -# define PATH_MAX 40000 -#endif - /* The length of this name must be 8. */ #define DIR_NAME "confdir3" int main () { +#ifndef PATH_MAX + /* There's no PATH_MAX limit, so there can't be such bug in getcwd. + the GNU system (aka GNU/Hurd) falls in this category */ + /* FIXME: It is possible for an OS to implement non-generic limits, + which can be obtained with pathconf. If such an OS had the + getcwd bug, we'd have to find a path for which path_max applies + to and test with that. I don't know how to reliably find that, but + in any case this is an extremely unlikely situation. */ + exit (0); +#else /* The '9' comes from strlen (DIR_NAME) + 1. */ #if INT_MAX - 9 <= PATH_MAX - /* FIXME: Assuming there's a system for which this is true -- Hurd?, + /* FIXME: Assuming there's a system for which this is true, this should be done in a compile test. */ exit (0); #else @@ -3817,6 +3819,7 @@ exit (fail); #endif +#endif /* #ifndef PATH_MAX */ } ]])], [gl_cv_func_getcwd_vs_path_max=yes], diff -ur coreutils-5.0.old/configure coreutils-5.0/configure --- coreutils-5.0.old/configure 2003-04-02 16:28:50.000000000 +0200 +++ coreutils-5.0/configure 2003-04-25 19:05:04.000000000 +0200 @@ -27827,23 +27827,25 @@ # define INT_MAX TYPE_MAXIMUM (int) #endif -#ifndef PATH_MAX -/* There might be a better way to handle this case, but note: - - the value shouldn't be anywhere near INT_MAX, and - - the value shouldn't be so big that the local declaration, below, - blows the stack. */ -# define PATH_MAX 40000 -#endif - /* The length of this name must be 8. */ #define DIR_NAME "confdir3" int main () { +#ifndef PATH_MAX + /* There's no PATH_MAX limit, so there can't be such bug in getcwd. + the GNU system (aka GNU/Hurd) falls in this category */ + /* FIXME: It is possible for an OS to implement non-generic limits, + which can be obtained with pathconf. If such an OS had the + getcwd bug, we'd have to find a path for which path_max applies + to and test with that. I don't know how to reliably find that, but + in any case this is an extremely unlikely situation. */ + exit (0); +#else /* The '9' comes from strlen (DIR_NAME) + 1. */ #if INT_MAX - 9 <= PATH_MAX - /* FIXME: Assuming there's a system for which this is true -- Hurd?, + /* FIXME: Assuming there's a system for which this is true, this should be done in a compile test. */ exit (0); #else @@ -27905,6 +27907,7 @@ exit (fail); #endif +#endif /* #ifndef PATH_MAX */ } _ACEOF diff -ur coreutils-5.0.old/m4/getcwd-path-max.m4 coreutils-5.0/m4/getcwd-path-max.m4 --- coreutils-5.0.old/m4/getcwd-path-max.m4 2003-03-07 10:57:20.000000000 +0100 +++ coreutils-5.0/m4/getcwd-path-max.m4 2003-04-25 19:06:58.000000000 +0200 @@ -44,23 +44,25 @@ # define INT_MAX TYPE_MAXIMUM (int) #endif -#ifndef PATH_MAX -/* There might be a better way to handle this case, but note: - - the value shouldn't be anywhere near INT_MAX, and - - the value shouldn't be so big that the local declaration, below, - blows the stack. */ -# define PATH_MAX 40000 -#endif - /* The length of this name must be 8. */ #define DIR_NAME "confdir3" int main () { +#ifndef PATH_MAX + /* There's no PATH_MAX limit, so there can't be such bug in getcwd. + the GNU system (aka GNU/Hurd) falls in this category */ + /* FIXME: It is possible for an OS to implement non-generic limits, + which can be obtained with pathconf. If such an OS had the + getcwd bug, we'd have to find a path for which path_max applies + to and test with that. I don't know how to reliably find that, but + in any case this is an extremely unlikely situation. */ + exit (0); +#else /* The '9' comes from strlen (DIR_NAME) + 1. */ #if INT_MAX - 9 <= PATH_MAX - /* FIXME: Assuming there's a system for which this is true -- Hurd?, + /* FIXME: Assuming there's a system for which this is true, this should be done in a compile test. */ exit (0); #else @@ -122,6 +124,7 @@ exit (fail); #endif +#endif /* #ifndef PATH_MAX */ } ]])], [gl_cv_func_getcwd_vs_path_max=yes],