]> Savannah Git Hosting - gnulib.git/commitdiff
getcwd: Fix test failure when building on a Linux 9p file system.
authorBruno Haible <bruno@clisp.org>
Sun, 13 Jan 2019 18:14:10 +0000 (19:14 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 13 Jan 2019 18:14:10 +0000 (19:14 +0100)
* 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.

ChangeLog
m4/getcwd-path-max.m4
tests/test-getcwd.c

index ecc7690659174eafe3f1417e719b40644a6adfd2..2f02edf2e5db90b6d5b8e2fb3a6e1465c6f5199d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 2cefc00ad1c561f0a081605d88d2514149572627..0ae3e1e81d5f5b5ba533799d3e9b7af2893eb2e0 100644 (file)
@@ -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;
         }
 
index 31c90375ffc458092d42888f88f701ff17f6b7e0..b5f8155ebf7dbefb2cc156976006ab1a86eee9fb 100644 (file)
@@ -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;
         }