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     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     struct statvfs_t
162     {
163         fsblkcnt_t f_bavail;
164         fsblkcnt_t f_bfree;
165         fsblkcnt_t f_blocks;
166         fsfilcnt_t f_favail;
167         fsfilcnt_t f_ffree;
168         fsfilcnt_t f_files;
169         ulong f_bsize;
170         ulong f_flag;
171         ulong f_frsize;
172         ulong f_fsid;
173         ulong f_namemax;
174     }
175 
176     enum uint ST_RDONLY = 0x1;
177     enum uint ST_NOSUID = 0x2;
178 
179     version (GNU)
180     {
181         int fstatvfs(int, statvfs_t*);
182         int statvfs(const char*, statvfs_t*);
183     }
184     else
185     {
186         pragma(mangle, "fstatvfs@FBSD_1.0") int fstatvfs(int, statvfs_t*);
187         pragma(mangle, "statvfs@FBSD_1.0")  int statvfs(const char*, statvfs_t*);
188     }
189 }
190 else
191 {
192     struct statvfs_t
193     {
194         c_ulong f_bsize;
195         c_ulong f_frsize;
196         fsblkcnt_t f_blocks;
197         fsblkcnt_t f_bfree;
198         fsblkcnt_t f_bavail;
199         fsfilcnt_t f_files;
200         fsfilcnt_t f_ffree;
201         fsfilcnt_t f_favail;
202         c_ulong f_fsid;
203         c_ulong f_flag;
204         c_ulong f_namemax;
205     }
206 
207     enum FFlag
208     {
209         ST_RDONLY = 1,        /* Mount read-only.  */
210         ST_NOSUID = 2
211     }
212 
213     int statvfs (const char * file, statvfs_t* buf);
214     int fstatvfs (int fildes, statvfs_t *buf) @trusted;
215 }