Changeset 260c052 in mainline for uspace/lib/ext2/libext2_filesystem.c


Ignore:
Timestamp:
2011-06-02T08:01:34Z (14 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5bd1ffb
Parents:
9bd5746
Message:

coding style

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext2/libext2_filesystem.c

    r9bd5746 r260c052  
    117117int ext2_filesystem_check_flags(ext2_filesystem_t *fs, bool *o_read_only)
    118118{
    119         // feature flags are present in rev 1 and later
     119        /* feature flags are present in rev 1 and later */
    120120        if (ext2_superblock_get_rev_major(fs->superblock) == 0) {
    121121                *o_read_only = false;
    122                 return 0;
     122                return EOK;
    123123        }
    124124       
     
    129129        read_only = ext2_superblock_get_features_read_only(fs->superblock);
    130130       
    131         // unset any supported features
     131        /* check whether we support all features
     132         * first unset any supported feature flags
     133         * and see whether any unspported feature remains */
    132134        incompatible &= ~EXT2_SUPPORTED_INCOMPATIBLE_FEATURES;
    133135        read_only &= ~EXT2_SUPPORTED_READ_ONLY_FEATURES;
     
    171173            / EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE;
    172174       
    173         // Block group descriptor table starts at the next block after superblock
     175        /* Block group descriptor table starts at the next block after superblock */
    174176        block_id = ext2_superblock_get_first_block(fs->superblock) + 1;
    175177       
    176         // Find the block containing the descriptor we are looking for
     178        /* Find the block containing the descriptor we are looking for */
    177179        block_id += bgid / descriptors_per_block;
    178180        offset = (bgid % descriptors_per_block) * EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE;
     
    240242        inodes_per_group = ext2_superblock_get_inodes_per_group(fs->superblock);
    241243       
    242         // inode numbers are 1-based
     244        /* inode numbers are 1-based, but it is simpler to work with 0-based
     245         * when computing indices
     246         */
    243247        index -= 1;
    244248        block_group = index / inodes_per_group;
     
    269273       
    270274        newref->inode = newref->block->data + offset_in_block;
    271         newref->index = index+1; // we decremented index above
     275        /* we decremented index above, but need to store the original value
     276         * in the reference
     277         */
     278        newref->index = index+1;
    272279       
    273280        *ref = newref;
     
    315322        block_t *block;
    316323       
     324        /* Handle simple case when we are dealing with direct reference */
    317325        if (iblock < EXT2_INODE_DIRECT_BLOCKS) {
    318326                current_block = ext2_inode_get_direct_block(inode, (uint32_t)iblock);
     
    321329        }
    322330       
    323         // Compute limits for indirect block levels
    324         // TODO: compute this once when loading filesystem and store in ext2_filesystem_t
     331        /* Compute limits for indirect block levels
     332         * TODO: compute this once when loading filesystem and store in ext2_filesystem_t
     333         */
    325334        block_ids_per_block = ext2_superblock_get_block_size(fs->superblock) / sizeof(uint32_t);
    326335        limits[0] = EXT2_INODE_DIRECT_BLOCKS;
     
    332341        }
    333342       
    334         // Determine the indirection level needed to get the desired block
     343        /* Determine the indirection level needed to get the desired block */
    335344        level = -1;
    336345        for (i = 1; i < 4; i++) {
     
    345354        }
    346355       
     356        /* Compute offsets for the topmost level */
    347357        block_offset_in_level = iblock - limits[level-1];
    348358        current_block = ext2_inode_get_indirect_block(inode, level-1);
    349359        offset_in_block = block_offset_in_level / blocks_per_level[level-1];
    350360       
     361        /* Navigate through other levels, until we find the block number
     362         * or find null reference meaning we are dealing with sparse file
     363         */
    351364        while (level > 0) {
    352365                rc = block_get(&block, fs->device, current_block, 0);
     
    364377               
    365378                if (current_block == 0) {
     379                        /* This is a sparse file */
    366380                        *fblock = 0;
    367381                        return EOK;
     
    370384                level -= 1;
    371385               
     386                /* If we are on the last level, break here as
     387                 * there is no next level to visit
     388                 */
    372389                if (level == 0) {
    373390                        break;
    374391                }
    375392               
     393                /* Visit the next level */
    376394                block_offset_in_level %= blocks_per_level[level];
    377395                offset_in_block = block_offset_in_level / blocks_per_level[level-1];
     
    385403/**
    386404 * Allocate a given number of blocks and store their ids in blocks
     405 *
     406 * @todo TODO: This function is not finished and really has never been
     407 *             used (and tested) yet
    387408 *
    388409 * @param fs pointer to filesystem
     
    420441        idx = 0;
    421442       
    422         // Read the block group descriptor
     443        /* Read the block group descriptor */
    423444        rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg);
    424445        if (rc != EOK) {
     
    444465                }
    445466               
    446                 // We found a block group with free block, let's look at the block bitmap
     467                /* We found a block group with free block, let's look at the block bitmap */
    447468                bb_block = ext2_block_group_get_block_bitmap_block(bg->block_group);
    448469               
     
    452473                }
    453474               
    454                 // Use all blocks from this block group
     475                /* Use all blocks from this block group */
    455476                for (bb_idx = 0; bb_idx < block_size && idx < count; bb_idx++) {
    456477                        uint8_t *data = (uint8_t *) block->data;
     
    458479                                continue;
    459480                        }
    460                         // find an empty bit
     481                        /* find an empty bit */
    461482                        uint8_t mask;
    462483                        for (mask = 1, bb_bit = 0;
Note: See TracChangeset for help on using the changeset viewer.