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 dir2_block_hdr_count(void *obj
, int startoff
);
45 static int dir2_block_leaf_count(void *obj
, int startoff
);
46 static int dir2_block_leaf_offset(void *obj
, int startoff
, int idx
);
47 static int dir2_block_tail_count(void *obj
, int startoff
);
48 static int dir2_block_tail_offset(void *obj
, int startoff
, int idx
);
49 static int dir2_block_u_count(void *obj
, int startoff
);
50 static int dir2_block_u_offset(void *obj
, int startoff
, int idx
);
51 static int dir2_data_union_freetag_count(void *obj
, int startoff
);
52 static int dir2_data_union_inumber_count(void *obj
, int startoff
);
53 static int dir2_data_union_length_count(void *obj
, int startoff
);
54 static int dir2_data_union_name_count(void *obj
, int startoff
);
55 static int dir2_data_union_namelen_count(void *obj
, int startoff
);
56 static int dir2_data_union_tag_count(void *obj
, int startoff
);
57 static int dir2_data_union_tag_offset(void *obj
, int startoff
, int idx
);
58 static int dir2_data_hdr_count(void *obj
, int startoff
);
59 static int dir2_data_u_count(void *obj
, int startoff
);
60 static int dir2_data_u_offset(void *obj
, int startoff
, int idx
);
61 static int dir2_free_bests_count(void *obj
, int startoff
);
62 static int dir2_free_hdr_count(void *obj
, int startoff
);
63 static int dir2_leaf_bests_count(void *obj
, int startoff
);
64 static int dir2_leaf_bests_offset(void *obj
, int startoff
, int idx
);
65 static int dir2_leaf_ents_count(void *obj
, int startoff
);
66 static int dir2_leaf_hdr_count(void *obj
, int startoff
);
67 static int dir2_leaf_tail_count(void *obj
, int startoff
);
68 static int dir2_leaf_tail_offset(void *obj
, int startoff
, int idx
);
69 static int dir2_node_btree_count(void *obj
, int startoff
);
70 static int dir2_node_hdr_count(void *obj
, int startoff
);
72 const field_t dir2_hfld
[] = {
73 { "", FLDT_DIR2
, OI(0), C1
, 0, TYP_NONE
},
77 #define BOFF(f) bitize(offsetof(xfs_dir2_block_t, f))
78 #define DOFF(f) bitize(offsetof(xfs_dir2_data_t, f))
79 #define FOFF(f) bitize(offsetof(xfs_dir2_free_t, f))
80 #define LOFF(f) bitize(offsetof(xfs_dir2_leaf_t, f))
81 #define NOFF(f) bitize(offsetof(xfs_da_intnode_t, f))
82 const field_t dir2_flds
[] = {
83 { "bhdr", FLDT_DIR2_DATA_HDR
, OI(BOFF(hdr
)), dir2_block_hdr_count
,
84 FLD_COUNT
, TYP_NONE
},
85 { "bu", FLDT_DIR2_DATA_UNION
, dir2_block_u_offset
, dir2_block_u_count
,
86 FLD_ARRAY
|FLD_OFFSET
|FLD_COUNT
, TYP_NONE
},
87 { "bleaf", FLDT_DIR2_LEAF_ENTRY
, dir2_block_leaf_offset
,
88 dir2_block_leaf_count
, FLD_ARRAY
|FLD_OFFSET
|FLD_COUNT
, TYP_NONE
},
89 { "btail", FLDT_DIR2_BLOCK_TAIL
, dir2_block_tail_offset
,
90 dir2_block_tail_count
, FLD_OFFSET
|FLD_COUNT
, TYP_NONE
},
91 { "dhdr", FLDT_DIR2_DATA_HDR
, OI(DOFF(hdr
)), dir2_data_hdr_count
,
92 FLD_COUNT
, TYP_NONE
},
93 { "du", FLDT_DIR2_DATA_UNION
, dir2_data_u_offset
, dir2_data_u_count
,
94 FLD_ARRAY
|FLD_OFFSET
|FLD_COUNT
, TYP_NONE
},
95 { "lhdr", FLDT_DIR2_LEAF_HDR
, OI(LOFF(hdr
)), dir2_leaf_hdr_count
,
96 FLD_COUNT
, TYP_NONE
},
97 { "lbests", FLDT_DIR2_DATA_OFF
, dir2_leaf_bests_offset
,
98 dir2_leaf_bests_count
, FLD_ARRAY
|FLD_OFFSET
|FLD_COUNT
, TYP_NONE
},
99 { "lents", FLDT_DIR2_LEAF_ENTRY
, OI(LOFF(ents
)), dir2_leaf_ents_count
,
100 FLD_ARRAY
|FLD_COUNT
, TYP_NONE
},
101 { "ltail", FLDT_DIR2_LEAF_TAIL
, dir2_leaf_tail_offset
,
102 dir2_leaf_tail_count
, FLD_OFFSET
|FLD_COUNT
, TYP_NONE
},
103 { "nhdr", FLDT_DIR_NODE_HDR
, OI(NOFF(hdr
)), dir2_node_hdr_count
,
104 FLD_COUNT
, TYP_NONE
},
105 { "nbtree", FLDT_DIR_NODE_ENTRY
, OI(NOFF(btree
)), dir2_node_btree_count
,
106 FLD_ARRAY
|FLD_COUNT
, TYP_NONE
},
107 { "fhdr", FLDT_DIR2_FREE_HDR
, OI(FOFF(hdr
)), dir2_free_hdr_count
,
108 FLD_COUNT
, TYP_NONE
},
109 { "fbests", FLDT_DIR2_DATA_OFFNZ
, OI(FOFF(bests
)),
110 dir2_free_bests_count
, FLD_ARRAY
|FLD_COUNT
, TYP_NONE
},
114 #define BTOFF(f) bitize(offsetof(xfs_dir2_block_tail_t, f))
115 const field_t dir2_block_tail_flds
[] = {
116 { "count", FLDT_UINT32D
, OI(BTOFF(count
)), C1
, 0, TYP_NONE
},
117 { "stale", FLDT_UINT32D
, OI(BTOFF(stale
)), C1
, 0, TYP_NONE
},
121 #define DFOFF(f) bitize(offsetof(xfs_dir2_data_free_t, f))
122 const field_t dir2_data_free_flds
[] = {
123 { "offset", FLDT_DIR2_DATA_OFF
, OI(DFOFF(offset
)), C1
, 0, TYP_NONE
},
124 { "length", FLDT_DIR2_DATA_OFF
, OI(DFOFF(length
)), C1
, 0, TYP_NONE
},
128 #define DHOFF(f) bitize(offsetof(xfs_dir2_data_hdr_t, f))
129 const field_t dir2_data_hdr_flds
[] = {
130 { "magic", FLDT_UINT32X
, OI(DHOFF(magic
)), C1
, 0, TYP_NONE
},
131 { "bestfree", FLDT_DIR2_DATA_FREE
, OI(DHOFF(bestfree
)),
132 CI(XFS_DIR2_DATA_FD_COUNT
), FLD_ARRAY
, TYP_NONE
},
136 #define DEOFF(f) bitize(offsetof(xfs_dir2_data_entry_t, f))
137 #define DUOFF(f) bitize(offsetof(xfs_dir2_data_unused_t, f))
138 const field_t dir2_data_union_flds
[] = {
139 { "freetag", FLDT_UINT16X
, OI(DUOFF(freetag
)),
140 dir2_data_union_freetag_count
, FLD_COUNT
, TYP_NONE
},
141 { "inumber", FLDT_INO
, OI(DEOFF(inumber
)),
142 dir2_data_union_inumber_count
, FLD_COUNT
, TYP_INODE
},
143 { "length", FLDT_DIR2_DATA_OFF
, OI(DUOFF(length
)),
144 dir2_data_union_length_count
, FLD_COUNT
, TYP_NONE
},
145 { "namelen", FLDT_UINT8D
, OI(DEOFF(namelen
)),
146 dir2_data_union_namelen_count
, FLD_COUNT
, TYP_NONE
},
147 { "name", FLDT_CHARNS
, OI(DEOFF(name
)), dir2_data_union_name_count
,
148 FLD_COUNT
, TYP_NONE
},
149 { "tag", FLDT_DIR2_DATA_OFF
, dir2_data_union_tag_offset
,
150 dir2_data_union_tag_count
, FLD_OFFSET
|FLD_COUNT
, TYP_NONE
},
154 #define LEOFF(f) bitize(offsetof(xfs_dir2_leaf_entry_t, f))
155 const field_t dir2_leaf_entry_flds
[] = {
156 { "hashval", FLDT_UINT32X
, OI(LEOFF(hashval
)), C1
, 0, TYP_NONE
},
157 { "address", FLDT_UINT32X
, OI(LEOFF(address
)), C1
, 0, TYP_NONE
},
161 #define LHOFF(f) bitize(offsetof(xfs_dir2_leaf_hdr_t, f))
162 const field_t dir2_leaf_hdr_flds
[] = {
163 { "info", FLDT_DIR_BLKINFO
, OI(LHOFF(info
)), C1
, 0, TYP_NONE
},
164 { "count", FLDT_UINT16D
, OI(LHOFF(count
)), C1
, 0, TYP_NONE
},
165 { "stale", FLDT_UINT16D
, OI(LHOFF(stale
)), C1
, 0, TYP_NONE
},
169 #define LTOFF(f) bitize(offsetof(xfs_dir2_leaf_tail_t, f))
170 const field_t dir2_leaf_tail_flds
[] = {
171 { "bestcount", FLDT_UINT32D
, OI(LTOFF(bestcount
)), C1
, 0, TYP_NONE
},
175 #define FHOFF(f) bitize(offsetof(xfs_dir2_free_hdr_t, f))
176 const field_t dir2_free_hdr_flds
[] = {
177 { "magic", FLDT_UINT32X
, OI(FHOFF(magic
)), C1
, 0, TYP_NONE
},
178 { "firstdb", FLDT_INT32D
, OI(FHOFF(firstdb
)), C1
, 0, TYP_NONE
},
179 { "nvalid", FLDT_INT32D
, OI(FHOFF(nvalid
)), C1
, 0, TYP_NONE
},
180 { "nused", FLDT_INT32D
, OI(FHOFF(nused
)), C1
, 0, TYP_NONE
},
186 dir2_block_hdr_count(
190 xfs_dir2_block_t
*block
;
192 ASSERT(startoff
== 0);
194 return INT_GET(block
->hdr
.magic
, ARCH_CONVERT
) == XFS_DIR2_BLOCK_MAGIC
;
199 dir2_block_leaf_count(
203 xfs_dir2_block_t
*block
;
204 xfs_dir2_block_tail_t
*btp
;
206 ASSERT(startoff
== 0);
208 if (INT_GET(block
->hdr
.magic
, ARCH_CONVERT
) != XFS_DIR2_BLOCK_MAGIC
)
210 btp
= XFS_DIR2_BLOCK_TAIL_P(mp
, block
);
211 return INT_GET(btp
->count
, ARCH_CONVERT
);
216 dir2_block_leaf_offset(
221 xfs_dir2_block_t
*block
;
222 xfs_dir2_block_tail_t
*btp
;
223 xfs_dir2_leaf_entry_t
*lep
;
225 ASSERT(startoff
== 0);
227 ASSERT(INT_GET(block
->hdr
.magic
, ARCH_CONVERT
) == XFS_DIR2_BLOCK_MAGIC
);
228 btp
= XFS_DIR2_BLOCK_TAIL_P(mp
, block
);
229 lep
= XFS_DIR2_BLOCK_LEAF_P_ARCH(btp
, ARCH_CONVERT
) + idx
;
230 return bitize((int)((char *)lep
- (char *)block
));
235 dir2_block_tail_count(
239 xfs_dir2_block_t
*block
;
241 ASSERT(startoff
== 0);
243 return INT_GET(block
->hdr
.magic
, ARCH_CONVERT
) == XFS_DIR2_BLOCK_MAGIC
;
248 dir2_block_tail_offset(
253 xfs_dir2_block_t
*block
;
254 xfs_dir2_block_tail_t
*btp
;
256 ASSERT(startoff
== 0);
259 ASSERT(INT_GET(block
->hdr
.magic
, ARCH_CONVERT
) == XFS_DIR2_BLOCK_MAGIC
);
260 btp
= XFS_DIR2_BLOCK_TAIL_P(mp
, block
);
261 return bitize((int)((char *)btp
- (char *)block
));
270 xfs_dir2_block_t
*block
;
271 xfs_dir2_block_tail_t
*btp
;
272 xfs_dir2_data_entry_t
*dep
;
273 xfs_dir2_data_unused_t
*dup
;
278 ASSERT(startoff
== 0);
280 if (INT_GET(block
->hdr
.magic
, ARCH_CONVERT
) != XFS_DIR2_BLOCK_MAGIC
)
282 btp
= XFS_DIR2_BLOCK_TAIL_P(mp
, block
);
283 ptr
= (char *)block
->u
;
284 endptr
= (char *)XFS_DIR2_BLOCK_LEAF_P_ARCH(btp
, ARCH_CONVERT
);
285 for (i
= 0; ptr
< endptr
; i
++) {
286 dup
= (xfs_dir2_data_unused_t
*)ptr
;
287 if (INT_GET(dup
->freetag
, ARCH_CONVERT
) == XFS_DIR2_DATA_FREE_TAG
)
288 ptr
+= INT_GET(dup
->length
, ARCH_CONVERT
);
290 dep
= (xfs_dir2_data_entry_t
*)ptr
;
291 ptr
+= XFS_DIR2_DATA_ENTSIZE(dep
->namelen
);
304 xfs_dir2_block_t
*block
;
305 xfs_dir2_block_tail_t
*btp
;
306 xfs_dir2_data_entry_t
*dep
;
307 xfs_dir2_data_unused_t
*dup
;
313 ASSERT(startoff
== 0);
315 ASSERT(INT_GET(block
->hdr
.magic
, ARCH_CONVERT
) == XFS_DIR2_BLOCK_MAGIC
);
316 btp
= XFS_DIR2_BLOCK_TAIL_P(mp
, block
);
317 ptr
= (char *)block
->u
;
318 endptr
= (char *)XFS_DIR2_BLOCK_LEAF_P_ARCH(btp
, ARCH_CONVERT
);
319 for (i
= 0; i
< idx
; i
++) {
320 ASSERT(ptr
< endptr
);
321 dup
= (xfs_dir2_data_unused_t
*)ptr
;
322 if (INT_GET(dup
->freetag
, ARCH_CONVERT
) == XFS_DIR2_DATA_FREE_TAG
)
323 ptr
+= INT_GET(dup
->length
, ARCH_CONVERT
);
325 dep
= (xfs_dir2_data_entry_t
*)ptr
;
326 ptr
+= XFS_DIR2_DATA_ENTSIZE(dep
->namelen
);
329 return bitize((int)(ptr
- (char *)block
));
333 dir2_data_union_freetag_count(
337 xfs_dir2_data_unused_t
*dup
;
340 ASSERT(bitoffs(startoff
) == 0);
341 dup
= (xfs_dir2_data_unused_t
*)((char *)obj
+ byteize(startoff
));
342 end
= (char *)&dup
->freetag
+ sizeof(dup
->freetag
);
343 return end
<= (char *)obj
+ mp
->m_dirblksize
&&
344 INT_GET(dup
->freetag
, ARCH_CONVERT
) == XFS_DIR2_DATA_FREE_TAG
;
348 dir2_data_union_inumber_count(
352 xfs_dir2_data_entry_t
*dep
;
353 xfs_dir2_data_unused_t
*dup
;
356 ASSERT(bitoffs(startoff
) == 0);
357 dup
= (xfs_dir2_data_unused_t
*)((char *)obj
+ byteize(startoff
));
358 dep
= (xfs_dir2_data_entry_t
*)dup
;
359 end
= (char *)&dep
->inumber
+ sizeof(dep
->inumber
);
360 return end
<= (char *)obj
+ mp
->m_dirblksize
&&
361 INT_GET(dup
->freetag
, ARCH_CONVERT
) != XFS_DIR2_DATA_FREE_TAG
;
365 dir2_data_union_length_count(
369 xfs_dir2_data_unused_t
*dup
;
372 ASSERT(bitoffs(startoff
) == 0);
373 dup
= (xfs_dir2_data_unused_t
*)((char *)obj
+ byteize(startoff
));
374 end
= (char *)&dup
->length
+ sizeof(dup
->length
);
375 return end
<= (char *)obj
+ mp
->m_dirblksize
&&
376 INT_GET(dup
->freetag
, ARCH_CONVERT
) == XFS_DIR2_DATA_FREE_TAG
;
380 dir2_data_union_name_count(
384 xfs_dir2_data_entry_t
*dep
;
385 xfs_dir2_data_unused_t
*dup
;
388 ASSERT(bitoffs(startoff
) == 0);
389 dup
= (xfs_dir2_data_unused_t
*)((char *)obj
+ byteize(startoff
));
390 dep
= (xfs_dir2_data_entry_t
*)dup
;
391 end
= (char *)&dep
->namelen
+ sizeof(dep
->namelen
);
392 if (end
>= (char *)obj
+ mp
->m_dirblksize
||
393 INT_GET(dup
->freetag
, ARCH_CONVERT
) == XFS_DIR2_DATA_FREE_TAG
)
395 end
= (char *)&dep
->name
[0] + dep
->namelen
;
396 return end
<= (char *)obj
+ mp
->m_dirblksize
? dep
->namelen
: 0;
400 dir2_data_union_namelen_count(
404 xfs_dir2_data_entry_t
*dep
;
405 xfs_dir2_data_unused_t
*dup
;
408 ASSERT(bitoffs(startoff
) == 0);
409 dup
= (xfs_dir2_data_unused_t
*)((char *)obj
+ byteize(startoff
));
410 dep
= (xfs_dir2_data_entry_t
*)dup
;
411 end
= (char *)&dep
->namelen
+ sizeof(dep
->namelen
);
412 return end
<= (char *)obj
+ mp
->m_dirblksize
&&
413 INT_GET(dup
->freetag
, ARCH_CONVERT
) != XFS_DIR2_DATA_FREE_TAG
;
417 dir2_data_union_tag_count(
421 xfs_dir2_data_entry_t
*dep
;
422 xfs_dir2_data_unused_t
*dup
;
424 xfs_dir2_data_off_t
*tagp
;
426 ASSERT(bitoffs(startoff
) == 0);
427 dup
= (xfs_dir2_data_unused_t
*)((char *)obj
+ byteize(startoff
));
428 dep
= (xfs_dir2_data_entry_t
*)dup
;
429 end
= (char *)&dup
->freetag
+ sizeof(dup
->freetag
);
430 if (end
> (char *)obj
+ mp
->m_dirblksize
)
432 if (INT_GET(dup
->freetag
, ARCH_CONVERT
) == XFS_DIR2_DATA_FREE_TAG
) {
433 end
= (char *)&dup
->length
+ sizeof(dup
->length
);
434 if (end
> (char *)obj
+ mp
->m_dirblksize
)
436 tagp
= XFS_DIR2_DATA_UNUSED_TAG_P_ARCH(dup
, ARCH_CONVERT
);
438 end
= (char *)&dep
->namelen
+ sizeof(dep
->namelen
);
439 if (end
> (char *)obj
+ mp
->m_dirblksize
)
441 tagp
= XFS_DIR2_DATA_ENTRY_TAG_P(dep
);
443 end
= (char *)tagp
+ sizeof(*tagp
);
444 return end
<= (char *)obj
+ mp
->m_dirblksize
;
449 dir2_data_union_tag_offset(
454 xfs_dir2_data_entry_t
*dep
;
455 xfs_dir2_data_unused_t
*dup
;
457 ASSERT(bitoffs(startoff
) == 0);
459 dup
= (xfs_dir2_data_unused_t
*)((char *)obj
+ byteize(startoff
));
460 if (INT_GET(dup
->freetag
, ARCH_CONVERT
) == XFS_DIR2_DATA_FREE_TAG
)
461 return bitize((int)((char *)XFS_DIR2_DATA_UNUSED_TAG_P_ARCH(dup
, ARCH_CONVERT
) -
463 dep
= (xfs_dir2_data_entry_t
*)dup
;
464 return bitize((int)((char *)XFS_DIR2_DATA_ENTRY_TAG_P(dep
) -
474 xfs_dir2_data_t
*data
;
476 ASSERT(startoff
== 0);
478 return INT_GET(data
->hdr
.magic
, ARCH_CONVERT
) == XFS_DIR2_DATA_MAGIC
;
487 xfs_dir2_data_t
*data
;
488 xfs_dir2_data_entry_t
*dep
;
489 xfs_dir2_data_unused_t
*dup
;
494 ASSERT(startoff
== 0);
496 if (INT_GET(data
->hdr
.magic
, ARCH_CONVERT
) != XFS_DIR2_DATA_MAGIC
)
498 ptr
= (char *)data
->u
;
499 endptr
= (char *)data
+ mp
->m_dirblksize
;
500 for (i
= 0; ptr
< endptr
; i
++) {
501 dup
= (xfs_dir2_data_unused_t
*)ptr
;
502 if (INT_GET(dup
->freetag
, ARCH_CONVERT
) == XFS_DIR2_DATA_FREE_TAG
)
503 ptr
+= INT_GET(dup
->length
, ARCH_CONVERT
);
505 dep
= (xfs_dir2_data_entry_t
*)ptr
;
506 ptr
+= XFS_DIR2_DATA_ENTSIZE(dep
->namelen
);
519 xfs_dir2_data_t
*data
;
520 xfs_dir2_data_entry_t
*dep
;
521 xfs_dir2_data_unused_t
*dup
;
527 ASSERT(startoff
== 0);
529 ASSERT(INT_GET(data
->hdr
.magic
, ARCH_CONVERT
) == XFS_DIR2_DATA_MAGIC
);
530 ptr
= (char *)data
->u
;
531 endptr
= (char *)data
+ mp
->m_dirblksize
;
532 for (i
= 0; i
< idx
; i
++) {
533 ASSERT(ptr
< endptr
);
534 dup
= (xfs_dir2_data_unused_t
*)ptr
;
535 if (INT_GET(dup
->freetag
, ARCH_CONVERT
) == XFS_DIR2_DATA_FREE_TAG
)
536 ptr
+= INT_GET(dup
->length
, ARCH_CONVERT
);
538 dep
= (xfs_dir2_data_entry_t
*)ptr
;
539 ptr
+= XFS_DIR2_DATA_ENTSIZE(dep
->namelen
);
542 return bitize((int)(ptr
- (char *)data
));
547 dir2_data_union_size(
552 xfs_dir2_data_entry_t
*dep
;
553 xfs_dir2_data_unused_t
*dup
;
555 ASSERT(bitoffs(startoff
) == 0);
557 dup
= (xfs_dir2_data_unused_t
*)((char *)obj
+ byteize(startoff
));
558 if (INT_GET(dup
->freetag
, ARCH_CONVERT
) == XFS_DIR2_DATA_FREE_TAG
)
559 return bitize(INT_GET(dup
->length
, ARCH_CONVERT
));
561 dep
= (xfs_dir2_data_entry_t
*)dup
;
562 return bitize(XFS_DIR2_DATA_ENTSIZE(dep
->namelen
));
568 dir2_free_bests_count(
572 xfs_dir2_free_t
*free
;
574 ASSERT(startoff
== 0);
576 if (INT_GET(free
->hdr
.magic
, ARCH_CONVERT
) != XFS_DIR2_FREE_MAGIC
)
578 return INT_GET(free
->hdr
.nvalid
, ARCH_CONVERT
);
587 xfs_dir2_free_t
*free
;
589 ASSERT(startoff
== 0);
591 return INT_GET(free
->hdr
.magic
, ARCH_CONVERT
) == XFS_DIR2_FREE_MAGIC
;
596 dir2_leaf_bests_count(
600 xfs_dir2_leaf_t
*leaf
;
601 xfs_dir2_leaf_tail_t
*ltp
;
603 ASSERT(startoff
== 0);
605 if (INT_GET(leaf
->hdr
.info
.magic
, ARCH_CONVERT
) != XFS_DIR2_LEAF1_MAGIC
)
607 ltp
= XFS_DIR2_LEAF_TAIL_P(mp
, leaf
);
608 return INT_GET(ltp
->bestcount
, ARCH_CONVERT
);
613 dir2_leaf_bests_offset(
618 xfs_dir2_data_off_t
*lbp
;
619 xfs_dir2_leaf_t
*leaf
;
620 xfs_dir2_leaf_tail_t
*ltp
;
622 ASSERT(startoff
== 0);
624 ASSERT(INT_GET(leaf
->hdr
.info
.magic
, ARCH_CONVERT
) == XFS_DIR2_LEAF1_MAGIC
);
625 ltp
= XFS_DIR2_LEAF_TAIL_P(mp
, leaf
);
626 lbp
= XFS_DIR2_LEAF_BESTS_P_ARCH(ltp
, ARCH_CONVERT
) + idx
;
627 return bitize((int)((char *)lbp
- (char *)leaf
));
632 dir2_leaf_ents_count(
636 xfs_dir2_leaf_t
*leaf
;
638 ASSERT(startoff
== 0);
640 if (INT_GET(leaf
->hdr
.info
.magic
, ARCH_CONVERT
) != XFS_DIR2_LEAF1_MAGIC
&&
641 INT_GET(leaf
->hdr
.info
.magic
, ARCH_CONVERT
) != XFS_DIR2_LEAFN_MAGIC
)
643 return INT_GET(leaf
->hdr
.count
, ARCH_CONVERT
);
652 xfs_dir2_leaf_t
*leaf
;
654 ASSERT(startoff
== 0);
656 return INT_GET(leaf
->hdr
.info
.magic
, ARCH_CONVERT
) == XFS_DIR2_LEAF1_MAGIC
||
657 INT_GET(leaf
->hdr
.info
.magic
, ARCH_CONVERT
) == XFS_DIR2_LEAFN_MAGIC
;
662 dir2_leaf_tail_count(
666 xfs_dir2_leaf_t
*leaf
;
668 ASSERT(startoff
== 0);
670 return INT_GET(leaf
->hdr
.info
.magic
, ARCH_CONVERT
) == XFS_DIR2_LEAF1_MAGIC
;
675 dir2_leaf_tail_offset(
680 xfs_dir2_leaf_t
*leaf
;
681 xfs_dir2_leaf_tail_t
*ltp
;
683 ASSERT(startoff
== 0);
686 ASSERT(INT_GET(leaf
->hdr
.info
.magic
, ARCH_CONVERT
) == XFS_DIR2_LEAF1_MAGIC
);
687 ltp
= XFS_DIR2_LEAF_TAIL_P(mp
, leaf
);
688 return bitize((int)((char *)ltp
- (char *)leaf
));
693 dir2_node_btree_count(
697 xfs_da_intnode_t
*node
;
699 ASSERT(startoff
== 0);
701 if (INT_GET(node
->hdr
.info
.magic
, ARCH_CONVERT
) != XFS_DA_NODE_MAGIC
)
703 return INT_GET(node
->hdr
.count
, ARCH_CONVERT
);
712 xfs_da_intnode_t
*node
;
714 ASSERT(startoff
== 0);
716 return INT_GET(node
->hdr
.info
.magic
, ARCH_CONVERT
) == XFS_DA_NODE_MAGIC
;
726 return bitize(mp
->m_dirblksize
);