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