stat64.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * stat64() for uClibc
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <_lfs_64.h>
  10. #include <sys/syscall.h>
  11. #include <sys/stat.h>
  12. #if defined __UCLIBC_HAS_LFS__
  13. # if defined __NR_fstatat64 && !defined __NR_stat64
  14. # include <fcntl.h>
  15. # include <unistd.h>
  16. int stat64(const char *file_name, struct stat64 *buf)
  17. {
  18. return fstatat64(AT_FDCWD, file_name, buf, 0);
  19. }
  20. libc_hidden_def(stat64)
  21. /* For systems which have both, prefer the old one */
  22. # elif defined __NR_stat64
  23. # define __NR___syscall_stat64 __NR_stat64
  24. # include "xstatconv.h"
  25. static __always_inline _syscall2(int, __syscall_stat64,
  26. const char *, file_name, struct kernel_stat64 *, buf)
  27. int stat64(const char *file_name, struct stat64 *buf)
  28. {
  29. int result;
  30. struct kernel_stat64 kbuf;
  31. result = __syscall_stat64(file_name, &kbuf);
  32. if (result == 0) {
  33. __xstat64_conv(&kbuf, buf);
  34. }
  35. return result;
  36. }
  37. libc_hidden_def(stat64)
  38. # endif
  39. #endif /* __UCLIBC_HAS_LFS__ */