Changeset e63ce679 in mainline for uspace/lib/ext4/libext4_directory_index.c
- Timestamp:
- 2012-03-03T20:06:31Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e8d054a
- Parents:
- 7689590
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_directory_index.c
r7689590 re63ce679 353 353 // Hardcoded number 2 means maximum height of index tree !!! 354 354 ext4_directory_dx_block_t dx_blocks[2]; 355 ext4_directory_dx_block_t *dx_block ;355 ext4_directory_dx_block_t *dx_block, *tmp; 356 356 rc = ext4_directory_dx_get_leaf(&hinfo, fs, inode_ref->inode, root_block, &dx_block, dx_blocks); 357 357 if (rc != EOK) { … … 367 367 rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, leaf_block_idx, &leaf_block_addr); 368 368 if (rc != EOK) { 369 return EXT4_ERR_BAD_DX_DIR;369 goto cleanup; 370 370 } 371 371 … … 373 373 rc = block_get(&leaf_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE); 374 374 if (rc != EOK) { 375 return EXT4_ERR_BAD_DX_DIR;375 goto cleanup; 376 376 } 377 377 378 378 ext4_directory_entry_ll_t *res_dentry; 379 379 rc = ext4_directory_find_in_block(leaf_block, fs->superblock, name_len, name, &res_dentry); 380 381 380 382 381 // Found => return it … … 387 386 } 388 387 388 // Not found, leave untouched 389 389 block_put(leaf_block); 390 390 391 // ERROR - corrupted index 392 if (rc == -1) { 393 // TODO cleanup 394 return EXT4_ERR_BAD_DX_DIR; 391 if (rc != ENOENT) { 392 goto cleanup; 395 393 } 396 394 397 395 rc = ext4_directory_dx_next_block(fs, inode_ref->inode, hinfo.hash, dx_block, &dx_blocks[0]); 398 396 if (rc < 0) { 399 // TODO cleanup 400 return EXT4_ERR_BAD_DX_DIR; 397 goto cleanup; 401 398 } 402 399 … … 404 401 405 402 return ENOENT; 403 404 cleanup: 405 406 tmp = dx_blocks; 407 while (tmp <= dx_block) { 408 block_put(tmp->block); 409 ++tmp; 410 } 411 return rc; 406 412 } 407 413 … … 605 611 { 606 612 int rc = EOK; 607 int rc2 ;613 int rc2 = EOK; 608 614 609 615 // get direct block 0 (index root) … … 630 636 // Hardcoded number 2 means maximum height of index tree !!! 631 637 ext4_directory_dx_block_t dx_blocks[2]; 632 ext4_directory_dx_block_t *dx_block ;638 ext4_directory_dx_block_t *dx_block, *dx_it; 633 639 rc = ext4_directory_dx_get_leaf(&hinfo, fs, parent->inode, root_block, &dx_block, dx_blocks); 634 640 if (rc != EOK) { 635 block_put(root_block);636 return EXT4_ERR_BAD_DX_DIR;641 rc = EXT4_ERR_BAD_DX_DIR; 642 goto release_index; 637 643 } 638 644 … … 643 649 rc = ext4_filesystem_get_inode_data_block_index(fs, parent->inode, leaf_block_idx, &leaf_block_addr); 644 650 if (rc != EOK) { 645 return EXT4_ERR_BAD_DX_DIR;651 goto release_index; 646 652 } 647 653 … … 650 656 rc = block_get(&target_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE); 651 657 if (rc != EOK) { 652 return EXT4_ERR_BAD_DX_DIR;658 goto release_index; 653 659 } 654 660 655 661 rc = ext4_directory_try_insert_entry(fs->superblock, target_block, child, name, name_len); 656 662 if (rc == EOK) { 657 goto cleanup; 658 663 goto release_target_index; 659 664 } 660 665 … … 679 684 if ((levels > 0) && (root_limit == root_count)) { 680 685 EXT4FS_DBG("Directory index is full"); 681 682 // ENOSPC - cleanup !!! 683 return ENOSPC; 686 rc = ENOSPC; 687 goto release_target_index; 684 688 } 685 689 … … 688 692 rc = ext4_directory_append_block(fs, parent, &new_fblock, &new_iblock); 689 693 if (rc != EOK) { 690 goto cleanup;694 goto release_target_index; 691 695 } 692 696 … … 695 699 rc = block_get(&new_block, fs->device, new_fblock, BLOCK_FLAGS_NOREAD); 696 700 if (rc != EOK) { 697 goto cleanup;701 goto release_target_index; 698 702 } 699 703 … … 772 776 rc = ext4_directory_dx_split_data(fs, parent, &hinfo, target_block, dx_block, &new_block); 773 777 if (rc != EOK) { 774 // TODO error 778 rc2 = rc; 779 goto release_target_index; 775 780 } 776 781 … … 788 793 789 794 795 // TODO check rc handling 790 796 terminate: 791 797 rc = block_put(new_block); … … 795 801 796 802 797 cleanup:803 release_target_index: 798 804 799 805 rc2 = rc; … … 804 810 } 805 811 806 ext4_directory_dx_block_t *dx_it = dx_blocks; 812 release_index: 813 dx_it = dx_blocks; 807 814 808 815 while (dx_it <= dx_block) {
Note:
See TracChangeset
for help on using the changeset viewer.