1
2
3
4
5
6#ifndef __XFS_TYPES_H__
7#define __XFS_TYPES_H__
8
9typedef uint32_t prid_t;
10
11typedef uint32_t xfs_agblock_t;
12typedef uint32_t xfs_agino_t;
13typedef uint32_t xfs_extlen_t;
14typedef uint32_t xfs_agnumber_t;
15typedef int32_t xfs_extnum_t;
16typedef int16_t xfs_aextnum_t;
17typedef int64_t xfs_fsize_t;
18typedef uint64_t xfs_ufsize_t;
19
20typedef int32_t xfs_suminfo_t;
21typedef uint32_t xfs_rtword_t;
22
23typedef int64_t xfs_lsn_t;
24typedef int64_t xfs_csn_t;
25
26typedef uint32_t xfs_dablk_t;
27typedef uint32_t xfs_dahash_t;
28
29typedef uint64_t xfs_fsblock_t;
30typedef uint64_t xfs_rfsblock_t;
31typedef uint64_t xfs_rtblock_t;
32typedef uint64_t xfs_fileoff_t;
33typedef uint64_t xfs_filblks_t;
34
35typedef int64_t xfs_srtblock_t;
36
37
38
39
40
41typedef void * xfs_failaddr_t;
42
43
44
45
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)
53
54#define NULLCOMMITLSN ((xfs_lsn_t)-1)
55
56#define NULLFSINO ((xfs_ino_t)-1)
57#define NULLAGINO ((xfs_agino_t)-1)
58
59
60
61
62#define MAXEXTLEN ((xfs_extlen_t)0x001fffff)
63#define MAXEXTNUM ((xfs_extnum_t)0x7fffffff)
64#define MAXAEXTNUM ((xfs_aextnum_t)0x7fff)
65
66
67
68
69
70
71
72
73#define XFS_MIN_BLOCKSIZE_LOG 9
74#define XFS_MAX_BLOCKSIZE_LOG 16
75#define XFS_MIN_BLOCKSIZE (1 << XFS_MIN_BLOCKSIZE_LOG)
76#define XFS_MAX_BLOCKSIZE (1 << XFS_MAX_BLOCKSIZE_LOG)
77#define XFS_MIN_CRC_BLOCKSIZE (1 << (XFS_MIN_BLOCKSIZE_LOG + 1))
78#define XFS_MIN_SECTORSIZE_LOG 9
79#define XFS_MAX_SECTORSIZE_LOG 15
80#define XFS_MIN_SECTORSIZE (1 << XFS_MIN_SECTORSIZE_LOG)
81#define XFS_MAX_SECTORSIZE (1 << XFS_MAX_SECTORSIZE_LOG)
82
83
84
85
86#define XFS_DATA_FORK 0
87#define XFS_ATTR_FORK 1
88#define XFS_COW_FORK 2
89
90#define XFS_WHICHFORK_STRINGS \
91 { XFS_DATA_FORK, "data" }, \
92 { XFS_ATTR_FORK, "attr" }, \
93 { XFS_COW_FORK, "cow" }
94
95
96
97
98#define MINDBTPTRS 3
99#define MINABTPTRS 2
100
101
102
103
104
105#define MAXNAMELEN 256
106
107
108
109
110
111typedef enum {
112 XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi
113} xfs_lookup_t;
114
115#define XFS_AG_BTREE_CMP_FORMAT_STR \
116 { XFS_LOOKUP_EQi, "eq" }, \
117 { XFS_LOOKUP_LEi, "le" }, \
118 { XFS_LOOKUP_GEi, "ge" }
119
120
121
122
123
124typedef enum {
125 XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_RMAPi, XFS_BTNUM_BMAPi,
126 XFS_BTNUM_INOi, XFS_BTNUM_FINOi, XFS_BTNUM_REFCi, XFS_BTNUM_MAX
127} xfs_btnum_t;
128
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
138struct xfs_name {
139 const unsigned char *name;
140 int len;
141 int type;
142};
143
144
145
146
147
148typedef uint32_t xfs_dqid_t;
149
150
151
152
153#define XFS_NBBYLOG 3
154#define XFS_WORDLOG 2
155#define XFS_NBWORDLOG (XFS_NBBYLOG + XFS_WORDLOG)
156#define XFS_NBWORD (1 << XFS_NBWORDLOG)
157#define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1)
158
159struct xfs_iext_cursor {
160 struct xfs_iext_leaf *leaf;
161 int pos;
162};
163
164typedef enum {
165 XFS_EXT_NORM, XFS_EXT_UNWRITTEN,
166} xfs_exntst_t;
167
168typedef struct xfs_bmbt_irec
169{
170 xfs_fileoff_t br_startoff;
171 xfs_fsblock_t br_startblock;
172 xfs_filblks_t br_blockcount;
173 xfs_exntst_t br_state;
174} xfs_bmbt_irec_t;
175
176
177enum 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
184
185
186
187struct xfs_mount;
188
189xfs_agblock_t xfs_ag_block_count(struct xfs_mount *mp, xfs_agnumber_t agno);
190bool xfs_verify_agbno(struct xfs_mount *mp, xfs_agnumber_t agno,
191 xfs_agblock_t agbno);
192bool xfs_verify_fsbno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
193bool xfs_verify_fsbext(struct xfs_mount *mp, xfs_fsblock_t fsbno,
194 xfs_fsblock_t len);
195
196void xfs_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno,
197 xfs_agino_t *first, xfs_agino_t *last);
198bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno,
199 xfs_agino_t agino);
200bool xfs_verify_agino_or_null(struct xfs_mount *mp, xfs_agnumber_t agno,
201 xfs_agino_t agino);
202bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino);
203bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino);
204bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino);
205bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno);
206bool xfs_verify_rtext(struct xfs_mount *mp, xfs_rtblock_t rtbno,
207 xfs_rtblock_t len);
208bool xfs_verify_icount(struct xfs_mount *mp, unsigned long long icount);
209bool xfs_verify_dablk(struct xfs_mount *mp, xfs_fileoff_t off);
210void xfs_icount_range(struct xfs_mount *mp, unsigned long long *min,
211 unsigned long long *max);
212bool xfs_verify_fileoff(struct xfs_mount *mp, xfs_fileoff_t off);
213bool xfs_verify_fileext(struct xfs_mount *mp, xfs_fileoff_t off,
214 xfs_fileoff_t len);
215
216#endif
217