core, pxe: Don't push on one stack and pop from the other in pxenv
[syslinux.git] / core / fs / xfs / xfs_sb.h
blob12024ab3da1ca489e5b2fd82a48f02c06a382a41
1 /*
2 * Taken from Linux kernel tree (linux/fs/xfs)
4 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
5 * All Rights Reserved.
7 * Copyright (c) 2012 Paulo Alcantara <pcacjr@zytor.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it would be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef XFS_SB_H_
23 #define XFS_SB_H_
25 #include <stddef.h>
27 #include <sys/types.h>
29 typedef unsigned char uuid_t[16];
32 * Super block
33 * Fits into a sector-sized buffer at address 0 of each allocation group.
34 * Only the first of these is ever updated except during growfs.
37 struct xfs_buf;
38 struct xfs_mount;
40 #define XFS_SB_MAGIC "XFSB" /* 'XFSB' */
41 #define XFS_SB_VERSION_1 1 /* 5.3, 6.0.1, 6.1 */
42 #define XFS_SB_VERSION_2 2 /* 6.2 - attributes */
43 #define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */
44 #define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */
45 #define XFS_SB_VERSION_NUMBITS 0x000f
46 #define XFS_SB_VERSION_ALLFBITS 0xfff0
47 #define XFS_SB_VERSION_SASHFBITS 0xf000
48 #define XFS_SB_VERSION_REALFBITS 0x0ff0
49 #define XFS_SB_VERSION_ATTRBIT 0x0010
50 #define XFS_SB_VERSION_NLINKBIT 0x0020
51 #define XFS_SB_VERSION_QUOTABIT 0x0040
52 #define XFS_SB_VERSION_ALIGNBIT 0x0080
53 #define XFS_SB_VERSION_DALIGNBIT 0x0100
54 #define XFS_SB_VERSION_SHAREDBIT 0x0200
55 #define XFS_SB_VERSION_LOGV2BIT 0x0400
56 #define XFS_SB_VERSION_SECTORBIT 0x0800
57 #define XFS_SB_VERSION_EXTFLGBIT 0x1000
58 #define XFS_SB_VERSION_DIRV2BIT 0x2000
59 #define XFS_SB_VERSION_BORGBIT 0x4000 /* ASCII only case-insens. */
60 #define XFS_SB_VERSION_MOREBITSBIT 0x8000
61 #define XFS_SB_VERSION_OKSASHFBITS \
62 (XFS_SB_VERSION_EXTFLGBIT | \
63 XFS_SB_VERSION_DIRV2BIT | \
64 XFS_SB_VERSION_BORGBIT)
65 #define XFS_SB_VERSION_OKREALFBITS \
66 (XFS_SB_VERSION_ATTRBIT | \
67 XFS_SB_VERSION_NLINKBIT | \
68 XFS_SB_VERSION_QUOTABIT | \
69 XFS_SB_VERSION_ALIGNBIT | \
70 XFS_SB_VERSION_DALIGNBIT | \
71 XFS_SB_VERSION_SHAREDBIT | \
72 XFS_SB_VERSION_LOGV2BIT | \
73 XFS_SB_VERSION_SECTORBIT | \
74 XFS_SB_VERSION_MOREBITSBIT)
75 #define XFS_SB_VERSION_OKREALBITS \
76 (XFS_SB_VERSION_NUMBITS | \
77 XFS_SB_VERSION_OKREALFBITS | \
78 XFS_SB_VERSION_OKSASHFBITS)
81 * There are two words to hold XFS "feature" bits: the original
82 * word, sb_versionnum, and sb_features2. Whenever a bit is set in
83 * sb_features2, the feature bit XFS_SB_VERSION_MOREBITSBIT must be set.
85 * These defines represent bits in sb_features2.
87 #define XFS_SB_VERSION2_REALFBITS 0x00ffffff /* Mask: features */
88 #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001
89 #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */
90 #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004
91 #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */
92 #define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */
93 #define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32 bit project id */
95 #define XFS_SB_VERSION2_OKREALFBITS \
96 (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \
97 XFS_SB_VERSION2_ATTR2BIT | \
98 XFS_SB_VERSION2_PROJID32BIT)
99 #define XFS_SB_VERSION2_OKSASHFBITS \
101 #define XFS_SB_VERSION2_OKREALBITS \
102 (XFS_SB_VERSION2_OKREALFBITS | \
103 XFS_SB_VERSION2_OKSASHFBITS )
106 * Sequence number values for the fields.
108 typedef enum {
109 XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS,
110 XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO,
111 XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS,
112 XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS,
113 XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE,
114 XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG,
115 XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG,
116 XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT,
117 XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO,
118 XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN,
119 XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG,
120 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT,
121 XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2,
122 XFS_SBS_FIELDCOUNT
123 } xfs_sb_field_t;
126 * Mask values, defined based on the xfs_sb_field_t values.
127 * Only define the ones we're using.
129 #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x)
130 #define XFS_SB_UUID XFS_SB_MVAL(UUID)
131 #define XFS_SB_FNAME XFS_SB_MVAL(FNAME)
132 #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO)
133 #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO)
134 #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO)
135 #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM)
136 #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO)
137 #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO)
138 #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS)
139 #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN)
140 #define XFS_SB_UNIT XFS_SB_MVAL(UNIT)
141 #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH)
142 #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT)
143 #define XFS_SB_IFREE XFS_SB_MVAL(IFREE)
144 #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS)
145 #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)
146 #define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2)
147 #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
148 #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
149 #define XFS_SB_MOD_BITS \
150 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \
151 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
152 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \
153 XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \
154 XFS_SB_BAD_FEATURES2)
158 * Misc. Flags - warning - these will be cleared by xfs_repair unless
159 * a feature bit is set when the flag is used.
161 #define XFS_SBF_NOFLAGS 0x00 /* no flags set */
162 #define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */
165 * define max. shared version we can interoperate with
167 #define XFS_SB_MAX_SHARED_VN 0
169 #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
172 * end of superblock version macros
175 #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR)
176 #define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr))
178 #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d))
179 #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \
180 xfs_daddr_to_agno(mp,d), xfs_daddr_to_agbno(mp,d))
181 #define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \
182 XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno))
185 * File system sector to basic block conversions.
187 #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log)
190 * File system block to basic block conversions.
192 #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
193 #define XFS_BB_TO_FSB(mp,bb) \
194 (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
195 #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
198 * File system block to byte conversions.
200 #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog)
201 #define XFS_B_TO_FSB(mp,b) \
202 ((((uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog)
203 #define XFS_B_TO_FSBT(mp,b) (((uint64_t)(b)) >> (mp)->m_sb.sb_blocklog)
204 #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask)
206 #endif /* XFS_SB_H_ */