fstat.c 974 B

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