Changeset b12ca16 in mainline for uspace/lib/ext4/libext4_superblock.c


Ignore:
Timestamp:
2011-11-18T15:30:24Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d5ba17f
Parents:
e18de3c
Message:

improved block allocator - but has some bugs

File:
1 edited

Legend:

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

    re18de3c rb12ca16  
    280280}
    281281
     282uint32_t ext4_superblock_get_block_group_count(ext4_superblock_t *sb)
     283{
     284        uint64_t blocks_count = ext4_superblock_get_blocks_count(sb);
     285        uint32_t blocks_per_group = ext4_superblock_get_blocks_per_group(sb);
     286
     287        uint32_t block_groups_count = blocks_count / blocks_per_group;
     288
     289        if (blocks_count % blocks_per_group) {
     290                block_groups_count++;
     291        }
     292
     293        return block_groups_count;
     294
     295}
     296
     297uint32_t ext4_superblock_get_blocks_in_group(ext4_superblock_t *sb, uint32_t bgid)
     298{
     299        uint32_t block_group_count = ext4_superblock_get_block_group_count(sb);
     300        uint32_t blocks_per_group = ext4_superblock_get_blocks_per_group(sb);
     301        uint64_t total_blocks = ext4_superblock_get_blocks_count(sb);
     302
     303        if (bgid < block_group_count - 1) {
     304                return blocks_per_group;
     305        } else {
     306                return (total_blocks - ((block_group_count - 1) * blocks_per_group));
     307        }
     308
     309}
     310
     311uint32_t ext4_superblock_get_inodes_in_group(ext4_superblock_t *sb, uint32_t bgid)
     312{
     313        uint32_t block_group_count = ext4_superblock_get_block_group_count(sb);
     314        uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb);
     315        uint32_t total_inodes = ext4_superblock_get_inodes_count(sb);
     316
     317        if (bgid < block_group_count - 1) {
     318                return inodes_per_group;
     319        } else {
     320                return (total_inodes - ((block_group_count - 1) * inodes_per_group));
     321        }
     322
     323}
     324
    282325/**
    283326 * @}
Note: See TracChangeset for help on using the changeset viewer.