stat64.c 976 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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
  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. /* For systems which have both, prefer the old one */
  20. # elif defined __NR_stat64
  21. # define __NR___syscall_stat64 __NR_stat64
  22. # include "xstatconv.h"
  23. static __always_inline _syscall2(int, __syscall_stat64,
  24. const char *, file_name, struct kernel_stat64 *, buf)
  25. int stat64(const char *file_name, struct stat64 *buf)
  26. {
  27. int result;
  28. struct kernel_stat64 kbuf;
  29. result = __syscall_stat64(file_name, &kbuf);
  30. if (result == 0) {
  31. __xstat64_conv(&kbuf, buf);
  32. }
  33. return result;
  34. }
  35. libc_hidden_def(stat64)
  36. #endif