blob: 5d078bee64204cdbac8b4dfa7daaf95380b8cb68 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*
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 Hughesc296e4f2014-09-19 20:36:03 -070028
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080029#ifndef _SYS_VFS_H_
30#define _SYS_VFS_H_
31
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080032#include <sys/cdefs.h>
Elliott Hughes414dd2d2024-10-16 14:48:30 +000033
34#include <stdint.h>
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080035#include <sys/types.h>
36
37__BEGIN_DECLS
38
Elliott Hughes01a700e2013-09-30 21:57:07 -070039/* The kernel's __kernel_fsid_t has a 'val' member but glibc uses '__val'. */
40typedef struct { int __val[2]; } __fsid_t;
Elliott Hughesabfc88f2014-01-07 17:44:51 -080041typedef __fsid_t fsid_t;
Elliott Hughes01a700e2013-09-30 21:57:07 -070042
Elliott Hughes5ac438e2020-02-13 15:56:31 -080043#if defined(__LP64__)
Elliott Hughesad58cc72024-08-29 12:06:27 -040044/* We can't just use the kernel struct statfs directly here because
45 * it's reused for both struct statfs *and* struct statfs64. */
Elliott Hughesdb1ea342014-01-17 18:42:49 -080046#define __STATFS64_BODY \
47 uint64_t f_type; \
48 uint64_t f_bsize; \
49 uint64_t f_blocks; \
50 uint64_t f_bfree; \
51 uint64_t f_bavail; \
52 uint64_t f_files; \
53 uint64_t f_ffree; \
54 fsid_t f_fsid; \
55 uint64_t f_namelen; \
56 uint64_t f_frsize; \
57 uint64_t f_flags; \
58 uint64_t f_spare[4]; \
59
Raghu Gandham6437eac2012-08-02 16:50:10 -070060#else
Elliott Hughesc7fdee72013-10-18 17:00:11 -070061/* 32-bit ARM or x86 (corresponds to the kernel's statfs64 type). */
Elliott Hughesdb1ea342014-01-17 18:42:49 -080062#define __STATFS64_BODY \
63 uint32_t f_type; \
64 uint32_t f_bsize; \
65 uint64_t f_blocks; \
66 uint64_t f_bfree; \
67 uint64_t f_bavail; \
68 uint64_t f_files; \
69 uint64_t f_ffree; \
70 fsid_t f_fsid; \
71 uint32_t f_namelen; \
72 uint32_t f_frsize; \
73 uint32_t f_flags; \
74 uint32_t f_spare[4]; \
75
Raghu Gandham6437eac2012-08-02 16:50:10 -070076#endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080077
Elliott Hughesdb1ea342014-01-17 18:42:49 -080078struct statfs { __STATFS64_BODY };
79struct statfs64 { __STATFS64_BODY };
Elliott Hughes01a700e2013-09-30 21:57:07 -070080
Calin Juravlef963da22014-05-13 11:01:11 +010081#undef __STATFS64_BODY
82
Elliott Hughes01a700e2013-09-30 21:57:07 -070083/* Declare that we have the f_namelen, f_frsize, and f_flags fields. */
84#define _STATFS_F_NAMELEN
85#define _STATFS_F_FRSIZE
86#define _STATFS_F_FLAGS
87
Elliott Hughesc296e4f2014-09-19 20:36:03 -070088/* Pull in the kernel magic numbers. */
89#include <linux/magic.h>
90/* Add in ones that we had historically that aren't in the uapi header. */
91#define BEFS_SUPER_MAGIC 0x42465331
92#define BFS_MAGIC 0x1BADFACE
93#define CIFS_MAGIC_NUMBER 0xFF534D42
94#define COH_SUPER_MAGIC 0x012FF7B7
95#define DEVFS_SUPER_MAGIC 0x1373
96#define EXT_SUPER_MAGIC 0x137D
97#define EXT2_OLD_SUPER_MAGIC 0xEF51
98#define HFS_SUPER_MAGIC 0x4244
99#define JFS_SUPER_MAGIC 0x3153464a
100#define NTFS_SB_MAGIC 0x5346544e
101#define ROMFS_MAGIC 0x7275
102#define SYSV2_SUPER_MAGIC 0x012FF7B6
103#define SYSV4_SUPER_MAGIC 0x012FF7B5
104#define UDF_SUPER_MAGIC 0x15013346
105#define UFS_MAGIC 0x00011954
106#define VXFS_SUPER_MAGIC 0xa501FCF5
107#define XENIX_SUPER_MAGIC 0x012FF7B4
108#define XFS_SUPER_MAGIC 0x58465342
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800109
zijunzhao557d9a52023-02-15 23:22:10 +0000110int statfs(const char* _Nonnull __path, struct statfs* _Nonnull __buf);
Elliott Hughes655e4302023-06-16 12:39:33 -0700111int statfs64(const char* _Nonnull __path, struct statfs64* _Nonnull __buf);
zijunzhao557d9a52023-02-15 23:22:10 +0000112int fstatfs(int __fd, struct statfs* _Nonnull __buf);
Elliott Hughes655e4302023-06-16 12:39:33 -0700113int fstatfs64(int __fd, struct statfs64* _Nonnull __buf);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800114
115__END_DECLS
116
Elliott Hughesff26a162017-08-17 22:34:21 +0000117#endif