summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/fstatat.c
diff options
context:
space:
mode:
authorDmitry Chestnykh <dm.chestnykh@gmail.com>2024-02-26 22:13:22 +0300
committerWaldemar Brodkorb <wbx@openadk.org>2024-02-27 02:34:47 +0100
commitee7e012b71dd3a964dc8bd3a82acddc24aceebc7 (patch)
treeebbbb38d00ba688be62d129191c87998bf2e24a4 /libc/sysdeps/linux/common/fstatat.c
parent73017bba9d3bc0f8ada159319ff590117c9e5689 (diff)
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 <dm.chestnykh@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/common/fstatat.c')
-rw-r--r--libc/sysdeps/linux/common/fstatat.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/libc/sysdeps/linux/common/fstatat.c b/libc/sysdeps/linux/common/fstatat.c
index d4f566a62..14b118cc0 100644
--- a/libc/sysdeps/linux/common/fstatat.c
+++ b/libc/sysdeps/linux/common/fstatat.c
@@ -9,13 +9,14 @@
#include <sys/syscall.h>
#include <sys/stat.h>
#include "xstatconv.h"
+#include <bits/uClibc_arch_features.h>
/* 64bit ports tend to favor newfstatat() */
#if __WORDSIZE == 64 && defined __NR_newfstatat
# define __NR_fstatat64 __NR_newfstatat
#endif
-#ifdef __NR_fstatat64
+#if defined(__NR_fstatat64) && !defined(__UCLIBC_USE_TIME64__)
int fstatat(int fd, const char *file, struct stat *buf, int flag)
{
int ret;
@@ -62,14 +63,6 @@ int fstatat(int fd, const char *file, struct stat *buf, int flag)
.st_mtim.tv_nsec = tmp.stx_mtime.tv_nsec,
.st_ctim.tv_sec = tmp.stx_ctime.tv_sec,
.st_ctim.tv_nsec = tmp.stx_ctime.tv_nsec,
-#if defined(__UCLIBC_USE_TIME64__) && !defined(__mips__)
- .__st_atim32.tv_sec = stx.stx_atime.tv_sec,
- .__st_atim32.tv_nsec = stx.stx_atime.tv_nsec,
- .__st_mtim32.tv_sec = stx.stx_mtime.tv_sec,
- .__st_mtim32.tv_nsec = stx.stx_mtime.tv_nsec,
- .__st_ctim32.tv_sec = stx.stx_ctime.tv_sec,
- .__st_ctim32.tv_nsec = stx.stx_ctime.tv_nsec,
-#endif
};
return ret;