The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * * Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * * Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in |
| 12 | * the documentation and/or other materials provided with the |
| 13 | * distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 26 | * SUCH DAMAGE. |
| 27 | */ |
| 28 | #ifndef _SYS_VFS_H_ |
| 29 | #define _SYS_VFS_H_ |
| 30 | |
| 31 | #include <stdint.h> |
| 32 | #include <sys/cdefs.h> |
| 33 | #include <sys/types.h> |
| 34 | |
| 35 | __BEGIN_DECLS |
| 36 | |
Elliott Hughes | 01a700e | 2013-09-30 21:57:07 -0700 | [diff] [blame] | 37 | /* The kernel's __kernel_fsid_t has a 'val' member but glibc uses '__val'. */ |
| 38 | typedef struct { int __val[2]; } __fsid_t; |
Elliott Hughes | abfc88f | 2014-01-07 17:44:51 -0800 | [diff] [blame] | 39 | typedef __fsid_t fsid_t; |
Elliott Hughes | 01a700e | 2013-09-30 21:57:07 -0700 | [diff] [blame] | 40 | |
Chris Dearman | 645d031 | 2014-02-05 18:51:43 -0800 | [diff] [blame] | 41 | #if defined(__aarch64__) || defined(__x86_64__) |
Raghu Gandham | 6437eac | 2012-08-02 16:50:10 -0700 | [diff] [blame] | 42 | struct statfs { |
Elliott Hughes | c7fdee7 | 2013-10-18 17:00:11 -0700 | [diff] [blame] | 43 | uint64_t f_type; |
| 44 | uint64_t f_bsize; |
| 45 | uint64_t f_blocks; |
| 46 | uint64_t f_bfree; |
| 47 | uint64_t f_bavail; |
| 48 | uint64_t f_files; |
| 49 | uint64_t f_ffree; |
Elliott Hughes | abfc88f | 2014-01-07 17:44:51 -0800 | [diff] [blame] | 50 | fsid_t f_fsid; |
Elliott Hughes | c7fdee7 | 2013-10-18 17:00:11 -0700 | [diff] [blame] | 51 | uint64_t f_namelen; |
| 52 | uint64_t f_frsize; |
| 53 | uint64_t f_flags; |
| 54 | uint64_t f_spare[4]; |
| 55 | }; |
Chris Dearman | 645d031 | 2014-02-05 18:51:43 -0800 | [diff] [blame] | 56 | #elif defined(__mips__) && defined(__LP64__) |
| 57 | /* 64-bit MIPS. */ |
| 58 | struct statfs { |
| 59 | uint64_t f_type; |
| 60 | uint64_t f_bsize; |
| 61 | uint64_t f_frsize; /* Fragment size - unsupported. */ |
| 62 | uint64_t f_blocks; |
| 63 | uint64_t f_bfree; |
| 64 | uint64_t f_files; |
| 65 | uint64_t f_ffree; |
| 66 | uint64_t f_bavail; |
| 67 | fsid_t f_fsid; |
| 68 | uint64_t f_namelen; |
| 69 | uint64_t f_flags; |
| 70 | uint64_t f_spare[5]; |
| 71 | }; |
Elliott Hughes | c7fdee7 | 2013-10-18 17:00:11 -0700 | [diff] [blame] | 72 | #elif defined(__mips__) |
| 73 | /* 32-bit MIPS (corresponds to the kernel's statfs64 type). */ |
| 74 | struct statfs { |
| 75 | uint32_t f_type; |
| 76 | uint32_t f_bsize; |
| 77 | uint32_t f_frsize; |
| 78 | uint32_t __pad; |
| 79 | uint64_t f_blocks; |
| 80 | uint64_t f_bfree; |
| 81 | uint64_t f_files; |
| 82 | uint64_t f_ffree; |
| 83 | uint64_t f_bavail; |
Elliott Hughes | abfc88f | 2014-01-07 17:44:51 -0800 | [diff] [blame] | 84 | fsid_t f_fsid; |
Elliott Hughes | c7fdee7 | 2013-10-18 17:00:11 -0700 | [diff] [blame] | 85 | uint32_t f_namelen; |
| 86 | uint32_t f_flags; |
| 87 | uint32_t f_spare[5]; |
Raghu Gandham | 6437eac | 2012-08-02 16:50:10 -0700 | [diff] [blame] | 88 | }; |
| 89 | #else |
Elliott Hughes | c7fdee7 | 2013-10-18 17:00:11 -0700 | [diff] [blame] | 90 | /* 32-bit ARM or x86 (corresponds to the kernel's statfs64 type). */ |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 91 | struct statfs { |
Elliott Hughes | c7fdee7 | 2013-10-18 17:00:11 -0700 | [diff] [blame] | 92 | uint32_t f_type; |
| 93 | uint32_t f_bsize; |
| 94 | uint64_t f_blocks; |
| 95 | uint64_t f_bfree; |
| 96 | uint64_t f_bavail; |
| 97 | uint64_t f_files; |
| 98 | uint64_t f_ffree; |
Elliott Hughes | abfc88f | 2014-01-07 17:44:51 -0800 | [diff] [blame] | 99 | fsid_t f_fsid; |
Elliott Hughes | c7fdee7 | 2013-10-18 17:00:11 -0700 | [diff] [blame] | 100 | uint32_t f_namelen; |
| 101 | uint32_t f_frsize; |
| 102 | uint32_t f_flags; |
| 103 | uint32_t f_spare[4]; |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 104 | }; |
Raghu Gandham | 6437eac | 2012-08-02 16:50:10 -0700 | [diff] [blame] | 105 | #endif |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 106 | |
Elliott Hughes | 01a700e | 2013-09-30 21:57:07 -0700 | [diff] [blame] | 107 | /* Source compatibility with glibc. */ |
| 108 | #define statfs64 statfs |
| 109 | |
| 110 | /* Declare that we have the f_namelen, f_frsize, and f_flags fields. */ |
| 111 | #define _STATFS_F_NAMELEN |
| 112 | #define _STATFS_F_FRSIZE |
| 113 | #define _STATFS_F_FLAGS |
| 114 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 115 | #define ADFS_SUPER_MAGIC 0xadf5 |
| 116 | #define AFFS_SUPER_MAGIC 0xADFF |
| 117 | #define BEFS_SUPER_MAGIC 0x42465331 |
| 118 | #define BFS_MAGIC 0x1BADFACE |
| 119 | #define CIFS_MAGIC_NUMBER 0xFF534D42 |
| 120 | #define CODA_SUPER_MAGIC 0x73757245 |
| 121 | #define COH_SUPER_MAGIC 0x012FF7B7 |
| 122 | #define CRAMFS_MAGIC 0x28cd3d45 |
| 123 | #define DEVFS_SUPER_MAGIC 0x1373 |
| 124 | #define EFS_SUPER_MAGIC 0x00414A53 |
| 125 | #define EXT_SUPER_MAGIC 0x137D |
| 126 | #define EXT2_OLD_SUPER_MAGIC 0xEF51 |
| 127 | #define EXT2_SUPER_MAGIC 0xEF53 |
| 128 | #define EXT3_SUPER_MAGIC 0xEF53 |
| 129 | #define HFS_SUPER_MAGIC 0x4244 |
| 130 | #define HPFS_SUPER_MAGIC 0xF995E849 |
| 131 | #define HUGETLBFS_MAGIC 0x958458f6 |
| 132 | #define ISOFS_SUPER_MAGIC 0x9660 |
| 133 | #define JFFS2_SUPER_MAGIC 0x72b6 |
| 134 | #define JFS_SUPER_MAGIC 0x3153464a |
| 135 | #define MINIX_SUPER_MAGIC 0x137F /* orig. minix */ |
| 136 | #define MINIX_SUPER_MAGIC2 0x138F /* 30 char minix */ |
| 137 | #define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 */ |
| 138 | #define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2, 30 char names */ |
| 139 | #define MSDOS_SUPER_MAGIC 0x4d44 |
| 140 | #define NCP_SUPER_MAGIC 0x564c |
| 141 | #define NFS_SUPER_MAGIC 0x6969 |
| 142 | #define NTFS_SB_MAGIC 0x5346544e |
| 143 | #define OPENPROM_SUPER_MAGIC 0x9fa1 |
| 144 | #define PROC_SUPER_MAGIC 0x9fa0 |
| 145 | #define QNX4_SUPER_MAGIC 0x002f |
| 146 | #define REISERFS_SUPER_MAGIC 0x52654973 |
| 147 | #define ROMFS_MAGIC 0x7275 |
| 148 | #define SMB_SUPER_MAGIC 0x517B |
| 149 | #define SYSV2_SUPER_MAGIC 0x012FF7B6 |
| 150 | #define SYSV4_SUPER_MAGIC 0x012FF7B5 |
| 151 | #define TMPFS_MAGIC 0x01021994 |
| 152 | #define UDF_SUPER_MAGIC 0x15013346 |
| 153 | #define UFS_MAGIC 0x00011954 |
| 154 | #define USBDEVICE_SUPER_MAGIC 0x9fa2 |
| 155 | #define VXFS_SUPER_MAGIC 0xa501FCF5 |
| 156 | #define XENIX_SUPER_MAGIC 0x012FF7B4 |
| 157 | #define XFS_SUPER_MAGIC 0x58465342 |
| 158 | #define _XIAFS_SUPER_MAGIC 0x012FD16D |
| 159 | |
Elliott Hughes | 01a700e | 2013-09-30 21:57:07 -0700 | [diff] [blame] | 160 | extern int statfs(const char*, struct statfs*) __nonnull((1, 2)); |
| 161 | extern int fstatfs(int, struct statfs*) __nonnull((2)); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 162 | |
| 163 | __END_DECLS |
| 164 | |
| 165 | #endif /* _SYS_VFS_H_ */ |