Changeset e8d054a in mainline


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

very hidden bug (memory_leak) found in splitting data block - now correct (without splitting index block)

File:
1 edited

Legend:

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

    re63ce679 re8d054a  
    383383                        result->block = leaf_block;
    384384                        result->dentry = res_dentry;
    385                         return EOK;
     385                        goto cleanup;
    386386                }
    387387
     
    400400        } while (rc == 1);
    401401
    402         return ENOENT;
     402        rc = ENOENT;
    403403
    404404cleanup:
     
    464464        int rc = EOK;
    465465
     466        // Allocate buffer for directory entries
    466467        uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
    467468        void *entry_buffer = malloc(block_size);
     
    470471        }
    471472
    472         // Copy data to buffer
    473         memcpy(entry_buffer, old_data_block->data, block_size);
    474 
    475473        // dot entry has the smallest size available
    476474        uint32_t max_entry_count =  block_size / sizeof(ext4_directory_dx_dot_entry_t);
    477475
     476        // Allocate sort entry
    478477        ext4_dx_sort_entry_t *sort_array = malloc(max_entry_count * sizeof(ext4_dx_sort_entry_t));
    479478        if (sort_array == NULL) {
     
    482481        }
    483482
    484         ext4_directory_entry_ll_t *dentry = old_data_block->data;
    485 
    486483        uint32_t idx = 0;
    487484        uint32_t real_size = 0;
    488         void *entry_buffer_ptr = entry_buffer;
    489 
     485
     486        // Initialize hinfo
    490487        ext4_hash_info_t tmp_hinfo;
    491488        memcpy(&tmp_hinfo, hinfo, sizeof(ext4_hash_info_t));
    492489
     490        // Load all valid entries to the buffer
     491        ext4_directory_entry_ll_t *dentry = old_data_block->data;
     492        void *entry_buffer_ptr = entry_buffer;
    493493        while ((void *)dentry < old_data_block->data + block_size) {
    494494
    495495                // Read only valid entries
    496496                if (ext4_directory_entry_ll_get_inode(dentry) != 0) {
    497                         char *name = (char *)dentry->name;
    498497
    499498                        uint8_t len = ext4_directory_entry_ll_get_name_length(fs->superblock, dentry);
    500                         ext4_hash_string(&tmp_hinfo, len, name);
     499                        ext4_hash_string(&tmp_hinfo, len, (char *)dentry->name);
    501500
    502501                        uint32_t rec_len = 8 + len;
     
    788787        }
    789788
    790         if (rc != EOK) {
    791                 goto terminate;
    792         }
    793 
    794 
    795789// TODO check rc handling
    796 terminate:
    797790        rc = block_put(new_block);
    798791        if (rc != EOK) {
     
    807800        rc = block_put(target_block);
    808801        if (rc != EOK) {
    809                 return rc;
     802                EXT4FS_DBG("error writing target block");
     803//              return rc;
    810804        }
    811805
     
    814808
    815809        while (dx_it <= dx_block) {
     810                EXT4FS_DBG("dirty = \%s, refcount = \%u", dx_it->block->dirty ? "true" : "false", dx_it->block->refcnt);
    816811                rc = block_put(dx_it->block);
    817812                if (rc != EOK) {
    818                         return rc;
     813                        EXT4FS_DBG("error writing index block");
     814//                      return rc;
    819815                }
    820816                dx_it++;
Note: See TracChangeset for help on using the changeset viewer.