Changeset e68c834 in mainline for uspace/lib/ext4/libext4_filesystem.c


Ignore:
Timestamp:
2011-10-10T06:48:16Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7a68fe5
Parents:
1114173
Message:

More functions ported from ext2

File:
1 edited

Legend:

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

    r1114173 re68c834  
    4141#include "libext4.h"
    4242
    43 /**
    44  * TODO doxy
    45  */
    4643int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id)
    4744{
     
    8683}
    8784
    88 /**
    89  * TODO doxy
    90  */
    9185void ext4_filesystem_fini(ext4_filesystem_t *fs)
    9286{
     
    9589}
    9690
    97 /**
    98  * TODO doxy
    99  */
    10091int ext4_filesystem_check_sanity(ext4_filesystem_t *fs)
    10192{
     
    110101}
    111102
    112 /**
    113  * TODO doxy
    114  */
    115103int ext4_filesystem_check_features(ext4_filesystem_t *fs, bool *o_read_only)
    116104{
     
    139127}
    140128
    141 /**
    142  * TODO doxy
    143  */
    144129int ext4_filesystem_get_block_group_ref(ext4_filesystem_t *fs, uint32_t bgid,
    145130    ext4_block_group_ref_t **ref)
    146131{
    147         EXT4FS_DBG("");
    148 
    149132        int rc;
    150133        aoff64_t block_id;
     
    164147        block_id = ext4_superblock_get_first_data_block(fs->superblock) + 1;
    165148
    166         EXT4FS_DBG("block_size = \%d", ext4_superblock_get_block_size(fs->superblock));
    167         EXT4FS_DBG("descriptors_per_block = \%d", descriptors_per_block);
    168         EXT4FS_DBG("bgid = \%d", bgid);
    169         EXT4FS_DBG("first_data_block: \%d", (uint32_t)block_id);
    170 
    171149        /* Find the block containing the descriptor we are looking for */
    172150        block_id += bgid / descriptors_per_block;
    173151        offset = (bgid % descriptors_per_block) * EXT4_BLOCK_GROUP_DESCRIPTOR_SIZE;
    174152
    175         EXT4FS_DBG("updated block_id: \%d", (uint32_t)block_id);
    176 
    177153        rc = block_get(&newref->block, fs->device, block_id, 0);
    178154        if (rc != EOK) {
    179 
    180                 EXT4FS_DBG("block_get error: \%d", rc);
    181 
    182155                free(newref);
    183156                return rc;
    184157        }
    185158
    186         EXT4FS_DBG("block read");
    187 
    188159        newref->block_group = newref->block->data + offset;
    189160
    190161        *ref = newref;
    191162
    192         EXT4FS_DBG("finished");
    193 
    194         return EOK;
    195 }
    196 
    197 /**
    198  * TODO doxy
    199  */
     163        return EOK;
     164}
     165
    200166int ext4_filesystem_get_inode_ref(ext4_filesystem_t *fs, uint32_t index,
    201167    ext4_inode_ref_t **ref)
    202168{
    203         EXT4FS_DBG("");
    204 
    205169        int rc;
    206170        aoff64_t block_id;
     
    221185        }
    222186
    223         EXT4FS_DBG("allocated");
    224 
    225187        inodes_per_group = ext4_superblock_get_inodes_per_group(fs->superblock);
    226 
    227         EXT4FS_DBG("inodes_per_group_loaded");
    228188
    229189        /* inode numbers are 1-based, but it is simpler to work with 0-based
     
    234194        offset_in_group = index % inodes_per_group;
    235195
    236         EXT4FS_DBG("index: \%d", index);
    237         EXT4FS_DBG("inodes_per_group: \%d", inodes_per_group);
    238         EXT4FS_DBG("bg_id: \%d", block_group);
    239 
    240196        rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);
    241197        if (rc != EOK) {
     
    243199                return rc;
    244200        }
    245 
    246         EXT4FS_DBG("block_group_ref loaded");
    247201
    248202        inode_table_start = ext4_block_group_get_inode_table_first_block(
    249203            bg_ref->block_group);
    250204
    251         EXT4FS_DBG("inode_table block loaded");
    252 
    253205        inode_size = ext4_superblock_get_inode_size(fs->superblock);
    254206        block_size = ext4_superblock_get_block_size(fs->superblock);
     
    259211        offset_in_block = byte_offset_in_group % block_size;
    260212
    261         EXT4FS_DBG("superblock info loaded");
    262 
    263213        rc = block_get(&newref->block, fs->device, block_id, 0);
    264214        if (rc != EOK) {
     
    266216                return rc;
    267217        }
    268 
    269         EXT4FS_DBG("block got");
    270218
    271219        newref->inode = newref->block->data + offset_in_block;
     
    277225        *ref = newref;
    278226
    279         EXT4FS_DBG("finished");
    280 
    281         return EOK;
    282 }
     227        return EOK;
     228}
     229
    283230
    284231int ext4_filesystem_put_inode_ref(ext4_inode_ref_t *ref)
     
    307254
    308255        /* Handle simple case when we are dealing with direct reference */
    309         if (iblock < EXT4_INODE_DIRECT_BLOCKS) {
     256        if (iblock < EXT4_INODE_DIRECT_BLOCK_COUNT) {
    310257                current_block = ext4_inode_get_direct_block(inode, (uint32_t)iblock);
    311258                *fblock = current_block;
     
    317264         */
    318265        block_ids_per_block = ext4_superblock_get_block_size(fs->superblock) / sizeof(uint32_t);
    319         limits[0] = EXT4_INODE_DIRECT_BLOCKS;
     266        limits[0] = EXT4_INODE_DIRECT_BLOCK_COUNT;
    320267        blocks_per_level[0] = 1;
    321268        for (i = 1; i < 4; i++) {
Note: See TracChangeset for help on using the changeset viewer.