2 * linux/fs/hfsplus/brec.c
5 * Brad Boyer (flar@allandria.com)
6 * (C) 2003 Ardis Technologies <roman@ardistech.com>
8 * Handle individual btree records
11 #include "hfsplus_fs.h"
12 #include "hfsplus_raw.h"
14 /* Get the length and offset of the given record in the given node */
15 u16 hfsplus_brec_lenoff(hfsplus_bnode *node, u16 rec, u16 *off)
20 dataoff = node->tree->node_size - (rec + 2) * 2;
21 hfsplus_bnode_readbytes(node, retval, dataoff, 4);
22 *off = be16_to_cpu(retval[1]);
23 return be16_to_cpu(retval[0]) - *off;
26 /* Get the length of the key from a keyed record */
27 u16 hfsplus_brec_keylen(hfsplus_bnode *node, u16 rec)
29 u16 klsz, retval, recoff;
32 if ((node->kind != HFSPLUS_NODE_NDX)&&(node->kind != HFSPLUS_NODE_LEAF))
35 klsz = (node->tree->attributes & HFSPLUS_TREE_BIGKEYS) ? 2 : 1;
36 if ((node->kind == HFSPLUS_NODE_NDX) &&
37 !(node->tree->attributes & HFSPLUS_TREE_VAR_NDXKEY_SIZE)) {
38 retval = node->tree->max_key_len;
40 recoff = hfsplus_bnode_read_u16(node, node->tree->node_size - (rec + 1) * 2);
43 hfsplus_bnode_readbytes(node, buf, recoff, klsz);
47 retval = be16_to_cpu(*(u16 *)buf);
49 return (retval + klsz + 1) & 0xFFFE;