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 private import core.stdc.config;
12 private import core.sys.posix.config;
13 public import core.sys.posix.sys.types;
14 
version(Posix)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 (__USE_GNU)
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     static if ( __USE_FILE_OFFSET64 )
75     {
76         int statvfs64 (const char * file, statvfs_t* buf);
77         alias statvfs64 statvfs;
78 
79         int fstatvfs64 (int fildes, statvfs_t *buf) @trusted;
80         alias fstatvfs64 fstatvfs;
81     }
82     else
83     {
84         int statvfs (const char * file, statvfs_t* buf);
85         int fstatvfs (int fildes, statvfs_t *buf);
86     }
87 
88 }
89 else version (NetBSD)
90 {
91     enum  _VFS_MNAMELEN = 1024;
92     enum  _VFS_NAMELEN = 32;
93 
94     struct fsid_t
95     {
96        int[2] __fsid_val;
97     }
98 
99     struct statvfs_t
100     {
101         c_ulong f_flag;
102         c_ulong f_bsize;
103         c_ulong f_frsize;
104         c_ulong f_iosize;
105         fsblkcnt_t f_blocks;
106         fsblkcnt_t f_bfree;
107         fsblkcnt_t f_bavail;
108         fsblkcnt_t f_bresvd;
109         fsfilcnt_t f_files;
110         fsfilcnt_t f_ffree;
111         fsfilcnt_t f_favail;
112         fsfilcnt_t f_fresvd;
113         ulong f_syncreads;
114         ulong f_syncwrites;
115         ulong f_asyncreads;
116         ulong f_asyncwrites;
117         fsid_t f_fsidx;
118         c_ulong f_fsid;
119         c_ulong f_namemax;
120         int f_owner;
121         int[4] f_spare;
122         char[_VFS_NAMELEN] f_fstypename = 0;
123         char[_VFS_MNAMELEN] f_mntonname = 0;
124         char[_VFS_MNAMELEN] f_mntfromname = 0;
125     }
126 
127     enum FFlag
128     {
129         ST_RDONLY = 1,        /* Mount read-only.  */
130         ST_NOSUID = 2
131     }
132 
133     int statvfs (const char * file, statvfs_t* buf);
134     int fstatvfs (int fildes, statvfs_t *buf) @trusted;
135 }
136 else version (OpenBSD)
137 {
138     struct statvfs_t
139     {
140         c_ulong    f_bsize;
141         c_ulong    f_frsize;
142         fsblkcnt_t f_blocks;
143         fsblkcnt_t f_bfree;
144         fsblkcnt_t f_bavail;
145         fsfilcnt_t f_files;
146         fsfilcnt_t f_ffree;
147         fsfilcnt_t f_favail;
148         c_ulong    f_fsid;
149         c_ulong    f_flag;
150         c_ulong    f_namemax;
151     }
152 
153     enum uint ST_RDONLY = 1;
154     enum uint ST_NOSUID = 2;
155 
156     int statvfs (const char* file, statvfs_t* buf);
157     int fstatvfs (int fildes, statvfs_t* buf) @trusted;
158 }
159 else version (FreeBSD)
160 {
161     import core.sys.freebsd.sys.mount;
162 
163     // @@@DEPRECATED_2.091@@@
164     deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
165     alias MFSNAMELEN = core.sys.freebsd.sys.mount.MFSNAMELEN;
166 
167     // @@@DEPRECATED_2.091@@@
168     deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
169     alias MNAMELEN = core.sys.freebsd.sys.mount.MNAMELEN;
170 
171     // @@@DEPRECATED_2.091@@@
172     deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
173     alias fsid_t = core.sys.freebsd.sys.mount.fsid_t;
174 
175     // @@@DEPRECATED_2.091@@@
176     deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
177     alias statfs_t = core.sys.freebsd.sys.mount.statfs_t;
178 
179     // @@@DEPRECATED_2.091@@@
180     deprecated("Values moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
181     enum FFlag
182     {
183         // @@@DEPRECATED_2.091@@@
184         MNT_RDONLY = 1,          /* read only filesystem */
185 
186         // @@@DEPRECATED_2.091@@@
187         MNT_SYNCHRONOUS = 2,     /* fs written synchronously */
188 
189         // @@@DEPRECATED_2.091@@@
190         MNT_NOEXEC = 4,          /* can't exec from filesystem */
191 
192         // @@@DEPRECATED_2.091@@@
193         MNT_NOSUID  = 8,         /* don't honor setuid fs bits */
194 
195         // @@@DEPRECATED_2.091@@@
196         MNT_NFS4ACLS = 16,       /* enable NFS version 4 ACLs */
197 
198         // @@@DEPRECATED_2.091@@@
199         MNT_UNION = 32,          /* union with underlying fs */
200 
201         // @@@DEPRECATED_2.091@@@
202         MNT_ASYNC = 64,          /* fs written asynchronously */
203 
204         // @@@DEPRECATED_2.091@@@
205         MNT_SUIDDIR = 128,       /* special SUID dir handling */
206 
207         // @@@DEPRECATED_2.091@@@
208         MNT_SOFTDEP = 256,       /* using soft updates */
209 
210         // @@@DEPRECATED_2.091@@@
211         MNT_NOSYMFOLLOW = 512,   /* do not follow symlinks */
212 
213         // @@@DEPRECATED_2.091@@@
214         MNT_GJOURNAL = 1024,     /* GEOM journal support enabled */
215 
216         // @@@DEPRECATED_2.091@@@
217         MNT_MULTILABEL = 2048,   /* MAC support for objects */
218 
219         // @@@DEPRECATED_2.091@@@
220         MNT_ACLS = 4096,         /* ACL support enabled */
221 
222         // @@@DEPRECATED_2.091@@@
223         MNT_NOATIME = 8192,      /* dont update file access time */
224 
225         // @@@DEPRECATED_2.091@@@
226         MNT_NOCLUSTERR = 16384,  /* disable cluster read */
227 
228         // @@@DEPRECATED_2.091@@@
229         MNT_NOCLUSTERW = 32768,  /* disable cluster write */
230 
231         // @@@DEPRECATED_2.091@@@
232         MNT_SUJ = 65536,         /* using journaled soft updates */
233 
234         // @@@DEPRECATED_2.091@@@
235         MNT_AUTOMOUNTED = 131072 /* mounted by automountd(8) */
236     }
237 
238     deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
239     alias statfs = core.sys.freebsd.sys.mount.statfs;
240 
241     deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
242     alias fstatfs = core.sys.freebsd.sys.mount.fstatfs;
243 
244     struct statvfs_t
245     {
246         fsblkcnt_t f_bavail;
247         fsblkcnt_t f_bfree;
248         fsblkcnt_t f_blocks;
249         fsfilcnt_t f_favail;
250         fsfilcnt_t f_ffree;
251         fsfilcnt_t f_files;
252         ulong f_bsize;
253         ulong f_flag;
254         ulong f_frsize;
255         ulong f_fsid;
256         ulong f_namemax;
257     }
258 
259     enum uint ST_RDONLY = 0x1;
260     enum uint ST_NOSUID = 0x2;
261 
262     int fstatvfs(int, statvfs_t*);
263     int statvfs(const char*, statvfs_t*);
264 }
265 else
266 {
267     struct statvfs_t
268     {
269         c_ulong f_bsize;
270         c_ulong f_frsize;
271         fsblkcnt_t f_blocks;
272         fsblkcnt_t f_bfree;
273         fsblkcnt_t f_bavail;
274         fsfilcnt_t f_files;
275         fsfilcnt_t f_ffree;
276         fsfilcnt_t f_favail;
277         c_ulong f_fsid;
278         c_ulong f_flag;
279         c_ulong f_namemax;
280     }
281 
282     enum FFlag
283     {
284         ST_RDONLY = 1,        /* Mount read-only.  */
285         ST_NOSUID = 2
286     }
287 
288     int statvfs (const char * file, statvfs_t* buf);
289     int fstatvfs (int fildes, statvfs_t *buf) @trusted;
290 }
291