stat.c 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * stat() 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. /* need to hide the 64bit prototype or the strong_alias()
  10. * will fail when __NR_stat64 doesnt exist */
  11. #define stat64 __hidestat64
  12. #include <sys/syscall.h>
  13. #include <unistd.h>
  14. #include <sys/stat.h>
  15. #include "xstatconv.h"
  16. #undef stat64
  17. libc_hidden_proto(stat)
  18. #define __NR___syscall_stat __NR_stat
  19. #undef stat
  20. static inline _syscall2(int, __syscall_stat,
  21. const char *, file_name, struct kernel_stat *, buf);
  22. int stat(const char *file_name, struct stat *buf)
  23. {
  24. int result;
  25. struct kernel_stat kbuf;
  26. result = __syscall_stat(file_name, &kbuf);
  27. if (result == 0) {
  28. __xstat_conv(&kbuf, buf);
  29. }
  30. return result;
  31. }
  32. libc_hidden_def(stat)
  33. #if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
  34. extern __typeof(stat) stat64;
  35. libc_hidden_proto(stat64)
  36. strong_alias(stat,stat64)
  37. libc_hidden_def(stat64)
  38. #endif