]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
da23017d NS |
2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
dfc130f3 | 4 | * |
da23017d NS |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as | |
2bd0ea18 | 7 | * published by the Free Software Foundation. |
dfc130f3 | 8 | * |
da23017d NS |
9 | * This program is distributed in the hope that it would be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
dfc130f3 | 13 | * |
da23017d NS |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
2bd0ea18 NS |
17 | */ |
18 | ||
1d7e80ee | 19 | #include <xfs/libxfs.h> |
2bd0ea18 NS |
20 | #include "type.h" |
21 | #include "faddr.h" | |
22 | #include "fprint.h" | |
23 | #include "field.h" | |
24 | #include "bmroot.h" | |
25 | #include "io.h" | |
26 | #include "print.h" | |
27 | #include "bit.h" | |
4ca431fc | 28 | #include "init.h" |
2bd0ea18 NS |
29 | |
30 | static int bmroota_key_count(void *obj, int startoff); | |
31 | static int bmroota_key_offset(void *obj, int startoff, int idx); | |
32 | static int bmroota_ptr_count(void *obj, int startoff); | |
33 | static int bmroota_ptr_offset(void *obj, int startoff, int idx); | |
34 | static int bmrootd_key_count(void *obj, int startoff); | |
35 | static int bmrootd_key_offset(void *obj, int startoff, int idx); | |
36 | static int bmrootd_ptr_count(void *obj, int startoff); | |
37 | static int bmrootd_ptr_offset(void *obj, int startoff, int idx); | |
38 | ||
39 | #define OFF(f) bitize(offsetof(xfs_bmdr_block_t, bb_ ## f)) | |
40 | const field_t bmroota_flds[] = { | |
41 | { "level", FLDT_UINT16D, OI(OFF(level)), C1, 0, TYP_NONE }, | |
42 | { "numrecs", FLDT_UINT16D, OI(OFF(numrecs)), C1, 0, TYP_NONE }, | |
43 | { "keys", FLDT_BMROOTAKEY, bmroota_key_offset, bmroota_key_count, | |
44 | FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE }, | |
45 | { "ptrs", FLDT_BMROOTAPTR, bmroota_ptr_offset, bmroota_ptr_count, | |
46 | FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_BMAPBTA }, | |
47 | { NULL } | |
48 | }; | |
49 | const field_t bmrootd_flds[] = { | |
50 | { "level", FLDT_UINT16D, OI(OFF(level)), C1, 0, TYP_NONE }, | |
51 | { "numrecs", FLDT_UINT16D, OI(OFF(numrecs)), C1, 0, TYP_NONE }, | |
52 | { "keys", FLDT_BMROOTDKEY, bmrootd_key_offset, bmrootd_key_count, | |
53 | FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE }, | |
54 | { "ptrs", FLDT_BMROOTDPTR, bmrootd_ptr_offset, bmrootd_ptr_count, | |
55 | FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_BMAPBTD }, | |
56 | { NULL } | |
57 | }; | |
58 | ||
59 | #define KOFF(f) bitize(offsetof(xfs_bmdr_key_t, br_ ## f)) | |
60 | const field_t bmroota_key_flds[] = { | |
61 | { "startoff", FLDT_DFILOFFA, OI(KOFF(startoff)), C1, 0, TYP_NONE }, | |
62 | { NULL } | |
63 | }; | |
64 | const field_t bmrootd_key_flds[] = { | |
65 | { "startoff", FLDT_DFILOFFD, OI(KOFF(startoff)), C1, 0, TYP_NONE }, | |
66 | { NULL } | |
67 | }; | |
68 | ||
69 | static int | |
70 | bmroota_key_count( | |
71 | void *obj, | |
72 | int startoff) | |
73 | { | |
74 | xfs_bmdr_block_t *block; | |
75 | #ifdef DEBUG | |
76 | xfs_dinode_t *dip = obj; | |
77 | #endif | |
78 | ||
79 | ASSERT(bitoffs(startoff) == 0); | |
80 | ASSERT(obj == iocur_top->data); | |
81 | block = (xfs_bmdr_block_t *)((char *)obj + byteize(startoff)); | |
82 | ASSERT(XFS_DFORK_Q(dip) && (char *)block == XFS_DFORK_APTR(dip)); | |
83 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | |
84 | return INT_GET(block->bb_numrecs, ARCH_CONVERT); | |
85 | } | |
86 | ||
87 | static int | |
88 | bmroota_key_offset( | |
89 | void *obj, | |
90 | int startoff, | |
91 | int idx) | |
92 | { | |
93 | xfs_bmdr_block_t *block; | |
94 | /* REFERENCED */ | |
95 | xfs_dinode_t *dip; | |
96 | xfs_bmdr_key_t *kp; | |
97 | ||
98 | ASSERT(bitoffs(startoff) == 0); | |
99 | ASSERT(obj == iocur_top->data); | |
100 | dip = obj; | |
101 | block = (xfs_bmdr_block_t *)((char *)obj + byteize(startoff)); | |
102 | ASSERT(XFS_DFORK_Q(dip) && (char *)block == XFS_DFORK_APTR(dip)); | |
103 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | |
104 | kp = XFS_BTREE_KEY_ADDR(iocur_top->len, xfs_bmdr, block, idx, | |
105 | XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_ASIZE(dip, mp), xfs_bmdr, 0)); | |
106 | return bitize((int)((char *)kp - (char *)block)); | |
107 | } | |
108 | ||
109 | static int | |
110 | bmroota_ptr_count( | |
111 | void *obj, | |
112 | int startoff) | |
113 | { | |
114 | xfs_bmdr_block_t *block; | |
115 | #ifdef DEBUG | |
116 | xfs_dinode_t *dip = obj; | |
117 | #endif | |
118 | ||
119 | ASSERT(bitoffs(startoff) == 0); | |
120 | ASSERT(obj == iocur_top->data); | |
121 | block = (xfs_bmdr_block_t *)((char *)obj + byteize(startoff)); | |
122 | ASSERT(XFS_DFORK_Q(dip) && (char *)block == XFS_DFORK_APTR(dip)); | |
123 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | |
124 | return INT_GET(block->bb_numrecs, ARCH_CONVERT); | |
125 | } | |
126 | ||
127 | static int | |
128 | bmroota_ptr_offset( | |
129 | void *obj, | |
130 | int startoff, | |
131 | int idx) | |
132 | { | |
133 | xfs_bmdr_block_t *block; | |
134 | xfs_dinode_t *dip; | |
135 | xfs_bmdr_ptr_t *pp; | |
136 | ||
137 | ASSERT(bitoffs(startoff) == 0); | |
138 | ASSERT(obj == iocur_top->data); | |
139 | dip = obj; | |
140 | block = (xfs_bmdr_block_t *)((char *)obj + byteize(startoff)); | |
141 | ASSERT(XFS_DFORK_Q(dip) && (char *)block == XFS_DFORK_APTR(dip)); | |
142 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | |
143 | pp = XFS_BTREE_PTR_ADDR(iocur_top->len, xfs_bmdr, block, idx, | |
144 | XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_ASIZE(dip, mp), xfs_bmdr, 0)); | |
145 | return bitize((int)((char *)pp - (char *)block)); | |
146 | } | |
147 | ||
148 | int | |
149 | bmroota_size( | |
150 | void *obj, | |
151 | int startoff, | |
152 | int idx) | |
153 | { | |
154 | xfs_dinode_t *dip; | |
155 | #ifdef DEBUG | |
156 | xfs_bmdr_block_t *block; | |
157 | #endif | |
158 | ||
159 | ASSERT(bitoffs(startoff) == 0); | |
160 | ASSERT(obj == iocur_top->data); | |
161 | ASSERT(idx == 0); | |
162 | dip = obj; | |
163 | #ifdef DEBUG | |
164 | block = (xfs_bmdr_block_t *)((char *)obj + byteize(startoff)); | |
165 | ASSERT(XFS_DFORK_Q(dip) && (char *)block == XFS_DFORK_APTR(dip)); | |
166 | #endif | |
167 | return bitize((int)XFS_DFORK_ASIZE(dip, mp)); | |
168 | } | |
169 | ||
170 | static int | |
171 | bmrootd_key_count( | |
172 | void *obj, | |
173 | int startoff) | |
174 | { | |
175 | xfs_bmdr_block_t *block; | |
176 | #ifdef DEBUG | |
177 | xfs_dinode_t *dip = obj; | |
178 | #endif | |
179 | ||
180 | ASSERT(bitoffs(startoff) == 0); | |
181 | ASSERT(obj == iocur_top->data); | |
182 | block = (xfs_bmdr_block_t *)((char *)obj + byteize(startoff)); | |
183 | ASSERT((char *)block == XFS_DFORK_DPTR(dip)); | |
184 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | |
185 | return INT_GET(block->bb_numrecs, ARCH_CONVERT); | |
186 | } | |
187 | ||
188 | static int | |
189 | bmrootd_key_offset( | |
190 | void *obj, | |
191 | int startoff, | |
192 | int idx) | |
193 | { | |
194 | xfs_bmdr_block_t *block; | |
195 | xfs_bmdr_key_t *kp; | |
196 | xfs_dinode_t *dip; | |
197 | ||
198 | ASSERT(bitoffs(startoff) == 0); | |
199 | ASSERT(obj == iocur_top->data); | |
200 | dip = obj; | |
201 | block = (xfs_bmdr_block_t *)((char *)obj + byteize(startoff)); | |
202 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | |
203 | kp = XFS_BTREE_KEY_ADDR(iocur_top->len, xfs_bmdr, block, idx, | |
204 | XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_DSIZE(dip, mp), xfs_bmdr, 0)); | |
205 | return bitize((int)((char *)kp - (char *)block)); | |
206 | } | |
207 | ||
208 | static int | |
209 | bmrootd_ptr_count( | |
210 | void *obj, | |
211 | int startoff) | |
212 | { | |
213 | xfs_bmdr_block_t *block; | |
214 | #ifdef DEBUG | |
215 | xfs_dinode_t *dip = obj; | |
216 | #endif | |
217 | ||
218 | ASSERT(bitoffs(startoff) == 0); | |
219 | ASSERT(obj == iocur_top->data); | |
220 | block = (xfs_bmdr_block_t *)((char *)obj + byteize(startoff)); | |
221 | ASSERT((char *)block == XFS_DFORK_DPTR(dip)); | |
222 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | |
223 | return INT_GET(block->bb_numrecs, ARCH_CONVERT); | |
224 | } | |
225 | ||
226 | static int | |
227 | bmrootd_ptr_offset( | |
228 | void *obj, | |
229 | int startoff, | |
230 | int idx) | |
231 | { | |
232 | xfs_bmdr_block_t *block; | |
233 | xfs_bmdr_ptr_t *pp; | |
234 | xfs_dinode_t *dip; | |
235 | ||
236 | ASSERT(bitoffs(startoff) == 0); | |
237 | ASSERT(obj == iocur_top->data); | |
238 | dip = obj; | |
239 | block = (xfs_bmdr_block_t *)((char *)obj + byteize(startoff)); | |
240 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | |
241 | pp = XFS_BTREE_PTR_ADDR(iocur_top->len, xfs_bmdr, block, idx, | |
242 | XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_DSIZE(dip, mp), xfs_bmdr, 0)); | |
243 | return bitize((int)((char *)pp - (char *)block)); | |
244 | } | |
245 | ||
246 | int | |
247 | bmrootd_size( | |
248 | void *obj, | |
249 | int startoff, | |
250 | int idx) | |
251 | { | |
252 | xfs_dinode_t *dip; | |
253 | ||
254 | ASSERT(bitoffs(startoff) == 0); | |
255 | ASSERT(obj == iocur_top->data); | |
256 | ASSERT(idx == 0); | |
257 | dip = obj; | |
258 | return bitize((int)XFS_DFORK_DSIZE(dip, mp)); | |
259 | } |