From: Bruno Haible Date: Mon, 16 Sep 2024 22:52:28 +0000 (+0200) Subject: faccessat: Correct errno value on AIX. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=3b47995f0fb5208ae34b2b0c6ddcf6a311a8b067;p=gnulib.git 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/ChangeLog b/ChangeLog index 17e1e7d1cd..a61fba9088 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-09-16 Bruno Haible + + 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 mbrtoc16: Fix undefined behaviour. 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;