Changeset d241aae in mainline for uspace/lib/ext2/libext2_superblock.c
- Timestamp:
- 2011-02-15T19:24:38Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce13577
- Parents:
- 1d6f507
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext2/libext2_superblock.c
r1d6f507 rd241aae 260 260 * Compute count of block groups present in the filesystem 261 261 * 262 * Note: This function works only for correct filesystem, 263 * i.e. it assumes that total block count > 0 and 264 * blocks per group > 0 265 * 266 * Example: 267 * If there are 3 blocks per group, the result should be as follows: 268 * Total blocks Result 269 * 1 1 270 * 2 1 271 * 3 1 272 * 4 2 273 * 274 * 262 275 * @param sb pointer to superblock 263 276 */ 264 277 inline uint32_t ext2_superblock_get_block_group_count(ext2_superblock_t *sb) 265 278 { 266 return ext2_superblock_get_total_block_count(sb) / 267 ext2_superblock_get_blocks_per_group(sb); 279 /* We add one to the result because e.g. 2/3 = 0, while to store 280 * 2 blocks in 3-block group we need one (1) block group 281 * 282 * We subtract one first because of special case that to store e.g. 283 * 3 blocks in a 3-block group we need only one group 284 * (and 3/3 yields one - this is one more that we want as we 285 * already add one at the end) 286 */ 287 return ((ext2_superblock_get_total_block_count(sb)-1) / 288 ext2_superblock_get_blocks_per_group(sb))+1; 268 289 } 269 290
Note:
See TracChangeset
for help on using the changeset viewer.