]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - libxfs/xfs_types.h
libxfs: remove xfs_inode_log_item ili_flags
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_types.h
CommitLineData
37b3b4d6 1// SPDX-License-Identifier: GPL-2.0
2bd0ea18 2/*
f302e9e4
NS
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
2bd0ea18
NS
5 */
6#ifndef __XFS_TYPES_H__
dfc130f3 7#define __XFS_TYPES_H__
2bd0ea18 8
4a492e72 9typedef uint32_t prid_t; /* project ID */
a2ceac1f 10
4a492e72
DW
11typedef uint32_t xfs_agblock_t; /* blockno in alloc. group */
12typedef uint32_t xfs_agino_t; /* inode # within allocation grp */
13typedef uint32_t xfs_extlen_t; /* extent length in blocks */
14typedef uint32_t xfs_agnumber_t; /* allocation group number */
15typedef int32_t xfs_extnum_t; /* # of extents in a file */
16typedef int16_t xfs_aextnum_t; /* # extents in an attribute fork */
17typedef int64_t xfs_fsize_t; /* bytes in a file */
18typedef uint64_t xfs_ufsize_t; /* unsigned bytes in a file */
2bd0ea18 19
4a492e72 20typedef int32_t xfs_suminfo_t; /* type of bitmap summary info */
a531149e 21typedef uint32_t xfs_rtword_t; /* word type for bitmap manipulations */
2bd0ea18 22
4a492e72
DW
23typedef int64_t xfs_lsn_t; /* log sequence number */
24typedef int32_t xfs_tid_t; /* transaction identifier */
2bd0ea18 25
4a492e72
DW
26typedef uint32_t xfs_dablk_t; /* dir/attr block number (in file) */
27typedef uint32_t xfs_dahash_t; /* dir/attr hash value */
2bd0ea18 28
4a492e72
DW
29typedef uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */
30typedef uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */
31typedef uint64_t xfs_rtblock_t; /* extent (block) in realtime area */
32typedef uint64_t xfs_fileoff_t; /* block number in a file */
33typedef uint64_t xfs_filblks_t; /* number of blocks in a file */
2bd0ea18 34
4a492e72
DW
35typedef int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */
36typedef int64_t xfs_sfiloff_t; /* signed block number in a file */
a2ceac1f 37
b47beff8
DW
38/*
39 * New verifiers will return the instruction address of the failing check.
40 * NULL means everything is ok.
41 */
42typedef void * xfs_failaddr_t;
43
2bd0ea18
NS
44/*
45 * Null values for the types.
46 */
dfc130f3
RC
47#define NULLFSBLOCK ((xfs_fsblock_t)-1)
48#define NULLRFSBLOCK ((xfs_rfsblock_t)-1)
49#define NULLRTBLOCK ((xfs_rtblock_t)-1)
50#define NULLFILEOFF ((xfs_fileoff_t)-1)
2bd0ea18 51
dfc130f3
RC
52#define NULLAGBLOCK ((xfs_agblock_t)-1)
53#define NULLAGNUMBER ((xfs_agnumber_t)-1)
2bd0ea18
NS
54
55#define NULLCOMMITLSN ((xfs_lsn_t)-1)
56
a2ceac1f
DC
57#define NULLFSINO ((xfs_ino_t)-1)
58#define NULLAGINO ((xfs_agino_t)-1)
59
2bd0ea18
NS
60/*
61 * Max values for extlen, extnum, aextnum.
62 */
dfc130f3
RC
63#define MAXEXTLEN ((xfs_extlen_t)0x001fffff) /* 21 bits */
64#define MAXEXTNUM ((xfs_extnum_t)0x7fffffff) /* signed int */
65#define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */
2bd0ea18 66
a2ceac1f
DC
67/*
68 * Minimum and maximum blocksize and sectorsize.
69 * The blocksize upper limit is pretty much arbitrary.
70 * The sectorsize upper limit is due to sizeof(sb_sectsize).
e24ee60b
DC
71 * CRC enable filesystems use 512 byte inodes, meaning 512 byte block sizes
72 * cannot be used.
a2ceac1f
DC
73 */
74#define XFS_MIN_BLOCKSIZE_LOG 9 /* i.e. 512 bytes */
75#define XFS_MAX_BLOCKSIZE_LOG 16 /* i.e. 65536 bytes */
76#define XFS_MIN_BLOCKSIZE (1 << XFS_MIN_BLOCKSIZE_LOG)
77#define XFS_MAX_BLOCKSIZE (1 << XFS_MAX_BLOCKSIZE_LOG)
e24ee60b 78#define XFS_MIN_CRC_BLOCKSIZE (1 << (XFS_MIN_BLOCKSIZE_LOG + 1))
a2ceac1f
DC
79#define XFS_MIN_SECTORSIZE_LOG 9 /* i.e. 512 bytes */
80#define XFS_MAX_SECTORSIZE_LOG 15 /* i.e. 32768 bytes */
81#define XFS_MIN_SECTORSIZE (1 << XFS_MIN_SECTORSIZE_LOG)
82#define XFS_MAX_SECTORSIZE (1 << XFS_MAX_SECTORSIZE_LOG)
83
2d4bfb91
DC
84/*
85 * Inode fork identifiers.
86 */
87#define XFS_DATA_FORK 0
88#define XFS_ATTR_FORK 1
cb8a004a 89#define XFS_COW_FORK 2
2d4bfb91 90
ca86e759
NS
91/*
92 * Min numbers of data/attr fork btree root pointers.
93 */
94#define MINDBTPTRS 3
95#define MINABTPTRS 2
96
2bd0ea18
NS
97/*
98 * MAXNAMELEN is the length (including the terminating null) of
99 * the longest permissible file (component) name.
100 */
101#define MAXNAMELEN 256
102
3eb6b563
DW
103/*
104 * This enum is used in string mapping in xfs_trace.h; please keep the
105 * TRACE_DEFINE_ENUMs for it up to date.
106 */
2bd0ea18
NS
107typedef enum {
108 XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi
109} xfs_lookup_t;
110
a47d8371
DW
111#define XFS_AG_BTREE_CMP_FORMAT_STR \
112 { XFS_LOOKUP_EQi, "eq" }, \
113 { XFS_LOOKUP_LEi, "le" }, \
114 { XFS_LOOKUP_GEi, "ge" }
115
6823e536 116/*
7c3bcec7
DW
117 * This enum is used in string mapping in xfs_trace.h and scrub/trace.h;
118 * please keep the TRACE_DEFINE_ENUMs for it up to date.
6823e536 119 */
2bd0ea18 120typedef enum {
e37838e5 121 XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_RMAPi, XFS_BTNUM_BMAPi,
88ce0792 122 XFS_BTNUM_INOi, XFS_BTNUM_FINOi, XFS_BTNUM_REFCi, XFS_BTNUM_MAX
2bd0ea18
NS
123} xfs_btnum_t;
124
6823e536
DW
125#define XFS_BTNUM_STRINGS \
126 { XFS_BTNUM_BNOi, "bnobt" }, \
127 { XFS_BTNUM_CNTi, "cntbt" }, \
128 { XFS_BTNUM_RMAPi, "rmapbt" }, \
129 { XFS_BTNUM_BMAPi, "bmbt" }, \
130 { XFS_BTNUM_INOi, "inobt" }, \
131 { XFS_BTNUM_FINOi, "finobt" }, \
132 { XFS_BTNUM_REFCi, "refcbt" }
133
5e656dbb 134struct xfs_name {
56b2de80
DC
135 const unsigned char *name;
136 int len;
494434d7 137 int type;
5e656dbb
BN
138};
139
dcbc51df
DC
140/*
141 * uid_t and gid_t are hard-coded to 32 bits in the inode.
142 * Hence, an 'id' in a dquot is 32 bits..
143 */
4a492e72 144typedef uint32_t xfs_dqid_t;
dcbc51df 145
4c51838c
DC
146/*
147 * Constants for bit manipulations.
148 */
149#define XFS_NBBYLOG 3 /* log2(NBBY) */
150#define XFS_WORDLOG 2 /* log2(sizeof(xfs_rtword_t)) */
151#define XFS_NBWORDLOG (XFS_NBBYLOG + XFS_WORDLOG)
152#define XFS_NBWORD (1 << XFS_NBWORDLOG)
153#define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1)
154
9788e059 155struct xfs_iext_cursor {
b37d753d
CH
156 struct xfs_iext_leaf *leaf;
157 int pos;
9788e059 158};
4c51838c 159
5837f99a
CH
160typedef enum {
161 XFS_EXT_NORM, XFS_EXT_UNWRITTEN,
162} xfs_exntst_t;
163
164typedef struct xfs_bmbt_irec
165{
166 xfs_fileoff_t br_startoff; /* starting file offset */
167 xfs_fsblock_t br_startblock; /* starting block number */
168 xfs_filblks_t br_blockcount; /* number of blocks */
169 xfs_exntst_t br_state; /* extent state */
170} xfs_bmbt_irec_t;
171
1727fd17
DC
172/*
173 * Type verifier functions
174 */
175struct xfs_mount;
176
177xfs_agblock_t xfs_ag_block_count(struct xfs_mount *mp, xfs_agnumber_t agno);
178bool xfs_verify_agbno(struct xfs_mount *mp, xfs_agnumber_t agno,
179 xfs_agblock_t agbno);
180bool xfs_verify_fsbno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
181
182void xfs_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno,
183 xfs_agino_t *first, xfs_agino_t *last);
184bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno,
185 xfs_agino_t agino);
7a425ea8
DW
186bool xfs_verify_agino_or_null(struct xfs_mount *mp, xfs_agnumber_t agno,
187 xfs_agino_t agino);
1727fd17
DC
188bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino);
189bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino);
190bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino);
191bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno);
751d83bc 192bool xfs_verify_icount(struct xfs_mount *mp, unsigned long long icount);
95a8c918 193bool xfs_verify_dablk(struct xfs_mount *mp, xfs_fileoff_t off);
1727fd17 194
2b288ccf 195#endif /* __XFS_TYPES_H__ */