diff options
author | Yann Sionneau <ysionneau@kalray.eu> | 2023-09-14 16:29:38 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2023-09-14 16:46:52 +0200 |
commit | 3daf0d3bf73b61acde095faa18979cff2da0017e (patch) | |
tree | e247b684ca0ea82ebe2c4b8a7597652e06a08ad4 /libc/sysdeps/linux | |
parent | 801d069af4e660b6448928509f7599b6571dadb3 (diff) |
fstatat64: define it as a wrapper of statx if the kernel does not support fstatat64 syscall
Define fstatat64 as a wrapper of statx if the kernel does not support fstatat64 syscall
This is the case for non-legacy architectures that don't define __ARCH_WANT_NEW_STAT
in their linux arch/xxx/include/asm/unistd.h
Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r-- | libc/sysdeps/linux/common/fstatat64.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c index 711521a6a..836ed4114 100644 --- a/libc/sysdeps/linux/common/fstatat64.c +++ b/libc/sysdeps/linux/common/fstatat64.c @@ -43,5 +43,28 @@ int fstatat64(int fd, const char *file, struct stat64 *buf, int flag) } libc_hidden_def(fstatat64) #else + +#if defined(__NR_statx) && defined(__UCLIBC_HAVE_STATX__) +# include <sys/stat.h> +# include <statx_cp.h> +# include <fcntl.h> // for AT_NO_AUTOMOUNT + +int fstatat64(int fd, const char *file, struct stat64 *buf, int flag) +{ + struct statx tmp; + + int r = INLINE_SYSCALL(statx, 5, fd, file, AT_NO_AUTOMOUNT | flag, + STATX_BASIC_STATS, &tmp); + + if (r != 0) + return r; + + __cp_stat_statx ((struct stat *)buf, &tmp); + + return 0; +} +libc_hidden_def(fstatat64) +#endif + /* should add emulation with fstat64() and /proc/self/fd/ ... */ #endif |