]> Savannah Git Hosting - gnulib.git/commitdiff
faccessat: Correct errno value on AIX.
authorBruno Haible <bruno@clisp.org>
Mon, 16 Sep 2024 22:52:28 +0000 (00:52 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 17 Sep 2024 14:06:45 +0000 (16:06 +0200)
* lib/faccessat.c (rpl_faccessat): Do the trailing-slash workaround also
if the original faccessat invocation failed.

ChangeLog
lib/faccessat.c

index b9fb6391852990fc3d207164ca21d89027fe24af..574ffb6c0e56fbedbedcc6206d26253da18604aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-09-16  Bruno Haible  <bruno@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.
+
 2024-09-10  Bruno Haible  <bruno@clisp.org>
 
        mbrtoc16: Fix undefined behaviour.
index 8178ca8632eafefb924011eb4fffe4e9d1856864..6eed1b642a62c8840e0450e2c8e0d6e98708e410 100644 (file)
@@ -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;