fstat64.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include <_lfs_64.h>
  9. #include <sys/syscall.h>
  10. #include <linux/version.h>
  11. #if defined(__NR_fstat64) && (!defined(__UCLIBC_USE_TIME64__) || LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))
  12. # include <unistd.h>
  13. # include <sys/stat.h>
  14. # include "xstatconv.h"
  15. # define __NR___syscall_fstat64 __NR_fstat64
  16. static __always_inline _syscall2(int, __syscall_fstat64,
  17. int, filedes, struct kernel_stat64 *, buf)
  18. int fstat64(int fd, struct stat64 *buf)
  19. {
  20. #ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
  21. int result;
  22. struct kernel_stat64 kbuf;
  23. result = __syscall_fstat64(fd, &kbuf);
  24. if (result == 0) {
  25. __xstat64_conv(&kbuf, buf);
  26. }
  27. return result;
  28. #else
  29. return __syscall_fstat64(fd, buf);
  30. #endif
  31. }
  32. libc_hidden_def(fstat64)
  33. #elif __NR_statx && defined __UCLIBC_HAVE_STATX__
  34. # include <fcntl.h>
  35. # include <statx_cp.h>
  36. int fstat64(int fd, struct stat64 *buf)
  37. {
  38. struct statx tmp;
  39. int rc = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH,
  40. STATX_BASIC_STATS, &tmp);
  41. if (rc == 0)
  42. __cp_stat64_statx ((struct stat64 *)buf, &tmp);
  43. return rc;
  44. }
  45. libc_hidden_def(fstat64)
  46. #endif