diff options
Diffstat (limited to 'fs/hfsplus/brec.c')
-rw-r--r-- | fs/hfsplus/brec.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c index 2f39d05443e1..2312de34bd42 100644 --- a/fs/hfsplus/brec.c +++ b/fs/hfsplus/brec.c | |||
@@ -39,7 +39,8 @@ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec) | |||
39 | !(node->tree->attributes & HFS_TREE_VARIDXKEYS)) { | 39 | !(node->tree->attributes & HFS_TREE_VARIDXKEYS)) { |
40 | retval = node->tree->max_key_len + 2; | 40 | retval = node->tree->max_key_len + 2; |
41 | } else { | 41 | } else { |
42 | recoff = hfs_bnode_read_u16(node, node->tree->node_size - (rec + 1) * 2); | 42 | recoff = hfs_bnode_read_u16(node, |
43 | node->tree->node_size - (rec + 1) * 2); | ||
43 | if (!recoff) | 44 | if (!recoff) |
44 | return 0; | 45 | return 0; |
45 | 46 | ||
@@ -84,7 +85,8 @@ again: | |||
84 | end_rec_off = tree->node_size - (node->num_recs + 1) * 2; | 85 | end_rec_off = tree->node_size - (node->num_recs + 1) * 2; |
85 | end_off = hfs_bnode_read_u16(node, end_rec_off); | 86 | end_off = hfs_bnode_read_u16(node, end_rec_off); |
86 | end_rec_off -= 2; | 87 | end_rec_off -= 2; |
87 | dprint(DBG_BNODE_MOD, "insert_rec: %d, %d, %d, %d\n", rec, size, end_off, end_rec_off); | 88 | dprint(DBG_BNODE_MOD, "insert_rec: %d, %d, %d, %d\n", |
89 | rec, size, end_off, end_rec_off); | ||
88 | if (size > end_rec_off - end_off) { | 90 | if (size > end_rec_off - end_off) { |
89 | if (new_node) | 91 | if (new_node) |
90 | panic("not enough room!\n"); | 92 | panic("not enough room!\n"); |
@@ -99,7 +101,9 @@ again: | |||
99 | } | 101 | } |
100 | node->num_recs++; | 102 | node->num_recs++; |
101 | /* write new last offset */ | 103 | /* write new last offset */ |
102 | hfs_bnode_write_u16(node, offsetof(struct hfs_bnode_desc, num_recs), node->num_recs); | 104 | hfs_bnode_write_u16(node, |
105 | offsetof(struct hfs_bnode_desc, num_recs), | ||
106 | node->num_recs); | ||
103 | hfs_bnode_write_u16(node, end_rec_off, end_off + size); | 107 | hfs_bnode_write_u16(node, end_rec_off, end_off + size); |
104 | data_off = end_off; | 108 | data_off = end_off; |
105 | data_rec_off = end_rec_off + 2; | 109 | data_rec_off = end_rec_off + 2; |
@@ -151,7 +155,8 @@ skip: | |||
151 | if (tree->attributes & HFS_TREE_VARIDXKEYS) | 155 | if (tree->attributes & HFS_TREE_VARIDXKEYS) |
152 | key_len = be16_to_cpu(fd->search_key->key_len) + 2; | 156 | key_len = be16_to_cpu(fd->search_key->key_len) + 2; |
153 | else { | 157 | else { |
154 | fd->search_key->key_len = cpu_to_be16(tree->max_key_len); | 158 | fd->search_key->key_len = |
159 | cpu_to_be16(tree->max_key_len); | ||
155 | key_len = tree->max_key_len + 2; | 160 | key_len = tree->max_key_len + 2; |
156 | } | 161 | } |
157 | goto again; | 162 | goto again; |
@@ -180,7 +185,8 @@ again: | |||
180 | mark_inode_dirty(tree->inode); | 185 | mark_inode_dirty(tree->inode); |
181 | } | 186 | } |
182 | hfs_bnode_dump(node); | 187 | hfs_bnode_dump(node); |
183 | dprint(DBG_BNODE_MOD, "remove_rec: %d, %d\n", fd->record, fd->keylength + fd->entrylength); | 188 | dprint(DBG_BNODE_MOD, "remove_rec: %d, %d\n", |
189 | fd->record, fd->keylength + fd->entrylength); | ||
184 | if (!--node->num_recs) { | 190 | if (!--node->num_recs) { |
185 | hfs_bnode_unlink(node); | 191 | hfs_bnode_unlink(node); |
186 | if (!node->parent) | 192 | if (!node->parent) |
@@ -194,7 +200,9 @@ again: | |||
194 | __hfs_brec_find(node, fd); | 200 | __hfs_brec_find(node, fd); |
195 | goto again; | 201 | goto again; |
196 | } | 202 | } |
197 | hfs_bnode_write_u16(node, offsetof(struct hfs_bnode_desc, num_recs), node->num_recs); | 203 | hfs_bnode_write_u16(node, |
204 | offsetof(struct hfs_bnode_desc, num_recs), | ||
205 | node->num_recs); | ||
198 | 206 | ||
199 | if (rec_off == end_off) | 207 | if (rec_off == end_off) |
200 | goto skip; | 208 | goto skip; |
@@ -364,7 +372,8 @@ again: | |||
364 | newkeylen = hfs_bnode_read_u16(node, 14) + 2; | 372 | newkeylen = hfs_bnode_read_u16(node, 14) + 2; |
365 | else | 373 | else |
366 | fd->keylength = newkeylen = tree->max_key_len + 2; | 374 | fd->keylength = newkeylen = tree->max_key_len + 2; |
367 | dprint(DBG_BNODE_MOD, "update_rec: %d, %d, %d\n", rec, fd->keylength, newkeylen); | 375 | dprint(DBG_BNODE_MOD, "update_rec: %d, %d, %d\n", |
376 | rec, fd->keylength, newkeylen); | ||
368 | 377 | ||
369 | rec_off = tree->node_size - (rec + 2) * 2; | 378 | rec_off = tree->node_size - (rec + 2) * 2; |
370 | end_rec_off = tree->node_size - (parent->num_recs + 1) * 2; | 379 | end_rec_off = tree->node_size - (parent->num_recs + 1) * 2; |
@@ -375,7 +384,7 @@ again: | |||
375 | end_off = hfs_bnode_read_u16(parent, end_rec_off); | 384 | end_off = hfs_bnode_read_u16(parent, end_rec_off); |
376 | if (end_rec_off - end_off < diff) { | 385 | if (end_rec_off - end_off < diff) { |
377 | 386 | ||
378 | printk(KERN_DEBUG "hfs: splitting index node...\n"); | 387 | dprint(DBG_BNODE_MOD, "hfs: splitting index node.\n"); |
379 | fd->bnode = parent; | 388 | fd->bnode = parent; |
380 | new_node = hfs_bnode_split(fd); | 389 | new_node = hfs_bnode_split(fd); |
381 | if (IS_ERR(new_node)) | 390 | if (IS_ERR(new_node)) |
@@ -383,7 +392,8 @@ again: | |||
383 | parent = fd->bnode; | 392 | parent = fd->bnode; |
384 | rec = fd->record; | 393 | rec = fd->record; |
385 | rec_off = tree->node_size - (rec + 2) * 2; | 394 | rec_off = tree->node_size - (rec + 2) * 2; |
386 | end_rec_off = tree->node_size - (parent->num_recs + 1) * 2; | 395 | end_rec_off = tree->node_size - |
396 | (parent->num_recs + 1) * 2; | ||
387 | } | 397 | } |
388 | } | 398 | } |
389 | 399 | ||