From: Bruno Haible Date: Sun, 13 Jan 2019 18:14:10 +0000 (+0100) Subject: getcwd: Fix test failure when building on a Linux 9p file system. X-Git-Tag: v1.0~5162 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c88cf363f14abc2f2f3014972b652a682f297f0a;p=gnulib.git getcwd: Fix test failure when building on a Linux 9p file system. * m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX): On Linux, treat error EINVAL from mkdir like ENAMETOOLONG. * tests/test-getcwd.c (test_long_name): Likewise. --- diff --git a/ChangeLog b/ChangeLog index ecc7690659..2f02edf2e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-01-13 Bruno Haible + + getcwd: Fix test failure when building on a Linux 9p file system. + * m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX): On Linux, treat error + EINVAL from mkdir like ENAMETOOLONG. + * tests/test-getcwd.c (test_long_name): Likewise. + 2019-01-12 Tim Rühsen Fix typos found by codespell. diff --git a/m4/getcwd-path-max.m4 b/m4/getcwd-path-max.m4 index 2cefc00ad1..0ae3e1e81d 100644 --- a/m4/getcwd-path-max.m4 +++ b/m4/getcwd-path-max.m4 @@ -1,4 +1,4 @@ -# serial 21 +# serial 22 # Check for several getcwd bugs with long file names. # If so, arrange to compile the wrapper function. @@ -111,12 +111,20 @@ main () /* If mkdir or chdir fails, it could be that this system cannot create any file with an absolute name longer than PATH_MAX, such as cygwin. If so, leave fail as 0, because the current working directory can't - be too long for getcwd if it can't even be created. For other - errors, be pessimistic and consider that as a failure, too. */ + be too long for getcwd if it can't even be created. On Linux with + the 9p file system, mkdir fails with error EINVAL when cwd_len gets + too long; ignore this failure because the getcwd() system call + produces good results whereas the gnulib substitute calls getdents64 + which fails with error EPROTO. + For other errors, be pessimistic and consider that as a failure, + too. */ if (mkdir (DIR_NAME, S_IRWXU) < 0 || chdir (DIR_NAME) < 0) { if (! (errno == ERANGE || is_ENAMETOOLONG (errno))) - fail = 20; + #ifdef __linux__ + if (! (errno == EINVAL)) + #endif + fail = 20; break; } diff --git a/tests/test-getcwd.c b/tests/test-getcwd.c index 31c90375ff..b5f8155ebf 100644 --- a/tests/test-getcwd.c +++ b/tests/test-getcwd.c @@ -166,12 +166,20 @@ test_long_name (void) /* If mkdir or chdir fails, it could be that this system cannot create any file with an absolute name longer than PATH_MAX, such as cygwin. If so, leave fail as 0, because the current working directory can't - be too long for getcwd if it can't even be created. For other - errors, be pessimistic and consider that as a failure, too. */ + be too long for getcwd if it can't even be created. On Linux with + the 9p file system, mkdir fails with error EINVAL when cwd_len gets + too long; ignore this failure because the getcwd() system call + produces good results whereas the gnulib substitute calls getdents64 + which fails with error EPROTO. + For other errors, be pessimistic and consider that as a failure, + too. */ if (mkdir (DIR_NAME, S_IRWXU) < 0 || chdir (DIR_NAME) < 0) { if (! (errno == ERANGE || errno == ENAMETOOLONG || errno == ENOENT)) - fail = 2; + #ifdef __linux__ + if (! (errno == EINVAL)) + #endif + fail = 2; break; }