statfs.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Copyright (C) 2011-2021 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _SYS_STATFS_H
  16. # error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
  17. #endif
  18. #include <bits/endian.h>
  19. #include <bits/types.h>
  20. #include <bits/wordsize.h>
  21. /* 64-bit libc uses the kernel's 'struct statfs', accessed via the
  22. statfs() syscall; 32-bit libc uses the kernel's 'struct statfs64'
  23. and accesses it via the statfs64() syscall. All the various
  24. APIs offered by libc use the kernel shape for their struct statfs
  25. structure; the only difference is that 32-bit programs not
  26. using __USE_FILE_OFFSET64 only see the low 32 bits of some
  27. of the fields (the __fsblkcnt_t and __fsfilcnt_t fields). */
  28. #if defined __USE_FILE_OFFSET64
  29. # define __field64(type, type64, name) type64 name
  30. #elif __WORDSIZE == 64 || __STATFS_MATCHES_STATFS64
  31. # define __field64(type, type64, name) type name
  32. #elif __BYTE_ORDER == __LITTLE_ENDIAN
  33. # define __field64(type, type64, name) \
  34. type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad
  35. #else
  36. # define __field64(type, type64, name) \
  37. int __##name##_pad __attribute__((__aligned__ (__alignof__ (type64)))); type name
  38. #endif
  39. struct statfs
  40. {
  41. __SWORD_TYPE f_type;
  42. __SWORD_TYPE f_bsize;
  43. __field64(__fsblkcnt_t, __fsblkcnt64_t, f_blocks);
  44. __field64(__fsblkcnt_t, __fsblkcnt64_t, f_bfree);
  45. __field64(__fsblkcnt_t, __fsblkcnt64_t, f_bavail);
  46. __field64(__fsfilcnt_t, __fsfilcnt64_t, f_files);
  47. __field64(__fsfilcnt_t, __fsfilcnt64_t, f_ffree);
  48. __fsid_t f_fsid;
  49. __SWORD_TYPE f_namelen;
  50. __SWORD_TYPE f_frsize;
  51. __SWORD_TYPE f_flags;
  52. __SWORD_TYPE f_spare[4];
  53. };
  54. #undef __field64
  55. #ifdef __USE_LARGEFILE64
  56. struct statfs64
  57. {
  58. __SWORD_TYPE f_type;
  59. __SWORD_TYPE f_bsize;
  60. __fsblkcnt64_t f_blocks;
  61. __fsblkcnt64_t f_bfree;
  62. __fsblkcnt64_t f_bavail;
  63. __fsfilcnt64_t f_files;
  64. __fsfilcnt64_t f_ffree;
  65. __fsid_t f_fsid;
  66. __SWORD_TYPE f_namelen;
  67. __SWORD_TYPE f_frsize;
  68. __SWORD_TYPE f_flags;
  69. __SWORD_TYPE f_spare[4];
  70. };
  71. #endif
  72. /* Tell code we have these members. */
  73. #define _STATFS_F_NAMELEN
  74. #define _STATFS_F_FRSIZE
  75. #define _STATFS_F_FLAGS