1 /*
2 * fstat64() for uClibc
3 *
4 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
5 *
6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7 */
8
9 #include <_lfs_64.h>
10 #include <sys/syscall.h>
11 #include <linux/version.h>
12
13 #if defined(__NR_fstat64) && (!defined(__UCLIBC_USE_TIME64__) || LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))
14 # include <unistd.h>
15 # include <sys/stat.h>
16 # include "xstatconv.h"
17 # define __NR___syscall_fstat64 __NR_fstat64
_syscall2(int,__syscall_fstat64,int,filedes,struct kernel_stat64 *,buf)18 static __always_inline _syscall2(int, __syscall_fstat64,
19 int, filedes, struct kernel_stat64 *, buf)
20
21 int fstat64(int fd, struct stat64 *buf)
22 {
23 #ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
24 int result;
25 struct kernel_stat64 kbuf;
26
27 result = __syscall_fstat64(fd, &kbuf);
28 if (result == 0) {
29 __xstat64_conv(&kbuf, buf);
30 }
31 return result;
32
33 #else
34 return __syscall_fstat64(fd, buf);
35 #endif
36 }
37 libc_hidden_def(fstat64)
38
39 #elif __NR_statx && defined __UCLIBC_HAVE_STATX__
40 # include <fcntl.h>
41 # include <statx_cp.h>
42
43 int fstat64(int fd, struct stat64 *buf)
44 {
45 struct statx tmp;
46 int rc = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH,
47 STATX_BASIC_STATS, &tmp);
48 if (rc == 0)
49 __cp_stat64_statx ((struct stat64 *)buf, &tmp);
50
51 return rc;
52 }
53 libc_hidden_def(fstat64)
54 #endif
55