Ignore:
Timestamp:
2012-03-03T20:06:31Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e8d054a
Parents:
7689590
Message:

Some TODOs solved (mostly in error handling)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_directory_index.c

    r7689590 re63ce679  
    353353        // Hardcoded number 2 means maximum height of index tree !!!
    354354        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;
    356356        rc = ext4_directory_dx_get_leaf(&hinfo, fs, inode_ref->inode, root_block, &dx_block, dx_blocks);
    357357        if (rc != EOK) {
     
    367367        rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, leaf_block_idx, &leaf_block_addr);
    368368        if (rc != EOK) {
    369                 return EXT4_ERR_BAD_DX_DIR;
     369                goto cleanup;
    370370        }
    371371
     
    373373                rc = block_get(&leaf_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE);
    374374                if (rc != EOK) {
    375                         return EXT4_ERR_BAD_DX_DIR;
     375                        goto cleanup;
    376376                }
    377377
    378378                ext4_directory_entry_ll_t *res_dentry;
    379379                rc = ext4_directory_find_in_block(leaf_block, fs->superblock, name_len, name, &res_dentry);
    380 
    381380
    382381                // Found => return it
     
    387386                }
    388387
     388                // Not found, leave untouched
    389389                block_put(leaf_block);
    390390
    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;
    395393                }
    396394
    397395                rc = ext4_directory_dx_next_block(fs, inode_ref->inode, hinfo.hash, dx_block, &dx_blocks[0]);
    398396                if (rc < 0) {
    399                         // TODO cleanup
    400                         return EXT4_ERR_BAD_DX_DIR;
     397                        goto cleanup;
    401398                }
    402399
     
    404401
    405402        return ENOENT;
     403
     404cleanup:
     405
     406        tmp = dx_blocks;
     407        while (tmp <= dx_block) {
     408                block_put(tmp->block);
     409                ++tmp;
     410        }
     411        return rc;
    406412}
    407413
     
    605611{
    606612        int rc = EOK;
    607         int rc2;
     613        int rc2 = EOK;
    608614
    609615        // get direct block 0 (index root)
     
    630636        // Hardcoded number 2 means maximum height of index tree !!!
    631637        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;
    633639        rc = ext4_directory_dx_get_leaf(&hinfo, fs, parent->inode, root_block, &dx_block, dx_blocks);
    634640        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;
    637643        }
    638644
     
    643649        rc = ext4_filesystem_get_inode_data_block_index(fs, parent->inode, leaf_block_idx, &leaf_block_addr);
    644650        if (rc != EOK) {
    645                 return EXT4_ERR_BAD_DX_DIR;
     651                goto release_index;
    646652        }
    647653
     
    650656        rc = block_get(&target_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE);
    651657        if (rc != EOK) {
    652                 return EXT4_ERR_BAD_DX_DIR;
     658                goto release_index;
    653659        }
    654660
    655661        rc = ext4_directory_try_insert_entry(fs->superblock, target_block, child, name, name_len);
    656662        if (rc == EOK) {
    657                 goto cleanup;
    658 
     663                goto release_target_index;
    659664        }
    660665
     
    679684                if ((levels > 0) && (root_limit == root_count)) {
    680685                        EXT4FS_DBG("Directory index is full");
    681 
    682                         // ENOSPC - cleanup !!!
    683                         return ENOSPC;
     686                        rc = ENOSPC;
     687                        goto release_target_index;
    684688                }
    685689
     
    688692                rc =  ext4_directory_append_block(fs, parent, &new_fblock, &new_iblock);
    689693                if (rc != EOK) {
    690                         goto cleanup;
     694                        goto release_target_index;
    691695                }
    692696
     
    695699                rc = block_get(&new_block, fs->device, new_fblock, BLOCK_FLAGS_NOREAD);
    696700                if (rc != EOK) {
    697                         goto cleanup;
     701                        goto release_target_index;
    698702                }
    699703
     
    772776        rc = ext4_directory_dx_split_data(fs, parent, &hinfo, target_block, dx_block, &new_block);
    773777        if (rc != EOK) {
    774                 // TODO error
     778                rc2 = rc;
     779                goto release_target_index;
    775780        }
    776781
     
    788793
    789794
     795// TODO check rc handling
    790796terminate:
    791797        rc = block_put(new_block);
     
    795801
    796802
    797 cleanup:
     803release_target_index:
    798804
    799805        rc2 = rc;
     
    804810        }
    805811
    806         ext4_directory_dx_block_t *dx_it = dx_blocks;
     812release_index:
     813        dx_it = dx_blocks;
    807814
    808815        while (dx_it <= dx_block) {
Note: See TracChangeset for help on using the changeset viewer.