1 /**
2 *    statvfs - VFS File System information structure
3 * from sys/statvfs.h
4 * http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/statvfs.h.html
5 *
6 * Copyright: Fawzi Mohamed 
7 * License:   tango license
8 * Authors:   Fawzi Mohamed
9 */
10 
11 module tango.stdc.posix.sys.statvfs;
12 import tango.stdc.config;
13 /+
14 // possible errno:
15     public import tango.sys.consts.errno:
16     EACCES, // (statfs()) Search permission is denied for a component of the path prefix of path. (See also path_resolution(2).) 
17     EBADF, // (fstatfs()) fd is not a valid open file descriptor. 
18     EFAULT, // buf or path points to an invalid address. 
19     EINTR, // This call was interrupted by a signal. 
20     EIO, // An I/O error occurred while reading from the file system. 
21     ELOOP, // (statfs()) Too many symbolic links were encountered in translating path. 
22     ENAMETOOLONG, // (statfs()) path is too long. 
23     ENOENT, // (statfs()) The file referred to by path does not exist. 
24     ENOMEM, // Insufficient kernel memory was available. 
25     ENOSYS, // The file system does not support this call. 
26     ENOTDIR, // (statfs()) A component of the path prefix of path is not a directory. 
27     EOVERFLOW // Some values were too large to be represented in the returned struct.
28 ;
29 +/
30 
31 version(OSX) {
32 
33     struct statvfs_t {
34      c_ulong f_bsize;
35      c_ulong f_frsize;
36      uint f_blocks;
37      uint f_bfree;
38      uint f_bavail;
39      uint f_files;
40      uint f_ffree;
41      uint f_favail;
42      c_ulong f_fsid;
43      c_ulong f_flag;
44      c_ulong f_namemax;
45     }
46 
47     enum{
48         ST_RDONLY=0x00000001,
49         ST_NOSUID=0x00000002,
50     }
51 }
52 
53 version( FreeBSD )
54 {
55     alias ulong __fsblkcnt_t, __fsfilcnt_t;
56     struct statvfs_t {
57         __fsblkcnt_t      f_bavail;       /* Number of blocks */
58         __fsblkcnt_t      f_bfree;
59         __fsblkcnt_t      f_blocks;
60         __fsfilcnt_t      f_favail;       /* Number of files (e.g., inodes) */
61         __fsfilcnt_t      f_ffree;
62         __fsfilcnt_t      f_files;
63         c_ulong   f_bsize;        /* Size of blocks counted above */
64         c_ulong  f_flag;
65         c_ulong   f_frsize;       /* Size of fragments */
66         c_ulong   f_fsid;         /* Not meaningful */
67         c_ulong   f_namemax;      /* Same as pathconf(_PC_NAME_MAX) */
68     }
69     enum {
70         ST_RDONLY = 1,
71         ST_NOSUID = 2,
72     }
73 }
74 
75 version(linux){
76     struct statvfs_t
77       {
78         c_ulong f_bsize;
79         c_ulong f_frsize;
80         c_ulong f_blocks;
81         c_ulong f_bfree;
82         c_ulong f_bavail;
83         c_ulong f_files;
84         c_ulong f_ffree;
85         c_ulong f_favail;
86         c_ulong f_fsid;
87         c_ulong f_flag;
88         c_ulong f_namemax;
89         int[6] __f_spare;
90       };
91     enum
92     {
93       ST_RDONLY = 1,
94       ST_NOSUID = 2,
95     }    
96 }
97 
98 version(solaris)
99 {
100     const _FSTYPSZ = 16;
101 
102     alias c_ulong fsblkcnt_t;
103     alias c_ulong fsfilcnt_t;
104 
105     struct statvfs_t {
106         c_ulong f_bsize; /* fundamental file system block size */
107         c_ulong f_frsize; /* fragment size */
108         fsblkcnt_t f_blocks; /* total blocks of f_frsize on fs */
109         fsblkcnt_t f_bfree; /* total free blocks of f_frsize */
110         fsblkcnt_t f_bavail; /* free blocks avail to non-superuser */
111         fsfilcnt_t f_files; /* total file nodes (inodes) */
112         fsfilcnt_t f_ffree; /* total free file nodes */
113         fsfilcnt_t f_favail; /* free nodes avail to non-superuser */
114         c_ulong f_fsid;  /* file system id (dev for now) */
115         char[_FSTYPSZ]  f_basetype; /* target fs type name, */
116                                                         /* null-terminated */
117         c_ulong f_flag;  /* bit-mask of flags */
118         c_ulong f_namemax; /* maximum file name length */
119         char[32] f_fstr; /* filesystem-specific string */
120         static if(size_t.sizeof == 8) //#if !defined(_LP64)
121         {
122             c_ulong[16]  f_filler; /* reserved for future expansion */
123         }
124 	};
125 
126     enum
127     {
128         ST_RDONLY = 1,
129         ST_NOSUID = 2,
130     }
131 }
132 
133 extern(C){
134     int fstatvfs(int, statvfs_t *);
135     int statvfs(in char * , statvfs_t *);
136 }