ustat.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Get filesystem statistics (deprecated). Linux version.
  2. Copyright (C) 1997-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <shlib-compat.h>
  17. /* This deprecated syscall is no longer used (replaced with {f}statfs). */
  18. #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28)
  19. # include <sysdep.h>
  20. # include <errno.h>
  21. # ifndef DEV_TO_KDEV
  22. # define DEV_TO_KDEV(__dev) \
  23. ({ \
  24. unsigned long long int k_dev; \
  25. k_dev = dev & ((1ULL << 32) - 1); \
  26. if (k_dev != dev) \
  27. return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); \
  28. (unsigned int) k_dev; \
  29. })
  30. # endif
  31. struct ustat
  32. {
  33. __daddr_t f_tfree; /* Number of free blocks. */
  34. __ino_t f_tinode; /* Number of free inodes. */
  35. char f_fname[6];
  36. char f_fpack[6];
  37. };
  38. int
  39. __old_ustat (dev_t dev, struct ustat *ubuf)
  40. {
  41. # ifdef __NR_ustat
  42. return INLINE_SYSCALL_CALL (ustat, DEV_TO_KDEV (dev), ubuf);
  43. # else
  44. return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOSYS);
  45. # endif
  46. }
  47. compat_symbol (libc, __old_ustat, ustat, GLIBC_2_0);
  48. #endif /* SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28) */