]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/bmapbt.c
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
43 static int bmapbta_key_count(void *obj
, int startoff
);
44 static int bmapbta_key_offset(void *obj
, int startoff
, int idx
);
45 static int bmapbta_ptr_count(void *obj
, int startoff
);
46 static int bmapbta_ptr_offset(void *obj
, int startoff
, int idx
);
47 static int bmapbta_rec_count(void *obj
, int startoff
);
48 static int bmapbta_rec_offset(void *obj
, int startoff
, int idx
);
49 static int bmapbtd_key_count(void *obj
, int startoff
);
50 static int bmapbtd_key_offset(void *obj
, int startoff
, int idx
);
51 static int bmapbtd_ptr_count(void *obj
, int startoff
);
52 static int bmapbtd_ptr_offset(void *obj
, int startoff
, int idx
);
53 static int bmapbtd_rec_count(void *obj
, int startoff
);
54 static int bmapbtd_rec_offset(void *obj
, int startoff
, int idx
);
56 const field_t bmapbta_hfld
[] = {
57 { "", FLDT_BMAPBTA
, OI(0), C1
, 0, TYP_NONE
},
60 const field_t bmapbtd_hfld
[] = {
61 { "", FLDT_BMAPBTD
, OI(0), C1
, 0, TYP_NONE
},
65 #define OFF(f) bitize(offsetof(xfs_bmbt_block_t, bb_ ## f))
66 const field_t bmapbta_flds
[] = {
67 { "magic", FLDT_UINT32X
, OI(OFF(magic
)), C1
, 0, TYP_NONE
},
68 { "level", FLDT_UINT16D
, OI(OFF(level
)), C1
, 0, TYP_NONE
},
69 { "numrecs", FLDT_UINT16D
, OI(OFF(numrecs
)), C1
, 0, TYP_NONE
},
70 { "leftsib", FLDT_DFSBNO
, OI(OFF(leftsib
)), C1
, 0, TYP_BMAPBTA
},
71 { "rightsib", FLDT_DFSBNO
, OI(OFF(rightsib
)), C1
, 0, TYP_BMAPBTA
},
72 { "recs", FLDT_BMAPBTAREC
, bmapbta_rec_offset
, bmapbta_rec_count
,
73 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
74 { "keys", FLDT_BMAPBTAKEY
, bmapbta_key_offset
, bmapbta_key_count
,
75 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
76 { "ptrs", FLDT_BMAPBTAPTR
, bmapbta_ptr_offset
, bmapbta_ptr_count
,
77 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_BMAPBTA
},
80 const field_t bmapbtd_flds
[] = {
81 { "magic", FLDT_UINT32X
, OI(OFF(magic
)), C1
, 0, TYP_NONE
},
82 { "level", FLDT_UINT16D
, OI(OFF(level
)), C1
, 0, TYP_NONE
},
83 { "numrecs", FLDT_UINT16D
, OI(OFF(numrecs
)), C1
, 0, TYP_NONE
},
84 { "leftsib", FLDT_DFSBNO
, OI(OFF(leftsib
)), C1
, 0, TYP_BMAPBTD
},
85 { "rightsib", FLDT_DFSBNO
, OI(OFF(rightsib
)), C1
, 0, TYP_BMAPBTD
},
86 { "recs", FLDT_BMAPBTDREC
, bmapbtd_rec_offset
, bmapbtd_rec_count
,
87 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
88 { "keys", FLDT_BMAPBTDKEY
, bmapbtd_key_offset
, bmapbtd_key_count
,
89 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
90 { "ptrs", FLDT_BMAPBTDPTR
, bmapbtd_ptr_offset
, bmapbtd_ptr_count
,
91 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_BMAPBTD
},
95 #define KOFF(f) bitize(offsetof(xfs_bmbt_key_t, br_ ## f))
96 const field_t bmapbta_key_flds
[] = {
97 { "startoff", FLDT_DFILOFFA
, OI(KOFF(startoff
)), C1
, 0, TYP_ATTR
},
100 const field_t bmapbtd_key_flds
[] = {
101 { "startoff", FLDT_DFILOFFD
, OI(KOFF(startoff
)), C1
, 0, TYP_INODATA
},
105 const field_t bmapbta_rec_flds
[] = {
106 { "startoff", FLDT_CFILEOFFA
, OI(BMBT_STARTOFF_BITOFF
), C1
, 0,
108 { "startblock", FLDT_CFSBLOCK
, OI(BMBT_STARTBLOCK_BITOFF
), C1
, 0,
110 { "blockcount", FLDT_CEXTLEN
, OI(BMBT_BLOCKCOUNT_BITOFF
), C1
, 0,
112 { "extentflag", FLDT_CEXTFLG
, OI(BMBT_EXNTFLAG_BITOFF
), C1
, 0,
116 const field_t bmapbtd_rec_flds
[] = {
117 { "startoff", FLDT_CFILEOFFD
, OI(BMBT_STARTOFF_BITOFF
), C1
, 0,
119 { "startblock", FLDT_CFSBLOCK
, OI(BMBT_STARTBLOCK_BITOFF
), C1
, 0,
121 { "blockcount", FLDT_CEXTLEN
, OI(BMBT_BLOCKCOUNT_BITOFF
), C1
, 0,
123 { "extentflag", FLDT_CEXTFLG
, OI(BMBT_EXNTFLAG_BITOFF
), C1
, 0,
133 xfs_bmbt_block_t
*block
;
135 ASSERT(startoff
== 0);
137 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0)
139 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
148 xfs_bmbt_block_t
*block
;
151 ASSERT(startoff
== 0);
153 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
154 kp
= XFS_BTREE_KEY_ADDR(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, block
, idx
,
155 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, 0));
156 return bitize((int)((char *)kp
- (char *)block
));
164 xfs_bmbt_block_t
*block
;
166 ASSERT(startoff
== 0);
168 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0)
170 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
179 xfs_bmbt_block_t
*block
;
182 ASSERT(startoff
== 0);
184 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
185 pp
= XFS_BTREE_PTR_ADDR(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, block
, idx
,
186 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, 0));
187 return bitize((int)((char *)pp
- (char *)block
));
195 xfs_bmbt_block_t
*block
;
197 ASSERT(startoff
== 0);
199 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0)
201 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
210 xfs_bmbt_block_t
*block
;
213 ASSERT(startoff
== 0);
215 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0);
216 rp
= XFS_BTREE_REC_ADDR(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, block
, idx
,
217 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, 1));
218 return bitize((int)((char *)rp
- (char *)block
));
227 return bitize(mp
->m_sb
.sb_blocksize
);
235 xfs_bmbt_block_t
*block
;
237 ASSERT(startoff
== 0);
239 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0)
241 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
250 xfs_bmbt_block_t
*block
;
253 ASSERT(startoff
== 0);
255 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
256 kp
= XFS_BTREE_KEY_ADDR(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, block
, idx
,
257 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, 0));
258 return bitize((int)((char *)kp
- (char *)block
));
266 xfs_bmbt_block_t
*block
;
268 ASSERT(startoff
== 0);
270 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0)
272 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
281 xfs_bmbt_block_t
*block
;
284 ASSERT(startoff
== 0);
286 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
287 pp
= XFS_BTREE_PTR_ADDR(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, block
, idx
,
288 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, 0));
289 return bitize((int)((char *)pp
- (char *)block
));
297 xfs_bmbt_block_t
*block
;
299 ASSERT(startoff
== 0);
301 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0)
303 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
312 xfs_bmbt_block_t
*block
;
315 ASSERT(startoff
== 0);
317 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0);
318 rp
= XFS_BTREE_REC_ADDR(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, block
, idx
,
319 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_bmbt
, 1));
320 return bitize((int)((char *)rp
- (char *)block
));
329 return bitize(mp
->m_sb
.sb_blocksize
);