From ee7e012b71dd3a964dc8bd3a82acddc24aceebc7 Mon Sep 17 00:00:00 2001 From: Dmitry Chestnykh Date: Mon, 26 Feb 2024 22:13:22 +0300 Subject: Fix *stat() and *stat64() when the time is beyond year 2038. To obtain correct `st_atim`, `st_mtim` and `st_ctim` fields we need to use statx() syscall and then convert the data from the kernel to the regular stat structure. Signed-off-by: Dmitry Chestnykh --- libc/sysdeps/linux/common/fstat.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libc/sysdeps/linux/common/fstat.c') diff --git a/libc/sysdeps/linux/common/fstat.c b/libc/sysdeps/linux/common/fstat.c index 86c24bff6..65e879799 100644 --- a/libc/sysdeps/linux/common/fstat.c +++ b/libc/sysdeps/linux/common/fstat.c @@ -10,10 +10,11 @@ #include #include #include +#include #include "xstatconv.h" -#if defined __NR_fstat64 && !defined __NR_fstat +#if defined __NR_fstat64 && !defined __NR_fstat && !defined(__UCLIBC_USE_TIME64__) int fstat(int fd, struct stat *buf) { return INLINE_SYSCALL(fstat64, 2, fd, buf); @@ -29,7 +30,7 @@ int fstat(int fd, struct stat *buf) } libc_hidden_def(fstat) -#elif __NR_statx && defined __UCLIBC_HAVE_STATX__ +#elif defined __NR_statx && defined __UCLIBC_HAVE_STATX__ # include # include -- cgit v1.2.3