stat.c 996 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * stat() for uClibc
  4. *
  5. * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
  6. *
  7. * GNU Library General Public License (LGPL) version 2 or later.
  8. */
  9. /* need to hide the 64bit prototype or the weak_alias()
  10. * will fail when __NR_stat64 doesnt exist */
  11. #define __stat64 __hide__stat64
  12. #include "syscalls.h"
  13. #include <unistd.h>
  14. #define _SYS_STAT_H
  15. #include <bits/stat.h>
  16. #include "xstatconv.h"
  17. #undef __stat64
  18. #define __NR___syscall_stat __NR_stat
  19. #undef __stat
  20. #undef stat
  21. static inline _syscall2(int, __syscall_stat,
  22. const char *, file_name, struct kernel_stat *, buf);
  23. int attribute_hidden __stat(const char *file_name, struct stat *buf)
  24. {
  25. int result;
  26. struct kernel_stat kbuf;
  27. result = __syscall_stat(file_name, &kbuf);
  28. if (result == 0) {
  29. __xstat_conv(&kbuf, buf);
  30. }
  31. return result;
  32. }
  33. strong_alias(__stat,stat)
  34. #if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
  35. hidden_strong_alias(__stat,__stat64)
  36. weak_alias(__stat,stat64)
  37. #endif