Better statfs/fstatfs glibc compatibility.
Change-Id: I069d169c96cd71b75a045ec911fb4bd484c6b2c9
diff --git a/libc/include/sys/vfs.h b/libc/include/sys/vfs.h
index 6a55c99..6fce3b4 100644
--- a/libc/include/sys/vfs.h
+++ b/libc/include/sys/vfs.h
@@ -34,40 +34,51 @@
__BEGIN_DECLS
-/* These correspond to the kernel's statfs64 type. */
+/* The kernel's __kernel_fsid_t has a 'val' member but glibc uses '__val'. */
+typedef struct { int __val[2]; } __fsid_t;
+
+/* Our struct statfs corresponds to the kernel's statfs64 type. */
#ifdef __mips__
struct statfs {
- uint32_t f_type;
- uint32_t f_bsize;
- uint32_t f_frsize;
- uint32_t __pad;
- uint64_t f_blocks;
- uint64_t f_bfree;
- uint64_t f_files;
- uint64_t f_ffree;
- uint64_t f_bavail;
- __kernel_fsid_t f_fsid;
- uint32_t f_namelen;
- uint32_t f_flags;
- uint32_t f_spare[5];
+ uint32_t f_type;
+ uint32_t f_bsize;
+ uint32_t f_frsize;
+ uint32_t __pad;
+ uint64_t f_blocks;
+ uint64_t f_bfree;
+ uint64_t f_files;
+ uint64_t f_ffree;
+ uint64_t f_bavail;
+ __fsid_t f_fsid;
+ uint32_t f_namelen;
+ uint32_t f_flags;
+ uint32_t f_spare[5];
};
#else
struct statfs {
- uint32_t f_type;
- uint32_t f_bsize;
- uint64_t f_blocks;
- uint64_t f_bfree;
- uint64_t f_bavail;
- uint64_t f_files;
- uint64_t f_ffree;
- __kernel_fsid_t f_fsid;
- uint32_t f_namelen;
- uint32_t f_frsize;
- uint32_t f_flags;
- uint32_t f_spare[4];
+ uint32_t f_type;
+ uint32_t f_bsize;
+ uint64_t f_blocks;
+ uint64_t f_bfree;
+ uint64_t f_bavail;
+ uint64_t f_files;
+ uint64_t f_ffree;
+ __fsid_t f_fsid;
+ uint32_t f_namelen;
+ uint32_t f_frsize;
+ uint32_t f_flags;
+ uint32_t f_spare[4];
};
#endif
+/* Source compatibility with glibc. */
+#define statfs64 statfs
+
+/* Declare that we have the f_namelen, f_frsize, and f_flags fields. */
+#define _STATFS_F_NAMELEN
+#define _STATFS_F_FRSIZE
+#define _STATFS_F_FLAGS
+
#define ADFS_SUPER_MAGIC 0xadf5
#define AFFS_SUPER_MAGIC 0xADFF
#define BEFS_SUPER_MAGIC 0x42465331
@@ -113,8 +124,8 @@
#define XFS_SUPER_MAGIC 0x58465342
#define _XIAFS_SUPER_MAGIC 0x012FD16D
-extern int statfs(const char *, struct statfs *);
-extern int fstatfs(int, struct statfs *);
+extern int statfs(const char*, struct statfs*) __nonnull((1, 2));
+extern int fstatfs(int, struct statfs*) __nonnull((2));
__END_DECLS