stat.c 1.0 KB

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. #include <sys/syscall.h>
  10. #include <unistd.h>
  11. #include <sys/stat.h>
  12. #include "xstatconv.h"
  13. #undef stat
  14. int stat(const char *file_name, struct stat *buf)
  15. {
  16. int result;
  17. #ifdef __NR_stat64
  18. /* normal stat call has limited values for various stat elements
  19. * e.g. uid device major/minor etc.
  20. * so we use 64 variant if available
  21. * in order to get newer versions of stat elements
  22. */
  23. struct kernel_stat64 kbuf;
  24. result = INLINE_SYSCALL(stat64, 2, file_name, &kbuf);
  25. if (result == 0) {
  26. __xstat32_conv(&kbuf, buf);
  27. }
  28. #else
  29. struct kernel_stat kbuf;
  30. result = INLINE_SYSCALL(stat, 2, file_name, &kbuf);
  31. if (result == 0) {
  32. __xstat_conv(&kbuf, buf);
  33. }
  34. #endif
  35. return result;
  36. }
  37. libc_hidden_def(stat)
  38. #if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
  39. strong_alias_untyped(stat,stat64)
  40. libc_hidden_def(stat64)
  41. #endif