stat64.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * stat64() 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 <sys/stat.h>
  11. #if defined __NR_fstatat64 && !defined __NR_stat64 && !defined(__UCLIBC_USE_TIME64__)
  12. #include <fcntl.h>
  13. #include <unistd.h>
  14. int stat64(const char *file_name, struct stat64 *buf)
  15. {
  16. return fstatat64(AT_FDCWD, file_name, buf, 0);
  17. }
  18. libc_hidden_def(stat64)
  19. #elif __NR_statx && defined __UCLIBC_HAVE_STATX__
  20. # include <fcntl.h>
  21. # include <statx_cp.h>
  22. int stat64(const char *file_name, struct stat64 *buf)
  23. {
  24. struct statx tmp;
  25. int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, file_name, AT_NO_AUTOMOUNT,
  26. STATX_BASIC_STATS, &tmp);
  27. if (rc == 0)
  28. __cp_stat64_statx ((struct stat64 *)buf, &tmp);
  29. return rc;
  30. }
  31. libc_hidden_def(stat64)
  32. /* For systems which have both, prefer the old one */
  33. # elif defined __NR_stat64
  34. # define __NR___syscall_stat64 __NR_stat64
  35. # include "xstatconv.h"
  36. static __always_inline _syscall2(int, __syscall_stat64,
  37. const char *, file_name, struct kernel_stat64 *, buf)
  38. int stat64(const char *file_name, struct stat64 *buf)
  39. {
  40. int result;
  41. struct kernel_stat64 kbuf;
  42. result = __syscall_stat64(file_name, &kbuf);
  43. if (result == 0) {
  44. __xstat64_conv(&kbuf, buf);
  45. }
  46. return result;
  47. }
  48. libc_hidden_def(stat64)
  49. #endif