fstatat64.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * fstatat64() for uClibc
  3. *
  4. * Copyright (C) 2009 Analog Devices Inc.
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <_lfs_64.h>
  9. #include <bits/wordsize.h>
  10. #include <sys/syscall.h>
  11. #if defined __mips__
  12. # include <sgidefs.h>
  13. #endif
  14. /* 64bit ports tend to favor newfstatat() */
  15. #if __WORDSIZE == 64 && defined __NR_newfstatat
  16. # define __NR_fstatat64 __NR_newfstatat
  17. #endif
  18. /* mips N32 ABI use newfstatat(), too */
  19. #if defined __mips__ && _MIPS_SIM == _ABIN32
  20. # define __NR_fstatat64 __NR_newfstatat
  21. #endif
  22. #ifdef __NR_fstatat64
  23. # include <sys/stat.h>
  24. # include "xstatconv.h"
  25. int fstatat64(int fd, const char *file, struct stat64 *buf, int flag)
  26. {
  27. # ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
  28. int ret;
  29. struct kernel_stat64 kbuf;
  30. ret = INLINE_SYSCALL(fstatat64, 4, fd, file, &kbuf, flag);
  31. if (ret == 0)
  32. __xstat64_conv(&kbuf, buf);
  33. return ret;
  34. # else
  35. return INLINE_SYSCALL(fstatat64, 4, fd, file, buf, flag);
  36. # endif
  37. }
  38. libc_hidden_def(fstatat64)
  39. #else
  40. #if defined(__NR_statx) && defined(__UCLIBC_HAVE_STATX__)
  41. # include <sys/stat.h>
  42. # include <statx_cp.h>
  43. # include <fcntl.h> // for AT_NO_AUTOMOUNT
  44. int fstatat64(int fd, const char *file, struct stat64 *buf, int flag)
  45. {
  46. struct statx tmp;
  47. int r = INLINE_SYSCALL(statx, 5, fd, file, AT_NO_AUTOMOUNT | flag,
  48. STATX_BASIC_STATS, &tmp);
  49. if (r != 0)
  50. return r;
  51. __cp_stat_statx ((struct stat *)buf, &tmp);
  52. return 0;
  53. }
  54. libc_hidden_def(fstatat64)
  55. #endif
  56. /* should add emulation with fstat64() and /proc/self/fd/ ... */
  57. #endif