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