Ignore:
File:
1 edited

Legend:

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

    r260c052 rc7faade  
    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 EOK;
     122                return 0;
    123123        }
    124124       
     
    129129        read_only = ext2_superblock_get_features_read_only(fs->superblock);
    130130       
    131         /* check whether we support all features
    132          * first unset any supported feature flags
    133          * and see whether any unspported feature remains */
     131        // unset any supported features
    134132        incompatible &= ~EXT2_SUPPORTED_INCOMPATIBLE_FEATURES;
    135133        read_only &= ~EXT2_SUPPORTED_READ_ONLY_FEATURES;
     
    173171            / EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE;
    174172       
    175         /* Block group descriptor table starts at the next block after superblock */
     173        // Block group descriptor table starts at the next block after superblock
    176174        block_id = ext2_superblock_get_first_block(fs->superblock) + 1;
    177175       
    178         /* Find the block containing the descriptor we are looking for */
     176        // Find the block containing the descriptor we are looking for
    179177        block_id += bgid / descriptors_per_block;
    180178        offset = (bgid % descriptors_per_block) * EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE;
     
    242240        inodes_per_group = ext2_superblock_get_inodes_per_group(fs->superblock);
    243241       
    244         /* inode numbers are 1-based, but it is simpler to work with 0-based
    245          * when computing indices
    246          */
     242        // inode numbers are 1-based
    247243        index -= 1;
    248244        block_group = index / inodes_per_group;
     
    273269       
    274270        newref->inode = newref->block->data + offset_in_block;
    275         /* we decremented index above, but need to store the original value
    276          * in the reference
    277          */
    278         newref->index = index+1;
     271        newref->index = index+1; // we decremented index above
    279272       
    280273        *ref = newref;
     
    322315        block_t *block;
    323316       
    324         /* Handle simple case when we are dealing with direct reference */
    325317        if (iblock < EXT2_INODE_DIRECT_BLOCKS) {
    326318                current_block = ext2_inode_get_direct_block(inode, (uint32_t)iblock);
     
    329321        }
    330322       
    331         /* Compute limits for indirect block levels
    332          * TODO: compute this once when loading filesystem and store in ext2_filesystem_t
    333          */
     323        // Compute limits for indirect block levels
     324        // TODO: compute this once when loading filesystem and store in ext2_filesystem_t
    334325        block_ids_per_block = ext2_superblock_get_block_size(fs->superblock) / sizeof(uint32_t);
    335326        limits[0] = EXT2_INODE_DIRECT_BLOCKS;
     
    341332        }
    342333       
    343         /* Determine the indirection level needed to get the desired block */
     334        // Determine the indirection level needed to get the desired block
    344335        level = -1;
    345336        for (i = 1; i < 4; i++) {
     
    354345        }
    355346       
    356         /* Compute offsets for the topmost level */
    357347        block_offset_in_level = iblock - limits[level-1];
    358348        current_block = ext2_inode_get_indirect_block(inode, level-1);
    359349        offset_in_block = block_offset_in_level / blocks_per_level[level-1];
    360350       
    361         /* Navigate through other levels, until we find the block number
    362          * or find null reference meaning we are dealing with sparse file
    363          */
    364351        while (level > 0) {
    365352                rc = block_get(&block, fs->device, current_block, 0);
     
    377364               
    378365                if (current_block == 0) {
    379                         /* This is a sparse file */
    380366                        *fblock = 0;
    381367                        return EOK;
     
    384370                level -= 1;
    385371               
    386                 /* If we are on the last level, break here as
    387                  * there is no next level to visit
    388                  */
    389372                if (level == 0) {
    390373                        break;
    391374                }
    392375               
    393                 /* Visit the next level */
    394376                block_offset_in_level %= blocks_per_level[level];
    395377                offset_in_block = block_offset_in_level / blocks_per_level[level-1];
     
    403385/**
    404386 * 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
    408387 *
    409388 * @param fs pointer to filesystem
     
    441420        idx = 0;
    442421       
    443         /* Read the block group descriptor */
     422        // Read the block group descriptor
    444423        rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg);
    445424        if (rc != EOK) {
     
    465444                }
    466445               
    467                 /* We found a block group with free block, let's look at the block bitmap */
     446                // We found a block group with free block, let's look at the block bitmap
    468447                bb_block = ext2_block_group_get_block_bitmap_block(bg->block_group);
    469448               
     
    473452                }
    474453               
    475                 /* Use all blocks from this block group */
     454                // Use all blocks from this block group
    476455                for (bb_idx = 0; bb_idx < block_size && idx < count; bb_idx++) {
    477456                        uint8_t *data = (uint8_t *) block->data;
     
    479458                                continue;
    480459                        }
    481                         /* find an empty bit */
     460                        // find an empty bit
    482461                        uint8_t mask;
    483462                        for (mask = 1, bb_bit = 0;
Note: See TracChangeset for help on using the changeset viewer.