statfs.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * statfs() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #include <string.h>
  10. #include <sys/param.h>
  11. #include <sys/vfs.h>
  12. extern __typeof(statfs) __libc_statfs attribute_hidden;
  13. #if defined __NR_statfs64 && !defined __NR_statfs
  14. int __libc_statfs(const char *path, struct statfs *buf)
  15. {
  16. int err = INLINE_SYSCALL(statfs64, 3, path, sizeof(*buf), buf);
  17. if (err == 0) {
  18. /* Did we overflow? */
  19. if (buf->__pad1 || buf->__pad2 || buf->__pad3 ||
  20. buf->__pad4 || buf->__pad5) {
  21. __set_errno(EOVERFLOW);
  22. return -1;
  23. }
  24. }
  25. return err;
  26. }
  27. # if defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__
  28. /* statfs is used by NPTL, so it must exported in case */
  29. weak_alias(__libc_statfs, statfs)
  30. libc_hidden_def(statfs)
  31. # endif
  32. /* For systems which have both, prefer the old one */
  33. #else
  34. # define __NR___libc_statfs __NR_statfs
  35. _syscall2(int, __libc_statfs, const char *, path, struct statfs *, buf)
  36. # if defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__
  37. /* statfs is used by NPTL, so it must exported in case */
  38. weak_alias(__libc_statfs, statfs)
  39. libc_hidden_def(statfs)
  40. # endif
  41. #endif