]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/bmroot.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/
45 static int bmroota_key_count(void *obj
, int startoff
);
46 static int bmroota_key_offset(void *obj
, int startoff
, int idx
);
47 static int bmroota_ptr_count(void *obj
, int startoff
);
48 static int bmroota_ptr_offset(void *obj
, int startoff
, int idx
);
49 static int bmrootd_key_count(void *obj
, int startoff
);
50 static int bmrootd_key_offset(void *obj
, int startoff
, int idx
);
51 static int bmrootd_ptr_count(void *obj
, int startoff
);
52 static int bmrootd_ptr_offset(void *obj
, int startoff
, int idx
);
54 #define OFF(f) bitize(offsetof(xfs_bmdr_block_t, bb_ ## f))
55 const field_t bmroota_flds
[] = {
56 { "level", FLDT_UINT16D
, OI(OFF(level
)), C1
, 0, TYP_NONE
},
57 { "numrecs", FLDT_UINT16D
, OI(OFF(numrecs
)), C1
, 0, TYP_NONE
},
58 { "keys", FLDT_BMROOTAKEY
, bmroota_key_offset
, bmroota_key_count
,
59 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
60 { "ptrs", FLDT_BMROOTAPTR
, bmroota_ptr_offset
, bmroota_ptr_count
,
61 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_BMAPBTA
},
64 const field_t bmrootd_flds
[] = {
65 { "level", FLDT_UINT16D
, OI(OFF(level
)), C1
, 0, TYP_NONE
},
66 { "numrecs", FLDT_UINT16D
, OI(OFF(numrecs
)), C1
, 0, TYP_NONE
},
67 { "keys", FLDT_BMROOTDKEY
, bmrootd_key_offset
, bmrootd_key_count
,
68 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
69 { "ptrs", FLDT_BMROOTDPTR
, bmrootd_ptr_offset
, bmrootd_ptr_count
,
70 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_BMAPBTD
},
74 #define KOFF(f) bitize(offsetof(xfs_bmdr_key_t, br_ ## f))
75 const field_t bmroota_key_flds
[] = {
76 { "startoff", FLDT_DFILOFFA
, OI(KOFF(startoff
)), C1
, 0, TYP_NONE
},
79 const field_t bmrootd_key_flds
[] = {
80 { "startoff", FLDT_DFILOFFD
, OI(KOFF(startoff
)), C1
, 0, TYP_NONE
},
89 xfs_bmdr_block_t
*block
;
91 xfs_dinode_t
*dip
= obj
;
94 ASSERT(bitoffs(startoff
) == 0);
95 ASSERT(obj
== iocur_top
->data
);
96 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
97 ASSERT(XFS_DFORK_Q(dip
) && (char *)block
== XFS_DFORK_APTR(dip
));
98 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
99 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
108 xfs_bmdr_block_t
*block
;
113 ASSERT(bitoffs(startoff
) == 0);
114 ASSERT(obj
== iocur_top
->data
);
116 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
117 ASSERT(XFS_DFORK_Q(dip
) && (char *)block
== XFS_DFORK_APTR(dip
));
118 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
119 kp
= XFS_BTREE_KEY_ADDR(iocur_top
->len
, xfs_bmdr
, block
, idx
,
120 XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_ASIZE(dip
, mp
), xfs_bmdr
, 0));
121 return bitize((int)((char *)kp
- (char *)block
));
129 xfs_bmdr_block_t
*block
;
131 xfs_dinode_t
*dip
= obj
;
134 ASSERT(bitoffs(startoff
) == 0);
135 ASSERT(obj
== iocur_top
->data
);
136 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
137 ASSERT(XFS_DFORK_Q(dip
) && (char *)block
== XFS_DFORK_APTR(dip
));
138 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
139 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
148 xfs_bmdr_block_t
*block
;
152 ASSERT(bitoffs(startoff
) == 0);
153 ASSERT(obj
== iocur_top
->data
);
155 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
156 ASSERT(XFS_DFORK_Q(dip
) && (char *)block
== XFS_DFORK_APTR(dip
));
157 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
158 pp
= XFS_BTREE_PTR_ADDR(iocur_top
->len
, xfs_bmdr
, block
, idx
,
159 XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_ASIZE(dip
, mp
), xfs_bmdr
, 0));
160 return bitize((int)((char *)pp
- (char *)block
));
171 xfs_bmdr_block_t
*block
;
174 ASSERT(bitoffs(startoff
) == 0);
175 ASSERT(obj
== iocur_top
->data
);
179 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
180 ASSERT(XFS_DFORK_Q(dip
) && (char *)block
== XFS_DFORK_APTR(dip
));
182 return bitize((int)XFS_DFORK_ASIZE(dip
, mp
));
190 xfs_bmdr_block_t
*block
;
192 xfs_dinode_t
*dip
= obj
;
195 ASSERT(bitoffs(startoff
) == 0);
196 ASSERT(obj
== iocur_top
->data
);
197 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
198 ASSERT((char *)block
== XFS_DFORK_DPTR(dip
));
199 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
200 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
209 xfs_bmdr_block_t
*block
;
213 ASSERT(bitoffs(startoff
) == 0);
214 ASSERT(obj
== iocur_top
->data
);
216 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
217 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
218 kp
= XFS_BTREE_KEY_ADDR(iocur_top
->len
, xfs_bmdr
, block
, idx
,
219 XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_DSIZE(dip
, mp
), xfs_bmdr
, 0));
220 return bitize((int)((char *)kp
- (char *)block
));
228 xfs_bmdr_block_t
*block
;
230 xfs_dinode_t
*dip
= obj
;
233 ASSERT(bitoffs(startoff
) == 0);
234 ASSERT(obj
== iocur_top
->data
);
235 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
236 ASSERT((char *)block
== XFS_DFORK_DPTR(dip
));
237 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
238 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
247 xfs_bmdr_block_t
*block
;
251 ASSERT(bitoffs(startoff
) == 0);
252 ASSERT(obj
== iocur_top
->data
);
254 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
255 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
256 pp
= XFS_BTREE_PTR_ADDR(iocur_top
->len
, xfs_bmdr
, block
, idx
,
257 XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_DSIZE(dip
, mp
), xfs_bmdr
, 0));
258 return bitize((int)((char *)pp
- (char *)block
));
269 ASSERT(bitoffs(startoff
) == 0);
270 ASSERT(obj
== iocur_top
->data
);
273 return bitize((int)XFS_DFORK_DSIZE(dip
, mp
));