diff mbox series

[v2] linux: Fix fstat64 on alpha and sparc64

Message ID 20231229194443.3213761-1-adhemerval.zanella@linaro.org
State Superseded
Headers show
Series [v2] linux: Fix fstat64 on alpha and sparc64 | expand

Commit Message

Adhemerval Zanella Dec. 29, 2023, 7:44 p.m. UTC
The 551101e8240b7514fc646d1722f8b79c90362b8f change is incorrect for
alpha and sparc, since __NR_stat is defined by both kABI.  Use
__NR_newfstat ti check whether fallback to __NR_fstat64 (similar to
what fstatat64).

Checked on sparc64-linux-gnu and x86_64-linux-gnu.
---
 sysdeps/unix/sysv/linux/fstat64.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Andreas Schwab Dec. 30, 2023, 12:36 a.m. UTC | #1
On Dez 29 2023, Adhemerval Zanella wrote:

> +  /* The __NR_stat is defined for all ABIs that also define XSTAT_IS_STAT64,
                     ^macro
Florian Weimer Dec. 30, 2023, 12:16 p.m. UTC | #2
* Adhemerval Zanella:

> The 551101e8240b7514fc646d1722f8b79c90362b8f change is incorrect for
> alpha and sparc, since __NR_stat is defined by both kABI.  Use
> __NR_newfstat ti check whether fallback to __NR_fstat64 (similar to

“__NR_newfstat [to] check whether [to] fallback to”

> what fstatat64).
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/fstat64.c b/sysdeps/unix/sysv/linux/fstat64.c
index a291f0825b..0f1391067b 100644
--- a/sysdeps/unix/sysv/linux/fstat64.c
+++ b/sysdeps/unix/sysv/linux/fstat64.c
@@ -30,7 +30,10 @@  __fstat64_time64 (int fd, struct __stat64_t64 *buf)
 {
 #if !FSTATAT_USE_STATX
 # if XSTAT_IS_XSTAT64
-#  ifdef __NR_fstat
+  /* The __NR_stat is defined for all ABIs that also define XSTAT_IS_STAT64,
+     so to correctly identify alpha and sparc check __NR_newfstatat (similar
+     to what fstatat64 does).  */
+#  ifdef __NR_newfstatat
   /* 64-bit kABI, e.g. aarch64, ia64, powerpc64*, s390x, riscv64, and
      x86_64.  */
   return INLINE_SYSCALL_CALL (fstat, fd, buf);