]>
Commit | Line | Data |
---|---|---|
0b61f8a4 | 1 | // SPDX-License-Identifier: GPL-2.0 |
1da177e4 | 2 | /* |
7b718769 NS |
3 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
4 | * All Rights Reserved. | |
1da177e4 LT |
5 | */ |
6 | #ifndef __XFS_TYPES_H__ | |
7 | #define __XFS_TYPES_H__ | |
8 | ||
c8ce540d | 9 | typedef uint32_t prid_t; /* project ID */ |
d386b32b | 10 | |
c8ce540d DW |
11 | typedef uint32_t xfs_agblock_t; /* blockno in alloc. group */ |
12 | typedef uint32_t xfs_agino_t; /* inode # within allocation grp */ | |
13 | typedef uint32_t xfs_extlen_t; /* extent length in blocks */ | |
14 | typedef uint32_t xfs_agnumber_t; /* allocation group number */ | |
15 | typedef int32_t xfs_extnum_t; /* # of extents in a file */ | |
16 | typedef int16_t xfs_aextnum_t; /* # extents in an attribute fork */ | |
17 | typedef int64_t xfs_fsize_t; /* bytes in a file */ | |
18 | typedef uint64_t xfs_ufsize_t; /* unsigned bytes in a file */ | |
1da177e4 | 19 | |
c8ce540d | 20 | typedef int32_t xfs_suminfo_t; /* type of bitmap summary info */ |
2483113f | 21 | typedef uint32_t xfs_rtword_t; /* word type for bitmap manipulations */ |
1da177e4 | 22 | |
c8ce540d | 23 | typedef int64_t xfs_lsn_t; /* log sequence number */ |
5f9b4b0d | 24 | typedef int64_t xfs_csn_t; /* CIL sequence number */ |
1da177e4 | 25 | |
c8ce540d DW |
26 | typedef uint32_t xfs_dablk_t; /* dir/attr block number (in file) */ |
27 | typedef uint32_t xfs_dahash_t; /* dir/attr hash value */ | |
1da177e4 | 28 | |
c8ce540d DW |
29 | typedef uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */ |
30 | typedef uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ | |
31 | typedef uint64_t xfs_rtblock_t; /* extent (block) in realtime area */ | |
32 | typedef uint64_t xfs_fileoff_t; /* block number in a file */ | |
33 | typedef uint64_t xfs_filblks_t; /* number of blocks in a file */ | |
1da177e4 | 34 | |
c8ce540d | 35 | typedef int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ |
60a34607 | 36 | |
52c732ee DW |
37 | /* |
38 | * New verifiers will return the instruction address of the failing check. | |
39 | * NULL means everything is ok. | |
40 | */ | |
41 | typedef void * xfs_failaddr_t; | |
42 | ||
1da177e4 LT |
43 | /* |
44 | * Null values for the types. | |
45 | */ | |
1da177e4 LT |
46 | #define NULLFSBLOCK ((xfs_fsblock_t)-1) |
47 | #define NULLRFSBLOCK ((xfs_rfsblock_t)-1) | |
48 | #define NULLRTBLOCK ((xfs_rtblock_t)-1) | |
49 | #define NULLFILEOFF ((xfs_fileoff_t)-1) | |
50 | ||
51 | #define NULLAGBLOCK ((xfs_agblock_t)-1) | |
52 | #define NULLAGNUMBER ((xfs_agnumber_t)-1) | |
1da177e4 LT |
53 | |
54 | #define NULLCOMMITLSN ((xfs_lsn_t)-1) | |
55 | ||
60a34607 DC |
56 | #define NULLFSINO ((xfs_ino_t)-1) |
57 | #define NULLAGINO ((xfs_agino_t)-1) | |
58 | ||
1da177e4 LT |
59 | /* |
60 | * Max values for extlen, extnum, aextnum. | |
61 | */ | |
62 | #define MAXEXTLEN ((xfs_extlen_t)0x001fffff) /* 21 bits */ | |
63 | #define MAXEXTNUM ((xfs_extnum_t)0x7fffffff) /* signed int */ | |
64 | #define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */ | |
65 | ||
77c1a08f DC |
66 | /* |
67 | * Minimum and maximum blocksize and sectorsize. | |
68 | * The blocksize upper limit is pretty much arbitrary. | |
69 | * The sectorsize upper limit is due to sizeof(sb_sectsize). | |
bec9d48d DW |
70 | * CRC enable filesystems use 512 byte inodes, meaning 512 byte block sizes |
71 | * cannot be used. | |
77c1a08f DC |
72 | */ |
73 | #define XFS_MIN_BLOCKSIZE_LOG 9 /* i.e. 512 bytes */ | |
74 | #define XFS_MAX_BLOCKSIZE_LOG 16 /* i.e. 65536 bytes */ | |
75 | #define XFS_MIN_BLOCKSIZE (1 << XFS_MIN_BLOCKSIZE_LOG) | |
76 | #define XFS_MAX_BLOCKSIZE (1 << XFS_MAX_BLOCKSIZE_LOG) | |
bec9d48d | 77 | #define XFS_MIN_CRC_BLOCKSIZE (1 << (XFS_MIN_BLOCKSIZE_LOG + 1)) |
77c1a08f DC |
78 | #define XFS_MIN_SECTORSIZE_LOG 9 /* i.e. 512 bytes */ |
79 | #define XFS_MAX_SECTORSIZE_LOG 15 /* i.e. 32768 bytes */ | |
80 | #define XFS_MIN_SECTORSIZE (1 << XFS_MIN_SECTORSIZE_LOG) | |
81 | #define XFS_MAX_SECTORSIZE (1 << XFS_MAX_SECTORSIZE_LOG) | |
82 | ||
69432832 DC |
83 | /* |
84 | * Inode fork identifiers. | |
85 | */ | |
86 | #define XFS_DATA_FORK 0 | |
87 | #define XFS_ATTR_FORK 1 | |
3993baeb | 88 | #define XFS_COW_FORK 2 |
69432832 | 89 | |
f93f85f7 DW |
90 | #define XFS_WHICHFORK_STRINGS \ |
91 | { XFS_DATA_FORK, "data" }, \ | |
92 | { XFS_ATTR_FORK, "attr" }, \ | |
93 | { XFS_COW_FORK, "cow" } | |
94 | ||
d8cc890d NS |
95 | /* |
96 | * Min numbers of data/attr fork btree root pointers. | |
97 | */ | |
98 | #define MINDBTPTRS 3 | |
99 | #define MINABTPTRS 2 | |
100 | ||
1da177e4 LT |
101 | /* |
102 | * MAXNAMELEN is the length (including the terminating null) of | |
103 | * the longest permissible file (component) name. | |
104 | */ | |
105 | #define MAXNAMELEN 256 | |
106 | ||
85f8dff0 DW |
107 | /* |
108 | * This enum is used in string mapping in xfs_trace.h; please keep the | |
109 | * TRACE_DEFINE_ENUMs for it up to date. | |
110 | */ | |
1da177e4 LT |
111 | typedef enum { |
112 | XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi | |
113 | } xfs_lookup_t; | |
114 | ||
05c753c4 DW |
115 | #define XFS_AG_BTREE_CMP_FORMAT_STR \ |
116 | { XFS_LOOKUP_EQi, "eq" }, \ | |
117 | { XFS_LOOKUP_LEi, "le" }, \ | |
118 | { XFS_LOOKUP_GEi, "ge" } | |
119 | ||
c494213f | 120 | /* |
86d163db DW |
121 | * This enum is used in string mapping in xfs_trace.h and scrub/trace.h; |
122 | * please keep the TRACE_DEFINE_ENUMs for it up to date. | |
c494213f | 123 | */ |
1da177e4 | 124 | typedef enum { |
b8704944 | 125 | XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_RMAPi, XFS_BTNUM_BMAPi, |
46eeb521 | 126 | XFS_BTNUM_INOi, XFS_BTNUM_FINOi, XFS_BTNUM_REFCi, XFS_BTNUM_MAX |
1da177e4 LT |
127 | } xfs_btnum_t; |
128 | ||
c494213f DW |
129 | #define XFS_BTNUM_STRINGS \ |
130 | { XFS_BTNUM_BNOi, "bnobt" }, \ | |
131 | { XFS_BTNUM_CNTi, "cntbt" }, \ | |
132 | { XFS_BTNUM_RMAPi, "rmapbt" }, \ | |
133 | { XFS_BTNUM_BMAPi, "bmbt" }, \ | |
134 | { XFS_BTNUM_INOi, "inobt" }, \ | |
135 | { XFS_BTNUM_FINOi, "finobt" }, \ | |
136 | { XFS_BTNUM_REFCi, "refcbt" } | |
137 | ||
556b8b16 | 138 | struct xfs_name { |
e2bcd936 DC |
139 | const unsigned char *name; |
140 | int len; | |
0cb97766 | 141 | int type; |
556b8b16 BN |
142 | }; |
143 | ||
6ca1c906 DC |
144 | /* |
145 | * uid_t and gid_t are hard-coded to 32 bits in the inode. | |
146 | * Hence, an 'id' in a dquot is 32 bits.. | |
147 | */ | |
c8ce540d | 148 | typedef uint32_t xfs_dqid_t; |
6ca1c906 | 149 | |
c7298202 DC |
150 | /* |
151 | * Constants for bit manipulations. | |
152 | */ | |
153 | #define XFS_NBBYLOG 3 /* log2(NBBY) */ | |
154 | #define XFS_WORDLOG 2 /* log2(sizeof(xfs_rtword_t)) */ | |
155 | #define XFS_NBWORDLOG (XFS_NBBYLOG + XFS_WORDLOG) | |
156 | #define XFS_NBWORD (1 << XFS_NBWORDLOG) | |
157 | #define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1) | |
158 | ||
b2b1712a | 159 | struct xfs_iext_cursor { |
6bdcf26a CH |
160 | struct xfs_iext_leaf *leaf; |
161 | int pos; | |
b2b1712a | 162 | }; |
c7298202 | 163 | |
866d7826 CH |
164 | typedef enum { |
165 | XFS_EXT_NORM, XFS_EXT_UNWRITTEN, | |
166 | } xfs_exntst_t; | |
167 | ||
168 | typedef struct xfs_bmbt_irec | |
169 | { | |
170 | xfs_fileoff_t br_startoff; /* starting file offset */ | |
171 | xfs_fsblock_t br_startblock; /* starting block number */ | |
172 | xfs_filblks_t br_blockcount; /* number of blocks */ | |
173 | xfs_exntst_t br_state; /* extent state */ | |
174 | } xfs_bmbt_irec_t; | |
175 | ||
0ad95687 DC |
176 | /* per-AG block reservation types */ |
177 | enum xfs_ag_resv_type { | |
178 | XFS_AG_RESV_NONE = 0, | |
179 | XFS_AG_RESV_AGFL, | |
180 | XFS_AG_RESV_METADATA, | |
181 | XFS_AG_RESV_RMAPBT, | |
182 | }; | |
183 | ||
86210fbe DC |
184 | /* |
185 | * Type verifier functions | |
186 | */ | |
187 | struct xfs_mount; | |
188 | ||
189 | xfs_agblock_t xfs_ag_block_count(struct xfs_mount *mp, xfs_agnumber_t agno); | |
190 | bool xfs_verify_agbno(struct xfs_mount *mp, xfs_agnumber_t agno, | |
191 | xfs_agblock_t agbno); | |
192 | bool xfs_verify_fsbno(struct xfs_mount *mp, xfs_fsblock_t fsbno); | |
67457eb0 DW |
193 | bool xfs_verify_fsbext(struct xfs_mount *mp, xfs_fsblock_t fsbno, |
194 | xfs_fsblock_t len); | |
86210fbe DC |
195 | |
196 | void xfs_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno, | |
197 | xfs_agino_t *first, xfs_agino_t *last); | |
198 | bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno, | |
199 | xfs_agino_t agino); | |
7d36c195 DW |
200 | bool xfs_verify_agino_or_null(struct xfs_mount *mp, xfs_agnumber_t agno, |
201 | xfs_agino_t agino); | |
86210fbe DC |
202 | bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino); |
203 | bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino); | |
204 | bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino); | |
205 | bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); | |
18695ad4 DW |
206 | bool xfs_verify_rtext(struct xfs_mount *mp, xfs_rtblock_t rtbno, |
207 | xfs_rtblock_t len); | |
69775fd1 | 208 | bool xfs_verify_icount(struct xfs_mount *mp, unsigned long long icount); |
f8c1d702 | 209 | bool xfs_verify_dablk(struct xfs_mount *mp, xfs_fileoff_t off); |
75efa57d DW |
210 | void xfs_icount_range(struct xfs_mount *mp, unsigned long long *min, |
211 | unsigned long long *max); | |
33005fd0 DW |
212 | bool xfs_verify_fileoff(struct xfs_mount *mp, xfs_fileoff_t off); |
213 | bool xfs_verify_fileext(struct xfs_mount *mp, xfs_fileoff_t off, | |
214 | xfs_fileoff_t len); | |
86210fbe | 215 | |
1da177e4 | 216 | #endif /* __XFS_TYPES_H__ */ |