Changeset 8be96a0 in mainline for uspace/srv/fs/ext4fs/ext4fs_ops.c


Ignore:
Timestamp:
2011-11-22T12:15:37Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bf66ef4
Parents:
f49638e
Message:

code optimalization (removed duplicity) and destroy functions implementation started

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    rf49638e r8be96a0  
    205205        ext4_directory_iterator_t it;
    206206        int rc;
    207         size_t name_size;
    208         size_t component_size;
    209         bool found = false;
    210         uint32_t inode;
    211207
    212208        fs = eparent->instance->filesystem;
     
    217213        }
    218214
    219         component_size = strlen(component);
    220 
    221         if (ext4_superblock_has_feature_compatible(fs->superblock, EXT4_FEATURE_COMPAT_DIR_INDEX) &&
    222                         ext4_inode_has_flag(eparent->inode_ref->inode, EXT4_INODE_FLAG_INDEX)) {
    223 
    224                 rc = ext4_directory_dx_find_entry(&it, fs, eparent->inode_ref, component_size, component);
    225 
    226                 // Index isn't corrupted
    227                 if (rc != EXT4_ERR_BAD_DX_DIR) {
    228 
    229                         if (rc != EOK) {
    230                                 return rc;
    231                         }
    232 
    233                         inode = ext4_directory_entry_ll_get_inode(it.current);
    234 
    235                         rc = ext4fs_node_get_core(rfn, eparent->instance, inode);
    236                         ext4_directory_iterator_fini(&it);
    237                         return rc;
    238                 }
    239 
    240         }
    241 
    242215        rc = ext4_directory_iterator_init(&it, fs, eparent->inode_ref, 0);
    243216        if (rc != EOK) {
     
    245218        }
    246219
    247         while (it.current != NULL) {
    248                 inode = ext4_directory_entry_ll_get_inode(it.current);
    249 
    250                 /* ignore empty directory entries */
    251                 if (inode != 0) {
    252                         name_size = ext4_directory_entry_ll_get_name_length(fs->superblock,
    253                                 it.current);
    254 
    255                         if (name_size == component_size && bcmp(component, &it.current->name,
    256                                     name_size) == 0) {
    257                                 rc = ext4fs_node_get_core(rfn, eparent->instance,
    258                                         inode);
    259                                 if (rc != EOK) {
    260                                         ext4_directory_iterator_fini(&it);
    261                                         return rc;
    262                                 }
    263                                 found = true;
    264                                 break;
    265                         }
    266                 }
    267 
    268                 rc = ext4_directory_iterator_next(&it);
    269                 if (rc != EOK) {
    270                         ext4_directory_iterator_fini(&it);
    271                         return rc;
    272                 }
     220        rc = ext4_directory_find_entry(&it, eparent->inode_ref, component);
     221        if (rc != EOK) {
     222                ext4_directory_iterator_fini(&it);
     223                return rc;
     224        }
     225
     226        uint32_t inode = ext4_directory_entry_ll_get_inode(it.current);
     227
     228        rc = ext4fs_node_get_core(rfn, eparent->instance, inode);
     229        if (rc != EOK) {
     230                ext4_directory_iterator_fini(&it);
     231                return rc;
    273232        }
    274233
    275234        ext4_directory_iterator_fini(&it);
    276 
    277         if (!found) {
    278                 return ENOENT;
    279         }
    280 
    281235        return EOK;
    282236}
     
    791745    ext4fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)
    792746{
    793 
    794747        ext4_directory_iterator_t it;
    795748        aoff64_t next;
     
    11511104static int ext4fs_destroy(service_id_t service_id, fs_index_t index)
    11521105{
    1153         EXT4FS_DBG("not supported");
    1154 
    1155         //TODO
    1156         return ENOTSUP;
     1106        int rc;
     1107        fs_node_t *fn;
     1108
     1109        rc = ext4fs_node_get(&fn, service_id, index);
     1110        if (rc != EOK) {
     1111                return rc;
     1112        }
     1113
     1114        /* Destroy the inode */
     1115        return ext4fs_destroy_node(fn);
    11571116}
    11581117
Note: See TracChangeset for help on using the changeset viewer.