Changeset ff4f073 in mainline


Ignore:
Timestamp:
2011-06-03T22:33:13Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
547c37a, 8d6c1f1
Parents:
5c96b2a (diff), 911ee54 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge ext2 fixes from http://ho.st.dcs.fmph.uniba.sk/~mato/bzr/helenos-ext2.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/ext2info/ext2info.c

    r5c96b2a rff4f073  
    586586        ext2_directory_iterator_t it;
    587587        size_t name_size;
     588        uint32_t inode;
    588589       
    589590        printf("  Directory contents:\n");
     
    600601                printf("    ");
    601602                print_data(&it.current->name, name_size);
    602                 printf(" --> %u\n", it.current->inode);
     603               
     604                inode = ext2_directory_entry_ll_get_inode(it.current);
     605                printf(" --> %u\n", inode);
    603606               
    604607                rc = ext2_directory_iterator_next(&it);
  • uspace/lib/ext2/libext2_directory.c

    r5c96b2a rff4f073  
    4040#include <assert.h>
    4141
     42static int ext2_directory_iterator_set(ext2_directory_iterator_t *it,
     43    uint32_t block_size);
     44
    4245/**
    4346 * Get inode number for the directory entry
     
    9093        int rc;
    9194        uint32_t block_id;
     95        uint32_t block_size;
     96       
    9297        it->inode_ref = inode_ref;
    9398        it->fs = fs;
     
    105110        }
    106111       
    107         it->current = it->current_block->data;
    108         it->current_offset = 0;
    109        
    110         return EOK;
     112        block_size = ext2_superblock_get_block_size(fs->superblock);
     113       
     114        it->current_offset = 0;
     115        return ext2_directory_iterator_set(it, block_size);
    111116}
    112117
     
    126131        uint32_t next_block_phys_idx;
    127132        uint32_t block_size;
    128         uint32_t offset_in_block;
    129133       
    130134        assert(it->current != NULL);
     
    175179        }
    176180       
    177         offset_in_block = (it->current_offset + skip) % block_size;
     181        it->current_offset += skip;
     182        return ext2_directory_iterator_set(it, block_size);
     183}
     184
     185static int ext2_directory_iterator_set(ext2_directory_iterator_t *it,
     186    uint32_t block_size)
     187{
     188        uint32_t offset_in_block = it->current_offset % block_size;
     189       
     190        it->current = NULL;
    178191       
    179192        /* Ensure proper alignment */
    180193        if ((offset_in_block % 4) != 0) {
    181                 it->current = NULL;
    182194                return EIO;
    183195        }
     
    185197        /* Ensure that the core of the entry does not overflow the block */
    186198        if (offset_in_block > block_size - 8) {
    187                 it->current = NULL;
    188                 return EIO;
    189         }
    190                
    191         it->current = it->current_block->data + offset_in_block;
    192         it->current_offset += skip;
     199                return EIO;
     200        }
     201       
     202        ext2_directory_entry_ll_t *entry = it->current_block->data + offset_in_block;
    193203       
    194204        /* Ensure that the whole entry does not overflow the block */
    195         skip = ext2_directory_entry_ll_get_entry_length(it->current);
    196         if (offset_in_block + skip > block_size) {
    197                 it->current = NULL;
     205        uint16_t length = ext2_directory_entry_ll_get_entry_length(entry);
     206        if (offset_in_block + length > block_size) {
    198207                return EIO;
    199208        }
     
    201210        /* Ensure the name length is not too large */
    202211        if (ext2_directory_entry_ll_get_name_length(it->fs->superblock,
    203             it->current) > skip-8) {
    204                 it->current = NULL;
    205                 return EIO;
    206         }
    207        
     212            entry) > length-8) {
     213                return EIO;
     214        }
     215       
     216        it->current = entry;
    208217        return EOK;
    209218}
  • uspace/lib/ext2/libext2_filesystem.c

    r5c96b2a rff4f073  
    4242#include <malloc.h>
    4343#include <assert.h>
     44#include <byteorder.h>
    4445
    4546/**
     
    369370               
    370371                assert(offset_in_block < block_ids_per_block);
    371                 current_block = ((uint32_t*)block->data)[offset_in_block];
     372                current_block = uint32_t_le2host(((uint32_t*)block->data)[offset_in_block]);
    372373               
    373374                rc = block_put(block);
  • uspace/lib/ext2/libext2_superblock.c

    r5c96b2a rff4f073  
    184184                return EXT2_REV0_INODE_SIZE;
    185185        }
    186         return uint32_t_le2host(sb->inode_size);
     186        return uint16_t_le2host(sb->inode_size);
    187187}
    188188
  • uspace/srv/fs/ext2fs/ext2fs_ops.c

    r5c96b2a rff4f073  
    232232        size_t component_size;
    233233        bool found = false;
     234        uint32_t inode;
    234235       
    235236        fs = eparent->instance->filesystem;
     
    254255       
    255256        while (it.current != NULL) {
     257                inode = ext2_directory_entry_ll_get_inode(it.current);
     258               
    256259                /* ignore empty directory entries */
    257                 if (it.current->inode != 0) {
     260                if (inode != 0) {
    258261                        name_size = ext2_directory_entry_ll_get_name_length(fs->superblock,
    259262                                it.current);
     
    262265                                    name_size) == 0) {
    263266                                rc = ext2fs_node_get_core(rfn, eparent->instance,
    264                                         it.current->inode);
     267                                        inode);
    265268                                if (rc != EOK) {
    266269                                        ext2_directory_iterator_fini(&it);
Note: See TracChangeset for help on using the changeset viewer.