fstat.c 999 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * fstat() 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_fstat64 doesnt exist */
  11. #define fstat64 __hidefstat64
  12. #define __fstat64 __hide__fstat64
  13. #include "syscalls.h"
  14. #include <unistd.h>
  15. #include <sys/stat.h>
  16. #include "xstatconv.h"
  17. #undef fstat64
  18. #undef __fstat64
  19. #define __NR___syscall_fstat __NR_fstat
  20. #undef __fstat
  21. #undef fstat
  22. static inline _syscall2(int, __syscall_fstat, int, fd, struct kernel_stat *, buf);
  23. int attribute_hidden __fstat(int fd, struct stat *buf)
  24. {
  25. int result;
  26. struct kernel_stat kbuf;
  27. result = __syscall_fstat(fd, &kbuf);
  28. if (result == 0) {
  29. __xstat_conv(&kbuf, buf);
  30. }
  31. return result;
  32. }
  33. strong_alias(__fstat,fstat)
  34. #if ! defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__
  35. hidden_strong_alias(__fstat,__fstat64)
  36. weak_alias(__fstat,fstat64)
  37. #endif