]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/bmroot.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/
44 static int bmroota_key_count(void *obj
, int startoff
);
45 static int bmroota_key_offset(void *obj
, int startoff
, int idx
);
46 static int bmroota_ptr_count(void *obj
, int startoff
);
47 static int bmroota_ptr_offset(void *obj
, int startoff
, int idx
);
48 static int bmrootd_key_count(void *obj
, int startoff
);
49 static int bmrootd_key_offset(void *obj
, int startoff
, int idx
);
50 static int bmrootd_ptr_count(void *obj
, int startoff
);
51 static int bmrootd_ptr_offset(void *obj
, int startoff
, int idx
);
53 #define OFF(f) bitize(offsetof(xfs_bmdr_block_t, bb_ ## f))
54 const field_t bmroota_flds
[] = {
55 { "level", FLDT_UINT16D
, OI(OFF(level
)), C1
, 0, TYP_NONE
},
56 { "numrecs", FLDT_UINT16D
, OI(OFF(numrecs
)), C1
, 0, TYP_NONE
},
57 { "keys", FLDT_BMROOTAKEY
, bmroota_key_offset
, bmroota_key_count
,
58 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
59 { "ptrs", FLDT_BMROOTAPTR
, bmroota_ptr_offset
, bmroota_ptr_count
,
60 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_BMAPBTA
},
63 const field_t bmrootd_flds
[] = {
64 { "level", FLDT_UINT16D
, OI(OFF(level
)), C1
, 0, TYP_NONE
},
65 { "numrecs", FLDT_UINT16D
, OI(OFF(numrecs
)), C1
, 0, TYP_NONE
},
66 { "keys", FLDT_BMROOTDKEY
, bmrootd_key_offset
, bmrootd_key_count
,
67 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
68 { "ptrs", FLDT_BMROOTDPTR
, bmrootd_ptr_offset
, bmrootd_ptr_count
,
69 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_BMAPBTD
},
73 #define KOFF(f) bitize(offsetof(xfs_bmdr_key_t, br_ ## f))
74 const field_t bmroota_key_flds
[] = {
75 { "startoff", FLDT_DFILOFFA
, OI(KOFF(startoff
)), C1
, 0, TYP_NONE
},
78 const field_t bmrootd_key_flds
[] = {
79 { "startoff", FLDT_DFILOFFD
, OI(KOFF(startoff
)), C1
, 0, TYP_NONE
},
88 xfs_bmdr_block_t
*block
;
90 xfs_dinode_t
*dip
= obj
;
93 ASSERT(bitoffs(startoff
) == 0);
94 ASSERT(obj
== iocur_top
->data
);
95 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
96 ASSERT(XFS_DFORK_Q(dip
) && (char *)block
== XFS_DFORK_APTR(dip
));
97 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
98 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
107 xfs_bmdr_block_t
*block
;
112 ASSERT(bitoffs(startoff
) == 0);
113 ASSERT(obj
== iocur_top
->data
);
115 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
116 ASSERT(XFS_DFORK_Q(dip
) && (char *)block
== XFS_DFORK_APTR(dip
));
117 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
118 kp
= XFS_BTREE_KEY_ADDR(iocur_top
->len
, xfs_bmdr
, block
, idx
,
119 XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_ASIZE(dip
, mp
), xfs_bmdr
, 0));
120 return bitize((int)((char *)kp
- (char *)block
));
128 xfs_bmdr_block_t
*block
;
130 xfs_dinode_t
*dip
= obj
;
133 ASSERT(bitoffs(startoff
) == 0);
134 ASSERT(obj
== iocur_top
->data
);
135 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
136 ASSERT(XFS_DFORK_Q(dip
) && (char *)block
== XFS_DFORK_APTR(dip
));
137 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
138 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
147 xfs_bmdr_block_t
*block
;
151 ASSERT(bitoffs(startoff
) == 0);
152 ASSERT(obj
== iocur_top
->data
);
154 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
155 ASSERT(XFS_DFORK_Q(dip
) && (char *)block
== XFS_DFORK_APTR(dip
));
156 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
157 pp
= XFS_BTREE_PTR_ADDR(iocur_top
->len
, xfs_bmdr
, block
, idx
,
158 XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_ASIZE(dip
, mp
), xfs_bmdr
, 0));
159 return bitize((int)((char *)pp
- (char *)block
));
170 xfs_bmdr_block_t
*block
;
173 ASSERT(bitoffs(startoff
) == 0);
174 ASSERT(obj
== iocur_top
->data
);
178 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
179 ASSERT(XFS_DFORK_Q(dip
) && (char *)block
== XFS_DFORK_APTR(dip
));
181 return bitize((int)XFS_DFORK_ASIZE(dip
, mp
));
189 xfs_bmdr_block_t
*block
;
191 xfs_dinode_t
*dip
= obj
;
194 ASSERT(bitoffs(startoff
) == 0);
195 ASSERT(obj
== iocur_top
->data
);
196 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
197 ASSERT((char *)block
== XFS_DFORK_DPTR(dip
));
198 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
199 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
208 xfs_bmdr_block_t
*block
;
212 ASSERT(bitoffs(startoff
) == 0);
213 ASSERT(obj
== iocur_top
->data
);
215 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
216 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
217 kp
= XFS_BTREE_KEY_ADDR(iocur_top
->len
, xfs_bmdr
, block
, idx
,
218 XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_DSIZE(dip
, mp
), xfs_bmdr
, 0));
219 return bitize((int)((char *)kp
- (char *)block
));
227 xfs_bmdr_block_t
*block
;
229 xfs_dinode_t
*dip
= obj
;
232 ASSERT(bitoffs(startoff
) == 0);
233 ASSERT(obj
== iocur_top
->data
);
234 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
235 ASSERT((char *)block
== XFS_DFORK_DPTR(dip
));
236 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
237 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
246 xfs_bmdr_block_t
*block
;
250 ASSERT(bitoffs(startoff
) == 0);
251 ASSERT(obj
== iocur_top
->data
);
253 block
= (xfs_bmdr_block_t
*)((char *)obj
+ byteize(startoff
));
254 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
255 pp
= XFS_BTREE_PTR_ADDR(iocur_top
->len
, xfs_bmdr
, block
, idx
,
256 XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_DSIZE(dip
, mp
), xfs_bmdr
, 0));
257 return bitize((int)((char *)pp
- (char *)block
));
268 ASSERT(bitoffs(startoff
) == 0);
269 ASSERT(obj
== iocur_top
->data
);
272 return bitize((int)XFS_DFORK_DSIZE(dip
, mp
));