index.c (e5451c8f8330e03ad3cfa16048b4daf961af434f) | index.c (09cbfeaf1a5a67bfb3201e0c83c810cecb2efa5a) |
---|---|
1/* 2 * index.c - NTFS kernel index handling. Part of the Linux-NTFS project. 3 * 4 * Copyright (c) 2004-2005 Anton Altaparmakov 5 * 6 * This program/include file is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as published 8 * by the Free Software Foundation; either version 2 of the License, or --- 262 unchanged lines hidden (view full) --- 271 actx = NULL; 272descend_into_child_node: 273 /* 274 * Convert vcn to index into the index allocation attribute in units 275 * of PAGE_CACHE_SIZE and map the page cache page, reading it from 276 * disk if necessary. 277 */ 278 page = ntfs_map_page(ia_mapping, vcn << | 1/* 2 * index.c - NTFS kernel index handling. Part of the Linux-NTFS project. 3 * 4 * Copyright (c) 2004-2005 Anton Altaparmakov 5 * 6 * This program/include file is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as published 8 * by the Free Software Foundation; either version 2 of the License, or --- 262 unchanged lines hidden (view full) --- 271 actx = NULL; 272descend_into_child_node: 273 /* 274 * Convert vcn to index into the index allocation attribute in units 275 * of PAGE_CACHE_SIZE and map the page cache page, reading it from 276 * disk if necessary. 277 */ 278 page = ntfs_map_page(ia_mapping, vcn << |
279 idx_ni->itype.index.vcn_size_bits >> PAGE_CACHE_SHIFT); | 279 idx_ni->itype.index.vcn_size_bits >> PAGE_SHIFT); |
280 if (IS_ERR(page)) { 281 ntfs_error(sb, "Failed to map index page, error %ld.", 282 -PTR_ERR(page)); 283 err = PTR_ERR(page); 284 goto err_out; 285 } 286 lock_page(page); 287 kaddr = (u8*)page_address(page); 288fast_descend_into_child_node: 289 /* Get to the index allocation block. */ 290 ia = (INDEX_ALLOCATION*)(kaddr + ((vcn << | 280 if (IS_ERR(page)) { 281 ntfs_error(sb, "Failed to map index page, error %ld.", 282 -PTR_ERR(page)); 283 err = PTR_ERR(page); 284 goto err_out; 285 } 286 lock_page(page); 287 kaddr = (u8*)page_address(page); 288fast_descend_into_child_node: 289 /* Get to the index allocation block. */ 290 ia = (INDEX_ALLOCATION*)(kaddr + ((vcn << |
291 idx_ni->itype.index.vcn_size_bits) & ~PAGE_CACHE_MASK)); | 291 idx_ni->itype.index.vcn_size_bits) & ~PAGE_MASK)); |
292 /* Bounds checks. */ | 292 /* Bounds checks. */ |
293 if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE) { | 293 if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_SIZE) { |
294 ntfs_error(sb, "Out of bounds check failed. Corrupt inode " 295 "0x%lx or driver bug.", idx_ni->mft_no); 296 goto unm_err_out; 297 } 298 /* Catch multi sector transfer fixup errors. */ 299 if (unlikely(!ntfs_is_indx_record(ia->magic))) { 300 ntfs_error(sb, "Index record with vcn 0x%llx is corrupt. " 301 "Corrupt inode 0x%lx. Run chkdsk.", --- 16 unchanged lines hidden (view full) --- 318 "specified size (%u). Inode is corrupt or " 319 "driver bug.", (unsigned long long)vcn, 320 idx_ni->mft_no, 321 le32_to_cpu(ia->index.allocated_size) + 0x18, 322 idx_ni->itype.index.block_size); 323 goto unm_err_out; 324 } 325 index_end = (u8*)ia + idx_ni->itype.index.block_size; | 294 ntfs_error(sb, "Out of bounds check failed. Corrupt inode " 295 "0x%lx or driver bug.", idx_ni->mft_no); 296 goto unm_err_out; 297 } 298 /* Catch multi sector transfer fixup errors. */ 299 if (unlikely(!ntfs_is_indx_record(ia->magic))) { 300 ntfs_error(sb, "Index record with vcn 0x%llx is corrupt. " 301 "Corrupt inode 0x%lx. Run chkdsk.", --- 16 unchanged lines hidden (view full) --- 318 "specified size (%u). Inode is corrupt or " 319 "driver bug.", (unsigned long long)vcn, 320 idx_ni->mft_no, 321 le32_to_cpu(ia->index.allocated_size) + 0x18, 322 idx_ni->itype.index.block_size); 323 goto unm_err_out; 324 } 325 index_end = (u8*)ia + idx_ni->itype.index.block_size; |
326 if (index_end > kaddr + PAGE_CACHE_SIZE) { | 326 if (index_end > kaddr + PAGE_SIZE) { |
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, 331 idx_ni->mft_no); 332 goto unm_err_out; 333 } 334 index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length); --- 87 unchanged lines hidden (view full) --- 422 old_vcn = vcn; 423 vcn = sle64_to_cpup((sle64*)((u8*)ie + le16_to_cpu(ie->length) - 8)); 424 if (vcn >= 0) { 425 /* 426 * If vcn is in the same page cache page as old_vcn we recycle 427 * the mapped page. 428 */ 429 if (old_vcn << vol->cluster_size_bits >> | 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, 331 idx_ni->mft_no); 332 goto unm_err_out; 333 } 334 index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length); --- 87 unchanged lines hidden (view full) --- 422 old_vcn = vcn; 423 vcn = sle64_to_cpup((sle64*)((u8*)ie + le16_to_cpu(ie->length) - 8)); 424 if (vcn >= 0) { 425 /* 426 * If vcn is in the same page cache page as old_vcn we recycle 427 * the mapped page. 428 */ 429 if (old_vcn << vol->cluster_size_bits >> |
430 PAGE_CACHE_SHIFT == vcn << | 430 PAGE_SHIFT == vcn << |
431 vol->cluster_size_bits >> | 431 vol->cluster_size_bits >> |
432 PAGE_CACHE_SHIFT) | 432 PAGE_SHIFT) |
433 goto fast_descend_into_child_node; 434 unlock_page(page); 435 ntfs_unmap_page(page); 436 goto descend_into_child_node; 437 } 438 ntfs_error(sb, "Negative child node vcn in inode 0x%lx.", 439 idx_ni->mft_no); 440unm_err_out: --- 14 unchanged lines hidden --- | 433 goto fast_descend_into_child_node; 434 unlock_page(page); 435 ntfs_unmap_page(page); 436 goto descend_into_child_node; 437 } 438 ntfs_error(sb, "Negative child node vcn in inode 0x%lx.", 439 idx_ni->mft_no); 440unm_err_out: --- 14 unchanged lines hidden --- |