On AIX 7.1, I'm seeing this test failure:

FAIL: test-faccessat
====================

../../gltests/test-faccessat.c:58: assertion 'errno == ENOTDIR' failed
FAIL test-faccessat (exit status: 134)

In lines 58, 60, 62, the errno value is EACCES instead of the ENOTDIR
that we expect.

This patch extends the existing workaround to fix this case as well.


2024-09-16  Bruno Haible  <br...@clisp.org>

        faccessat: Correct errno value on AIX.
        * lib/faccessat.c (rpl_faccessat): Do the trailing-slash workaround also
        if the original faccessat invocation failed.

diff --git a/lib/faccessat.c b/lib/faccessat.c
index 8178ca8632..6eed1b642a 100644
--- a/lib/faccessat.c
+++ b/lib/faccessat.c
@@ -63,15 +63,17 @@ rpl_faccessat (int fd, char const *file, int mode, int flag)
 {
   int result = orig_faccessat (fd, file, mode, flag);
 
-  if (result == 0 && file[strlen (file) - 1] == '/')
+  if (file[strlen (file) - 1] == '/')
     {
       struct stat st;
-      result = fstatat (fd, file, &st, 0);
-      if (result == 0 && !S_ISDIR (st.st_mode))
+      int ret = fstatat (fd, file, &st, 0);
+      if (ret == 0 && !S_ISDIR (st.st_mode))
         {
           errno = ENOTDIR;
           return -1;
         }
+      if (result == 0)
+        result = ret;
     }
 
   return result;




Reply via email to