]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/inobt.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 inobt_key_count(void *obj
, int startoff
);
44 static int inobt_key_offset(void *obj
, int startoff
, int idx
);
45 static int inobt_ptr_count(void *obj
, int startoff
);
46 static int inobt_ptr_offset(void *obj
, int startoff
, int idx
);
47 static int inobt_rec_count(void *obj
, int startoff
);
48 static int inobt_rec_offset(void *obj
, int startoff
, int idx
);
50 const field_t inobt_hfld
[] = {
51 { "", FLDT_INOBT
, OI(0), C1
, 0, TYP_NONE
},
55 #define OFF(f) bitize(offsetof(xfs_inobt_block_t, bb_ ## f))
56 const field_t inobt_flds
[] = {
57 { "magic", FLDT_UINT32X
, OI(OFF(magic
)), C1
, 0, TYP_NONE
},
58 { "level", FLDT_UINT16D
, OI(OFF(level
)), C1
, 0, TYP_NONE
},
59 { "numrecs", FLDT_UINT16D
, OI(OFF(numrecs
)), C1
, 0, TYP_NONE
},
60 { "leftsib", FLDT_AGBLOCK
, OI(OFF(leftsib
)), C1
, 0, TYP_INOBT
},
61 { "rightsib", FLDT_AGBLOCK
, OI(OFF(rightsib
)), C1
, 0, TYP_INOBT
},
62 { "recs", FLDT_INOBTREC
, inobt_rec_offset
, inobt_rec_count
,
63 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
64 { "keys", FLDT_INOBTKEY
, inobt_key_offset
, inobt_key_count
,
65 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
66 { "ptrs", FLDT_INOBTPTR
, inobt_ptr_offset
, inobt_ptr_count
,
67 FLD_ARRAY
|FLD_ABASE1
|FLD_COUNT
|FLD_OFFSET
, TYP_INOBT
},
71 #define KOFF(f) bitize(offsetof(xfs_inobt_key_t, ir_ ## f))
72 const field_t inobt_key_flds
[] = {
73 { "startino", FLDT_AGINO
, OI(KOFF(startino
)), C1
, 0, TYP_INODE
},
77 #define ROFF(f) bitize(offsetof(xfs_inobt_rec_t, ir_ ## f))
78 const field_t inobt_rec_flds
[] = {
79 { "startino", FLDT_AGINO
, OI(ROFF(startino
)), C1
, 0, TYP_INODE
},
80 { "freecount", FLDT_INT32D
, OI(ROFF(freecount
)), C1
, 0, TYP_NONE
},
81 { "free", FLDT_INOFREE
, OI(ROFF(free
)), C1
, 0, TYP_NONE
},
91 xfs_inobt_block_t
*block
;
93 ASSERT(startoff
== 0);
95 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0)
97 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
107 xfs_inobt_block_t
*block
;
110 ASSERT(startoff
== 0);
112 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
113 kp
= XFS_BTREE_KEY_ADDR(mp
->m_sb
.sb_blocksize
, xfs_inobt
, block
, idx
,
114 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_inobt
, 0));
115 return bitize((int)((char *)kp
- (char *)block
));
124 xfs_inobt_block_t
*block
;
126 ASSERT(startoff
== 0);
128 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0)
130 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
140 xfs_inobt_block_t
*block
;
143 ASSERT(startoff
== 0);
145 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0);
146 pp
= XFS_BTREE_PTR_ADDR(mp
->m_sb
.sb_blocksize
, xfs_inobt
, block
, idx
,
147 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_inobt
, 0));
148 return bitize((int)((char *)pp
- (char *)block
));
157 xfs_inobt_block_t
*block
;
159 ASSERT(startoff
== 0);
161 if (INT_GET(block
->bb_level
, ARCH_CONVERT
) > 0)
163 return INT_GET(block
->bb_numrecs
, ARCH_CONVERT
);
173 xfs_inobt_block_t
*block
;
176 ASSERT(startoff
== 0);
178 ASSERT(INT_GET(block
->bb_level
, ARCH_CONVERT
) == 0);
179 rp
= XFS_BTREE_REC_ADDR(mp
->m_sb
.sb_blocksize
, xfs_inobt
, block
, idx
,
180 XFS_BTREE_BLOCK_MAXRECS(mp
->m_sb
.sb_blocksize
, xfs_inobt
, 1));
181 return bitize((int)((char *)rp
- (char *)block
));
191 return bitize(mp
->m_sb
.sb_blocksize
);