Changeset 418f21d in mainline for uspace/lib/ext4/libext4_balloc.c
- Timestamp:
- 2015-04-26T21:02:32Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5cc1853
- Parents:
- 60c409c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_balloc.c
r60c409c r418f21d 39 39 #include "libext4.h" 40 40 41 /** Compute number of block group from block address.42 *43 * @param sb Superblock pointer.44 * @param block_addr Absolute address of block.45 *46 * @return Block group index47 *48 */49 static uint32_t ext4_balloc_get_bgid_of_block(ext4_superblock_t *sb,50 uint32_t block_addr)51 {52 uint32_t blocks_per_group =53 ext4_superblock_get_blocks_per_group(sb);54 uint32_t first_block =55 ext4_superblock_get_first_data_block(sb);56 57 /* First block == 0 or 1 */58 if (first_block == 0)59 return block_addr / blocks_per_group;60 else61 return (block_addr - 1) / blocks_per_group;62 }63 64 41 /** Free block. 65 42 * … … 76 53 77 54 /* Compute indexes */ 78 uint32_t block_group = ext4_ balloc_get_bgid_of_block(sb, block_addr);55 uint32_t block_group = ext4_filesystem_blockaddr2group(sb, block_addr); 79 56 uint32_t index_in_group = 80 57 ext4_filesystem_blockaddr2_index_in_group(sb, block_addr); … … 142 119 143 120 /* Compute indexes */ 144 uint32_t block_group_first = 145 ext4_balloc_get_bgid_of_block(sb,first);146 uint32_t block_group_last = 147 ext4_balloc_get_bgid_of_block(sb,first + count - 1);121 uint32_t block_group_first = ext4_filesystem_blockaddr2group(sb, 122 first); 123 uint32_t block_group_last = ext4_filesystem_blockaddr2group(sb, 124 first + count - 1); 148 125 149 126 assert(block_group_first == block_group_last); … … 410 387 411 388 /* Load block group number for goal and relative index */ 412 uint32_t block_group = ext4_ balloc_get_bgid_of_block(sb, goal);389 uint32_t block_group = ext4_filesystem_blockaddr2group(sb, goal); 413 390 uint32_t index_in_group = 414 391 ext4_filesystem_blockaddr2_index_in_group(sb, goal); … … 683 660 684 661 /* Compute indexes */ 685 uint32_t block_group = ext4_ balloc_get_bgid_of_block(sb, fblock);662 uint32_t block_group = ext4_filesystem_blockaddr2group(sb, fblock); 686 663 uint32_t index_in_group = 687 664 ext4_filesystem_blockaddr2_index_in_group(sb, fblock);
Note:
See TracChangeset
for help on using the changeset viewer.