1 /*
2  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
3  *
4  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5  */
6 
7 #ifndef _SYS_STATFS_H
8 # error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
9 #endif
10 
11 #include <endian.h>
12 #include <bits/align64bit.h>
13 #include <bits/types.h>
14 #include <bits/wordsize.h>
15 
16 /* 64-bit libc uses the kernel's 'struct statfs', accessed via the
17    statfs() syscall; 32-bit libc uses the kernel's 'struct statfs64'
18    and accesses it via the statfs64() syscall.  All the various
19    APIs offered by libc use the kernel shape for their struct statfs
20    structure; the only difference is that 32-bit programs not
21    using __USE_FILE_OFFSET64 only see the low 32 bits of some
22    of the fields (the __fsblkcnt_t and __fsfilcnt_t fields).  */
23 
24 #if defined __USE_FILE_OFFSET64
25 # define __field64(type, type64, name) type64 name
26 #elif __WORDSIZE == 64
27 # define __field64(type, type64, name) type name
28 #elif __BYTE_ORDER == __LITTLE_ENDIAN
29 # define __field64(type, type64, name) \
30   type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad
31 #else
32 # define __field64(type, type64, name) \
33   int __##name##_pad __attribute__((__aligned__ (__alignof__ (type64)))); type name
34 #endif
35 
36 struct statfs
37   {
38     __SWORD_TYPE f_type;
39     __SWORD_TYPE f_bsize;
40     __field64(__fsblkcnt_t, __fsblkcnt64_t, f_blocks);
41     __field64(__fsblkcnt_t, __fsblkcnt64_t, f_bfree);
42     __field64(__fsblkcnt_t, __fsblkcnt64_t, f_bavail);
43     __field64(__fsfilcnt_t, __fsfilcnt64_t, f_files);
44     __field64(__fsfilcnt_t, __fsfilcnt64_t, f_ffree);
45     __fsid_t f_fsid;
46     __SWORD_TYPE f_namelen;
47     __SWORD_TYPE f_frsize;
48     __SWORD_TYPE f_flags;
49     __SWORD_TYPE f_spare[4];
50   };
51 
52 #undef __field64
53 
54 #ifdef __USE_LARGEFILE64
55 struct statfs64
56   {
57     __SWORD_TYPE f_type;
58     __SWORD_TYPE f_bsize;
59     __U64_TYPE f_blocks;
60     __U64_TYPE f_bfree;
61     __U64_TYPE f_bavail;
62     __U64_TYPE f_files;
63     __U64_TYPE f_ffree;
64     __fsid_t f_fsid;
65     __SWORD_TYPE f_namelen;
66     __SWORD_TYPE f_frsize;
67     __SWORD_TYPE f_flags;
68     __SWORD_TYPE f_spare[4];
69   };
70 #endif
71 
72 /* Tell code we have these members.  */
73 #define _STATFS_F_NAMELEN
74 #define _STATFS_F_FRSIZE
75