]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/cntbt.c
2 * Copyright (c) 2000 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/
44 static int cntbt_key_count(void *obj
, int startoff
);
45 static int cntbt_key_offset(void *obj
, int startoff
, int idx
);
46 static int cntbt_ptr_count(void *obj
, int startoff
);
47 static int cntbt_ptr_offset(void *obj
, int startoff
, int idx
);
48 static int cntbt_rec_count(void *obj
, int startoff
);
49 static int cntbt_rec_offset(void *obj
, int startoff
, int idx
);
51 const field_t cntbt_hfld
[] = {
52 { "", FLDT_CNTBT
, OI(0), C1
, 0, TYP_NONE
},
56 #define OFF(f) bitize(offsetof(xfs_alloc_block_t, bb_ ## f))
57 const field_t cntbt_flds
[] = {
58 { "magic", FLDT_UINT32X
, OI(OFF(magic
)), C1
, 0, TYP_NONE
},
59 { "level", FLDT_UINT16D
, OI(OFF(level
)), C1
, 0, TYP_NONE
},
60 { "numrecs", FLDT_UINT16D
, OI(OFF(numrecs
)), C1
, 0, TYP_NONE
},
61 { "leftsib", FLDT_AGBLOCK
, OI(OFF(leftsib
)), C1
, 0, TYP_CNTBT
},
62 { "rightsib", FLDT_AGBLOCK
, OI(OFF(rightsib
)), C1
, 0, TYP_CNTBT
},
63 { "recs", FLDT_CNTBTREC
, cntbt_rec_offset
, cntbt_rec_count
,
64 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
65 { "keys", FLDT_CNTBTKEY
, cntbt_key_offset
, cntbt_key_count
,
66 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
67 { "ptrs", FLDT_CNTBTPTR
, cntbt_ptr_offset
, cntbt_ptr_count
,
68 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_CNTBT
},
72 #define KOFF(f) bitize(offsetof(xfs_alloc_key_t, ar_ ## f))
73 const field_t cntbt_key_flds
[] = {
74 { "blockcount", FLDT_EXTLEN
, OI(KOFF(blockcount
)), C1
, 0, TYP_NONE
},
75 { "startblock", FLDT_AGBLOCK
, OI(KOFF(startblock
)), C1
, 0, TYP_DATA
},
79 #define ROFF(f) bitize(offsetof(xfs_alloc_rec_t, ar_ ## f))
80 const field_t cntbt_rec_flds
[] = {
81 { "startblock", FLDT_AGBLOCK
, OI(ROFF(startblock
)), C1
, 0, TYP_DATA
},
82 { "blockcount", FLDT_EXTLEN
, OI(ROFF(blockcount
)), C1
, 0, TYP_NONE
},
92 xfs_alloc_block_t
*block
;
94 ASSERT(startoff
== 0);
96 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0)
98 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
108 xfs_alloc_block_t
*block
;
111 ASSERT(startoff
== 0);
113 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
114 kp
= XFS_BTREE_KEY_ADDR(mp
->m_sb
.sb_blocksize
, xfs_alloc
, block
, idx
,
115 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_alloc
, 0));
116 return bitize((int)((char *)kp
- (char *)block
));
125 xfs_alloc_block_t
*block
;
127 ASSERT(startoff
== 0);
129 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0)
131 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
141 xfs_alloc_block_t
*block
;
144 ASSERT(startoff
== 0);
146 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
147 pp
= XFS_BTREE_PTR_ADDR(mp
->m_sb
.sb_blocksize
, xfs_alloc
, block
, idx
,
148 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_alloc
, 0));
149 return bitize((int)((char *)pp
- (char *)block
));
158 xfs_alloc_block_t
*block
;
160 ASSERT(startoff
== 0);
162 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0)
164 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
174 xfs_alloc_block_t
*block
;
177 ASSERT(startoff
== 0);
179 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0);
180 rp
= XFS_BTREE_REC_ADDR(mp
->m_sb
.sb_blocksize
, xfs_alloc
, block
, idx
,
181 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_alloc
, 1));
182 return bitize((int)((char *)rp
- (char *)block
));
192 return bitize(mp
->m_sb
.sb_blocksize
);