Mercurial > gnulib
changeset 40101:7c995961cd9c
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 13 Jan 2019 19:14:10 +0100 |
parents | f63c4e7dfb31 |
children | c98985691335 |
files | ChangeLog m4/getcwd-path-max.m4 tests/test-getcwd.c |
diffstat | 3 files changed, 30 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Jan 12 15:17:09 2019 +0100 +++ b/ChangeLog Sun Jan 13 19:14:10 2019 +0100 @@ -1,3 +1,10 @@ +2019-01-13 Bruno Haible <bruno@clisp.org> + + 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 <tim.ruehsen@gmx.de> Fix typos found by codespell.
--- a/m4/getcwd-path-max.m4 Sat Jan 12 15:17:09 2019 +0100 +++ b/m4/getcwd-path-max.m4 Sun Jan 13 19:14:10 2019 +0100 @@ -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 @@ /* 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; }
--- a/tests/test-getcwd.c Sat Jan 12 15:17:09 2019 +0100 +++ b/tests/test-getcwd.c Sun Jan 13 19:14:10 2019 +0100 @@ -166,12 +166,20 @@ /* 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; }