| 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 | */ | 
| Elliott Hughes | c296e4f | 2014-09-19 20:36:03 -0700 | [diff] [blame] | 28 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 29 | #ifndef _SYS_VFS_H_ | 
|  | 30 | #define _SYS_VFS_H_ | 
|  | 31 |  | 
|  | 32 | #include <stdint.h> | 
|  | 33 | #include <sys/cdefs.h> | 
|  | 34 | #include <sys/types.h> | 
|  | 35 |  | 
|  | 36 | __BEGIN_DECLS | 
|  | 37 |  | 
| Elliott Hughes | 01a700e | 2013-09-30 21:57:07 -0700 | [diff] [blame] | 38 | /* The kernel's __kernel_fsid_t has a 'val' member but glibc uses '__val'. */ | 
|  | 39 | typedef struct { int __val[2]; } __fsid_t; | 
| Elliott Hughes | abfc88f | 2014-01-07 17:44:51 -0800 | [diff] [blame] | 40 | typedef __fsid_t fsid_t; | 
| Elliott Hughes | 01a700e | 2013-09-30 21:57:07 -0700 | [diff] [blame] | 41 |  | 
| Chris Dearman | 645d031 | 2014-02-05 18:51:43 -0800 | [diff] [blame] | 42 | #if defined(__aarch64__) || defined(__x86_64__) | 
| Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 43 | #define __STATFS64_BODY \ | 
|  | 44 | uint64_t f_type; \ | 
|  | 45 | uint64_t f_bsize; \ | 
|  | 46 | uint64_t f_blocks; \ | 
|  | 47 | uint64_t f_bfree; \ | 
|  | 48 | uint64_t f_bavail; \ | 
|  | 49 | uint64_t f_files; \ | 
|  | 50 | uint64_t f_ffree; \ | 
|  | 51 | fsid_t f_fsid; \ | 
|  | 52 | uint64_t f_namelen; \ | 
|  | 53 | uint64_t f_frsize; \ | 
|  | 54 | uint64_t f_flags; \ | 
|  | 55 | uint64_t f_spare[4]; \ | 
|  | 56 |  | 
| Chris Dearman | 645d031 | 2014-02-05 18:51:43 -0800 | [diff] [blame] | 57 | #elif defined(__mips__) && defined(__LP64__) | 
|  | 58 | /* 64-bit MIPS. */ | 
| Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 59 | #define __STATFS64_BODY \ | 
|  | 60 | uint64_t f_type; \ | 
|  | 61 | uint64_t f_bsize; \ | 
|  | 62 | uint64_t f_frsize; /* Fragment size - unsupported. */ \ | 
|  | 63 | uint64_t f_blocks; \ | 
|  | 64 | uint64_t f_bfree; \ | 
|  | 65 | uint64_t f_files; \ | 
|  | 66 | uint64_t f_ffree; \ | 
|  | 67 | uint64_t f_bavail; \ | 
|  | 68 | fsid_t f_fsid; \ | 
|  | 69 | uint64_t f_namelen; \ | 
|  | 70 | uint64_t f_flags; \ | 
|  | 71 | uint64_t f_spare[5]; \ | 
|  | 72 |  | 
| Elliott Hughes | c7fdee7 | 2013-10-18 17:00:11 -0700 | [diff] [blame] | 73 | #elif defined(__mips__) | 
|  | 74 | /* 32-bit MIPS (corresponds to the kernel's statfs64 type). */ | 
| Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 75 | #define __STATFS64_BODY \ | 
|  | 76 | uint32_t f_type; \ | 
|  | 77 | uint32_t f_bsize; \ | 
|  | 78 | uint32_t f_frsize; \ | 
|  | 79 | uint32_t __pad; \ | 
|  | 80 | uint64_t f_blocks; \ | 
|  | 81 | uint64_t f_bfree; \ | 
|  | 82 | uint64_t f_files; \ | 
|  | 83 | uint64_t f_ffree; \ | 
|  | 84 | uint64_t f_bavail; \ | 
|  | 85 | fsid_t f_fsid; \ | 
|  | 86 | uint32_t f_namelen; \ | 
|  | 87 | uint32_t f_flags; \ | 
|  | 88 | uint32_t f_spare[5]; \ | 
|  | 89 |  | 
| Raghu Gandham | 6437eac | 2012-08-02 16:50:10 -0700 | [diff] [blame] | 90 | #else | 
| Elliott Hughes | c7fdee7 | 2013-10-18 17:00:11 -0700 | [diff] [blame] | 91 | /* 32-bit ARM or x86 (corresponds to the kernel's statfs64 type). */ | 
| Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 92 | #define __STATFS64_BODY \ | 
|  | 93 | uint32_t f_type; \ | 
|  | 94 | uint32_t f_bsize; \ | 
|  | 95 | uint64_t f_blocks; \ | 
|  | 96 | uint64_t f_bfree; \ | 
|  | 97 | uint64_t f_bavail; \ | 
|  | 98 | uint64_t f_files; \ | 
|  | 99 | uint64_t f_ffree; \ | 
|  | 100 | fsid_t f_fsid; \ | 
|  | 101 | uint32_t f_namelen; \ | 
|  | 102 | uint32_t f_frsize; \ | 
|  | 103 | uint32_t f_flags; \ | 
|  | 104 | uint32_t f_spare[4]; \ | 
|  | 105 |  | 
| Raghu Gandham | 6437eac | 2012-08-02 16:50:10 -0700 | [diff] [blame] | 106 | #endif | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 107 |  | 
| Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 108 | struct statfs { __STATFS64_BODY }; | 
|  | 109 | struct statfs64 { __STATFS64_BODY }; | 
| Elliott Hughes | 01a700e | 2013-09-30 21:57:07 -0700 | [diff] [blame] | 110 |  | 
| Calin Juravle | f963da2 | 2014-05-13 11:01:11 +0100 | [diff] [blame] | 111 | #undef __STATFS64_BODY | 
|  | 112 |  | 
| Elliott Hughes | 01a700e | 2013-09-30 21:57:07 -0700 | [diff] [blame] | 113 | /* Declare that we have the f_namelen, f_frsize, and f_flags fields. */ | 
|  | 114 | #define _STATFS_F_NAMELEN | 
|  | 115 | #define _STATFS_F_FRSIZE | 
|  | 116 | #define _STATFS_F_FLAGS | 
|  | 117 |  | 
| Elliott Hughes | c296e4f | 2014-09-19 20:36:03 -0700 | [diff] [blame] | 118 | /* Pull in the kernel magic numbers. */ | 
|  | 119 | #include <linux/magic.h> | 
|  | 120 | /* Add in ones that we had historically that aren't in the uapi header. */ | 
|  | 121 | #define BEFS_SUPER_MAGIC      0x42465331 | 
|  | 122 | #define BFS_MAGIC             0x1BADFACE | 
|  | 123 | #define CIFS_MAGIC_NUMBER     0xFF534D42 | 
|  | 124 | #define COH_SUPER_MAGIC       0x012FF7B7 | 
|  | 125 | #define DEVFS_SUPER_MAGIC     0x1373 | 
|  | 126 | #define EXT_SUPER_MAGIC       0x137D | 
|  | 127 | #define EXT2_OLD_SUPER_MAGIC  0xEF51 | 
|  | 128 | #define HFS_SUPER_MAGIC       0x4244 | 
|  | 129 | #define JFS_SUPER_MAGIC       0x3153464a | 
|  | 130 | #define NTFS_SB_MAGIC         0x5346544e | 
|  | 131 | #define ROMFS_MAGIC           0x7275 | 
|  | 132 | #define SYSV2_SUPER_MAGIC     0x012FF7B6 | 
|  | 133 | #define SYSV4_SUPER_MAGIC     0x012FF7B5 | 
|  | 134 | #define UDF_SUPER_MAGIC       0x15013346 | 
|  | 135 | #define UFS_MAGIC             0x00011954 | 
|  | 136 | #define VXFS_SUPER_MAGIC      0xa501FCF5 | 
|  | 137 | #define XENIX_SUPER_MAGIC     0x012FF7B4 | 
|  | 138 | #define XFS_SUPER_MAGIC       0x58465342 | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 139 |  | 
| Elliott Hughes | 01a700e | 2013-09-30 21:57:07 -0700 | [diff] [blame] | 140 | extern int statfs(const char*, struct statfs*) __nonnull((1, 2)); | 
| Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 141 | extern int statfs64(const char*, struct statfs64*) __nonnull((1, 2)); | 
| Elliott Hughes | 01a700e | 2013-09-30 21:57:07 -0700 | [diff] [blame] | 142 | extern int fstatfs(int, struct statfs*) __nonnull((2)); | 
| Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 143 | extern int fstatfs64(int, struct statfs64*) __nonnull((2)); | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 144 |  | 
|  | 145 | __END_DECLS | 
|  | 146 |  | 
|  | 147 | #endif /* _SYS_VFS_H_ */ |