1 /++ 2 D header file correspoding to sys/statvfs.h. 3 4 Copyright: Copyright 2012 - 5 License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 Authors: Robert Klotzner and $(HTTP jmdavisprog.com, Jonathan M Davis) 7 Standards: $(HTTP http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_statvfs.h.html, 8 The Open Group Base Specifications Issue 7 IEEE Std 1003.1, 2018 Edition) 9 +/ 10 module core.sys.posix.sys.statvfs; 11 import core.stdc.config; 12 import core.sys.posix.config; 13 public import core.sys.posix.sys.types; 14 15 version (Posix): 16 extern (C) : 17 nothrow: 18 @nogc: 19 20 version (CRuntime_Glibc) { 21 static if (__WORDSIZE == 32) 22 { 23 version=_STATVFSBUF_F_UNUSED; 24 } 25 struct statvfs_t 26 { 27 c_ulong f_bsize; 28 c_ulong f_frsize; 29 fsblkcnt_t f_blocks; 30 fsblkcnt_t f_bfree; 31 fsblkcnt_t f_bavail; 32 fsfilcnt_t f_files; 33 fsfilcnt_t f_ffree; 34 fsfilcnt_t f_favail; 35 c_ulong f_fsid; 36 version (_STATVFSBUF_F_UNUSED) 37 { 38 int __f_unused; 39 } 40 c_ulong f_flag; 41 c_ulong f_namemax; 42 int[6] __f_spare; 43 } 44 /* Definitions for the flag in `f_flag'. These definitions should be 45 kept in sync with the definitions in <sys/mount.h>. */ 46 static if (_GNU_SOURCE) 47 { 48 enum FFlag 49 { 50 ST_RDONLY = 1, /* Mount read-only. */ 51 ST_NOSUID = 2, 52 ST_NODEV = 4, /* Disallow access to device special files. */ 53 ST_NOEXEC = 8, /* Disallow program execution. */ 54 ST_SYNCHRONOUS = 16, /* Writes are synced at once. */ 55 ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */ 56 ST_WRITE = 128, /* Write on file/directory/symlink. */ 57 ST_APPEND = 256, /* Append-only file. */ 58 ST_IMMUTABLE = 512, /* Immutable file. */ 59 ST_NOATIME = 1024, /* Do not update access times. */ 60 ST_NODIRATIME = 2048, /* Do not update directory access times. */ 61 ST_RELATIME = 4096 /* Update atime relative to mtime/ctime. */ 62 63 } 64 } /* Use GNU. */ 65 else 66 { // Posix defined: 67 enum FFlag 68 { 69 ST_RDONLY = 1, /* Mount read-only. */ 70 ST_NOSUID = 2 71 } 72 } 73 74 version (CRuntime_Musl) 75 { 76 int statvfs (const char * file, statvfs_t* buf); 77 int fstatvfs (int fildes, statvfs_t *buf); 78 alias statvfs64 = statvfs; 79 alias fstatvfs64 = fstatvfs; 80 } 81 else 82 { 83 static if ( __USE_FILE_OFFSET64 ) 84 { 85 int statvfs64 (const char * file, statvfs_t* buf); 86 alias statvfs64 statvfs; 87 88 int fstatvfs64 (int fildes, statvfs_t *buf) @trusted; 89 alias fstatvfs64 fstatvfs; 90 } 91 else 92 { 93 int statvfs (const char * file, statvfs_t* buf); 94 int fstatvfs (int fildes, statvfs_t *buf); 95 } 96 } 97 98 } 99 else version (NetBSD) 100 { 101 enum _VFS_MNAMELEN = 1024; 102 enum _VFS_NAMELEN = 32; 103 104 struct fsid_t 105 { 106 int[2] __fsid_val; 107 } 108 109 struct statvfs_t 110 { 111 c_ulong f_flag; 112 c_ulong f_bsize; 113 c_ulong f_frsize; 114 c_ulong f_iosize; 115 fsblkcnt_t f_blocks; 116 fsblkcnt_t f_bfree; 117 fsblkcnt_t f_bavail; 118 fsblkcnt_t f_bresvd; 119 fsfilcnt_t f_files; 120 fsfilcnt_t f_ffree; 121 fsfilcnt_t f_favail; 122 fsfilcnt_t f_fresvd; 123 ulong f_syncreads; 124 ulong f_syncwrites; 125 ulong f_asyncreads; 126 ulong f_asyncwrites; 127 fsid_t f_fsidx; 128 c_ulong f_fsid; 129 c_ulong f_namemax; 130 int f_owner; 131 int[4] f_spare; 132 char[_VFS_NAMELEN] f_fstypename = 0; 133 char[_VFS_MNAMELEN] f_mntonname = 0; 134 char[_VFS_MNAMELEN] f_mntfromname = 0; 135 } 136 137 enum FFlag 138 { 139 ST_RDONLY = 1, /* Mount read-only. */ 140 ST_NOSUID = 2 141 } 142 143 int statvfs (const char * file, statvfs_t* buf); 144 int fstatvfs (int fildes, statvfs_t *buf) @trusted; 145 } 146 else version (OpenBSD) 147 { 148 struct statvfs_t 149 { 150 c_ulong f_bsize; 151 c_ulong f_frsize; 152 fsblkcnt_t f_blocks; 153 fsblkcnt_t f_bfree; 154 fsblkcnt_t f_bavail; 155 fsfilcnt_t f_files; 156 fsfilcnt_t f_ffree; 157 fsfilcnt_t f_favail; 158 c_ulong f_fsid; 159 c_ulong f_flag; 160 c_ulong f_namemax; 161 } 162 163 enum uint ST_RDONLY = 1; 164 enum uint ST_NOSUID = 2; 165 166 int statvfs (const char* file, statvfs_t* buf); 167 int fstatvfs (int fildes, statvfs_t* buf) @trusted; 168 } 169 else version (FreeBSD) 170 { 171 struct statvfs_t 172 { 173 fsblkcnt_t f_bavail; 174 fsblkcnt_t f_bfree; 175 fsblkcnt_t f_blocks; 176 fsfilcnt_t f_favail; 177 fsfilcnt_t f_ffree; 178 fsfilcnt_t f_files; 179 ulong f_bsize; 180 ulong f_flag; 181 ulong f_frsize; 182 ulong f_fsid; 183 ulong f_namemax; 184 } 185 186 enum uint ST_RDONLY = 0x1; 187 enum uint ST_NOSUID = 0x2; 188 189 version (GNU) 190 { 191 int fstatvfs(int, statvfs_t*); 192 int statvfs(const char*, statvfs_t*); 193 } 194 else 195 { 196 pragma(mangle, "fstatvfs@FBSD_1.0") int fstatvfs(int, statvfs_t*); 197 pragma(mangle, "statvfs@FBSD_1.0") int statvfs(const char*, statvfs_t*); 198 } 199 } 200 else 201 { 202 struct statvfs_t 203 { 204 c_ulong f_bsize; 205 c_ulong f_frsize; 206 fsblkcnt_t f_blocks; 207 fsblkcnt_t f_bfree; 208 fsblkcnt_t f_bavail; 209 fsfilcnt_t f_files; 210 fsfilcnt_t f_ffree; 211 fsfilcnt_t f_favail; 212 c_ulong f_fsid; 213 c_ulong f_flag; 214 c_ulong f_namemax; 215 } 216 217 enum FFlag 218 { 219 ST_RDONLY = 1, /* Mount read-only. */ 220 ST_NOSUID = 2 221 } 222 223 int statvfs (const char * file, statvfs_t* buf); 224 int fstatvfs (int fildes, statvfs_t *buf) @trusted; 225 }