statvfs.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*++
  2. Copyright (c) 2015 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. statvfs.h
  9. Abstract:
  10. This header contains definitions for getting information about the file
  11. system.
  12. Author:
  13. Evan Green 15-Jan-2015
  14. --*/
  15. #ifndef _SYS_STATVFS_H
  16. #define _SYS_STATVFS_H
  17. //
  18. // ------------------------------------------------------------------- Includes
  19. //
  20. #include <sys/types.h>
  21. //
  22. // ---------------------------------------------------------------- Definitions
  23. //
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. //
  28. // Define flags for the f_flag field of the statvfs structure.
  29. //
  30. //
  31. // This bit is set if the file system is mounted read-only.
  32. //
  33. #define ST_RDONLY 0x00000001
  34. //
  35. // This bit is set if setuid and setgid bits are ignored.
  36. //
  37. #define ST_NOSUID 0x00000002
  38. //
  39. // This bit is set if device special files cannot be accessed.
  40. //
  41. #define ST_NODEV 0x00000004
  42. //
  43. // This bit is set if programs cannot be executed on this file system.
  44. //
  45. #define ST_NOEXEC 0x00000008
  46. //
  47. // This bit is set if writes are synchronized immediately.
  48. //
  49. #define ST_SYNCHRONOUS 0x00000010
  50. //
  51. // This bit is set to indicate access times are not updated.
  52. //
  53. #define ST_NOATIME 0x00000020
  54. //
  55. // This bit is set to indicate directory access times are not update.
  56. //
  57. #define ST_NODIRATIME 0x00000040
  58. //
  59. // This bit is set to indicate that access time is updated only in relation to
  60. // modified and changed time.
  61. //
  62. #define ST_RELATIME 0x00000080
  63. //
  64. // ------------------------------------------------------ Data Type Definitions
  65. //
  66. /*++
  67. Structure Description:
  68. This structure defines file system information.
  69. Members:
  70. f_bsize - Stores the file system block size.
  71. f_frsize - Stores the fundamental file system block size.
  72. f_blocks - Stores the number of blocks on the file system in units of
  73. f_frsize.
  74. f_bfree - Stores the total number of free blocks.
  75. f_bavail - Stores the number of free blocks available to non-privileged
  76. processes.
  77. f_files - Stores the total number of file serial numbers.
  78. f_ffree - Stores the number of free file serial numbers.
  79. f_favail - Stores the number of free file serila numbers available to
  80. non-privileged processes.
  81. f_fsid - Stores the file system ID.
  82. f_flag - Stores the bitmask of flag values.
  83. f_namemax - Stores the maximum file name length.
  84. --*/
  85. struct statvfs {
  86. unsigned long f_bsize;
  87. unsigned long f_frsize;
  88. fsblkcnt_t f_blocks;
  89. fsblkcnt_t f_bfree;
  90. fsblkcnt_t f_bavail;
  91. fsfilcnt_t f_files;
  92. fsfilcnt_t f_ffree;
  93. fsfilcnt_t f_favail;
  94. unsigned long f_fsid;
  95. unsigned long f_flag;
  96. unsigned long f_namemax;
  97. };
  98. //
  99. // -------------------------------------------------------------------- Globals
  100. //
  101. //
  102. // -------------------------------------------------------- Function Prototypes
  103. //
  104. LIBC_API
  105. int
  106. statvfs (
  107. const char *Path,
  108. struct statvfs *Information
  109. );
  110. /*++
  111. Routine Description:
  112. This routine returns information about the file system containing the
  113. given path.
  114. Arguments:
  115. Path - Supplies a pointer to a null terminated string containing the path
  116. to a file.
  117. Information - Supplies a pointer where the file system information will
  118. be returned.
  119. Return Value:
  120. 0 on success.
  121. -1 on failure, and errno will be set to indicate the error.
  122. --*/
  123. LIBC_API
  124. int
  125. fstatvfs (
  126. int FileDescriptor,
  127. struct statvfs *Information
  128. );
  129. /*++
  130. Routine Description:
  131. This routine returns information about the file system containing the
  132. given file descriptor.
  133. Arguments:
  134. FileDescriptor - Supplies an open file descriptor whose file system
  135. properties are desired.
  136. Information - Supplies a pointer where the file system information will
  137. be returned.
  138. Return Value:
  139. 0 on success.
  140. -1 on failure, and errno will be set to indicate the error.
  141. --*/
  142. #ifdef __cplusplus
  143. }
  144. #endif
  145. #endif