1
0

statvfs.h 4.0 KB

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