fstatfs.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * fstatfs() 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 <sys/vfs.h>
  11. #include <string.h>
  12. #ifndef __USE_FILE_OFFSET64__
  13. extern int fstatfs (int __fildes, struct statfs *__buf)
  14. __THROW __nonnull ((2));
  15. #else
  16. # ifdef __REDIRECT_NTH
  17. extern int __REDIRECT_NTH (fstatfs, (int __fildes, struct statfs *__buf),
  18. fstatfs64) __nonnull ((2));
  19. # else
  20. # define fstatfs fstatfs64
  21. # endif
  22. #endif
  23. extern __typeof(fstatfs) __libc_fstatfs attribute_hidden;
  24. #ifdef __NR_fstatfs
  25. # define __NR___libc_fstatfs __NR_fstatfs
  26. _syscall2(int, __libc_fstatfs, int, fd, struct statfs *, buf)
  27. #else
  28. int __libc_fstatfs (int __fildes, struct statfs *__buf)
  29. {
  30. int err = INLINE_SYSCALL(fstatfs64, 3, __fildes, sizeof(*__buf), __buf);
  31. if (err == 0) {
  32. /* Did we overflow? */
  33. if (__buf->__pad1 || __buf->__pad2 || __buf->__pad3 ||
  34. __buf->__pad4 || __buf->__pad5) {
  35. __set_errno(EOVERFLOW);
  36. return -1;
  37. }
  38. }
  39. return err;
  40. };
  41. /* Redefined fstatfs because we need it for backwards compatibility */
  42. #endif /* __NR_fstatfs */
  43. #if defined __UCLIBC_LINUX_SPECIFIC__
  44. weak_alias(__libc_fstatfs,fstatfs)
  45. #endif