Ignore:
Timestamp:
2012-04-12T03:03:36Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1fff583
Parents:
81ee87cd
Message:

not debugged version of dir index initialization

File:
1 edited

Legend:

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

    r81ee87cd r7eb033ce  
    135135/**************************************************************************/
    136136
     137int ext4_directory_dx_init(ext4_inode_ref_t *dir)
     138{
     139        int rc;
     140
     141        uint32_t fblock;
     142        rc = ext4_filesystem_get_inode_data_block_index(dir, 0, &fblock);
     143        if (rc != EOK) {
     144                return rc;
     145        }
     146
     147        block_t *block;
     148        rc = block_get(&block, dir->fs->device, fblock, BLOCK_FLAGS_NONE);
     149        if (rc != EOK) {
     150                return rc;
     151        }
     152
     153        EXT4FS_DBG("fblock = \%u", fblock);
     154
     155        ext4_directory_dx_root_t *root = block->data;
     156
     157        ext4_directory_entry_ll_t *dot = (ext4_directory_entry_ll_t *)&root->dots[0];
     158        ext4_directory_entry_ll_t *dot_dot = (ext4_directory_entry_ll_t *)&root->dots[1];
     159
     160        EXT4FS_DBG("dot len = \%u, dotdot len = \%u", ext4_directory_entry_ll_get_entry_length(dot), ext4_directory_entry_ll_get_entry_length(dot_dot));
     161
     162//      uint32_t block_size = ext4_superblock_get_block_size(dir->fs->superblock);
     163//      uint16_t len = block_size - sizeof(ext4_directory_dx_dot_entry_t);
     164
     165//      ext4_directory_entry_ll_set_entry_length(dot_dot, len);
     166
     167        ext4_directory_dx_root_info_t *info = &(root->info);
     168
     169        uint8_t hash_version =
     170                        ext4_superblock_get_default_hash_version(dir->fs->superblock);
     171
     172        ext4_directory_dx_root_info_set_hash_version(info, hash_version);
     173        ext4_directory_dx_root_info_set_indirect_levels(info, 0);
     174        ext4_directory_dx_root_info_set_info_length(info, 8);
     175
     176        ext4_directory_dx_countlimit_t *countlimit =
     177                        (ext4_directory_dx_countlimit_t *)&root->entries;
     178        ext4_directory_dx_countlimit_set_count(countlimit, 1);
     179
     180        uint32_t block_size = ext4_superblock_get_block_size(dir->fs->superblock);
     181        uint32_t entry_space = block_size - 2 * sizeof(ext4_directory_dx_dot_entry_t)
     182                - sizeof(ext4_directory_dx_root_info_t);
     183        uint16_t root_limit = entry_space / sizeof(ext4_directory_dx_entry_t);
     184        ext4_directory_dx_countlimit_set_limit(countlimit, root_limit);
     185
     186        uint32_t iblock;
     187        rc = ext4_filesystem_append_inode_block(dir, &fblock, &iblock);
     188        if (rc != EOK) {
     189                block_put(block);
     190                return rc;
     191        }
     192
     193        block_t *new_block;
     194        rc = block_get(&new_block, dir->fs->device, fblock, BLOCK_FLAGS_NOREAD);
     195        if (rc != EOK) {
     196                block_put(block);
     197                return rc;
     198        }
     199
     200        ext4_directory_entry_ll_t *block_entry = new_block->data;
     201        ext4_directory_entry_ll_set_entry_length(block_entry, block_size);
     202        ext4_directory_entry_ll_set_inode(block_entry, 0);
     203
     204        new_block->dirty = true;
     205        rc = block_put(new_block);
     206        if (rc != EOK) {
     207                block_put(block);
     208                return rc;
     209        }
     210
     211        ext4_directory_dx_entry_t *entry = root->entries;
     212        ext4_directory_dx_entry_set_block(entry, iblock);
     213
     214        block->dirty = true;
     215
     216        rc = block_put(block);
     217        if (rc != EOK) {
     218                return rc;
     219        }
     220
     221        return EOK;
     222}
    137223
    138224static int ext4_directory_hinfo_init(ext4_hash_info_t *hinfo, block_t *root_block,
     
    771857        if (rc != EOK) {
    772858                block_put(root_block);
     859                EXT4FS_DBG("hinfo initialization error");
    773860                return EXT4_ERR_BAD_DX_DIR;
    774861        }
     
    779866        rc = ext4_directory_dx_get_leaf(&hinfo, parent, root_block, &dx_block, dx_blocks);
    780867        if (rc != EOK) {
     868                EXT4FS_DBG("get leaf error");
    781869                rc = EXT4_ERR_BAD_DX_DIR;
    782870                goto release_index;
Note: See TracChangeset for help on using the changeset viewer.