22 #include <linux/slab.h>
70 ntfs_unmap_page(page);
131 u8 *index_end, *kaddr;
138 BUG_ON(!NInoAttr(idx_ni));
144 if (!ntfs_is_collation_rule_supported(
146 ntfs_error(sb,
"Index uses unsupported collation rule 0x%x. "
154 ntfs_error(sb,
"map_mft_record() failed with error code %ld.",
168 ntfs_error(sb,
"Index root attribute missing in inode "
169 "0x%lx.", idx_ni->
mft_no);
175 ir = (INDEX_ROOT*)((
u8*)actx->
attr +
177 index_end = (
u8*)&ir->index +
le32_to_cpu(ir->index.index_length);
179 ie = (INDEX_ENTRY*)((
u8*)&ir->index +
185 for (;; ie = (INDEX_ENTRY*)((
u8*)ie +
le16_to_cpu(ie->length))) {
188 sizeof(INDEX_ENTRY_HEADER) > index_end ||
198 if ((
u32)
sizeof(INDEX_ENTRY_HEADER) +
207 &ie->key, key_len)) {
255 if (!NInoIndexAllocPresent(idx_ni)) {
256 ntfs_error(sb,
"No index allocation attribute but index entry "
257 "requires one. Inode 0x%lx is corrupt or "
258 "driver bug.", idx_ni->
mft_no);
263 ia_mapping = VFS_I(idx_ni)->i_mapping;
272 descend_into_child_node:
278 page = ntfs_map_page(ia_mapping, vcn <<
281 ntfs_error(sb,
"Failed to map index page, error %ld.",
288 fast_descend_into_child_node:
294 ntfs_error(sb,
"Out of bounds check failed. Corrupt inode "
295 "0x%lx or driver bug.", idx_ni->
mft_no);
300 ntfs_error(sb,
"Index record with vcn 0x%llx is corrupt. "
301 "Corrupt inode 0x%lx. Run chkdsk.",
302 (
long long)vcn, idx_ni->
mft_no);
305 if (sle64_to_cpu(ia->index_block_vcn) != vcn) {
306 ntfs_error(sb,
"Actual VCN (0x%llx) of index buffer is "
307 "different from expected VCN (0x%llx). Inode "
308 "0x%lx is corrupt or driver bug.",
310 sle64_to_cpu(ia->index_block_vcn),
311 (
unsigned long long)vcn, idx_ni->
mft_no);
314 if (
le32_to_cpu(ia->index.allocated_size) + 0x18 !=
316 ntfs_error(sb,
"Index buffer (VCN 0x%llx) of inode 0x%lx has "
317 "a size (%u) differing from the index "
318 "specified size (%u). Inode is corrupt or "
319 "driver bug.", (
unsigned long long)vcn,
327 ntfs_error(sb,
"Index buffer (VCN 0x%llx) of inode 0x%lx "
328 "crosses page boundary. Impossible! Cannot "
329 "access! This is probably a bug in the "
330 "driver.", (
unsigned long long)vcn,
334 index_end = (
u8*)&ia->index +
le32_to_cpu(ia->index.index_length);
335 if (index_end > (
u8*)ia + idx_ni->
itype.
index.block_size) {
336 ntfs_error(sb,
"Size of index buffer (VCN 0x%llx) of inode "
337 "0x%lx exceeds maximum size.",
338 (
unsigned long long)vcn, idx_ni->
mft_no);
342 ie = (INDEX_ENTRY*)((
u8*)&ia->index +
349 for (;; ie = (INDEX_ENTRY*)((
u8*)ie +
le16_to_cpu(ie->length))) {
351 if ((
u8*)ie < (
u8*)ia || (
u8*)ie +
352 sizeof(INDEX_ENTRY_HEADER) > index_end ||
354 ntfs_error(sb,
"Index entry out of bounds in inode "
355 "0x%lx.", idx_ni->
mft_no);
365 if ((
u32)
sizeof(INDEX_ENTRY_HEADER) +
371 ntfs_error(sb,
"Index entry out of bounds in inode "
372 "0x%lx.", idx_ni->
mft_no);
377 &ie->key, key_len)) {
417 ntfs_error(sb,
"Index entry with child node found in a leaf "
418 "node in inode 0x%lx.", idx_ni->
mft_no);
433 goto fast_descend_into_child_node;
435 ntfs_unmap_page(page);
436 goto descend_into_child_node;
438 ntfs_error(sb,
"Negative child node vcn in inode 0x%lx.",
442 ntfs_unmap_page(page);
452 ntfs_error(sb,
"Corrupt index. Aborting lookup.");