Changes in uspace/lib/ext2/libext2_filesystem.c [260c052:c7faade] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext2/libext2_filesystem.c
r260c052 rc7faade 117 117 int ext2_filesystem_check_flags(ext2_filesystem_t *fs, bool *o_read_only) 118 118 { 119 / * feature flags are present in rev 1 and later */119 // feature flags are present in rev 1 and later 120 120 if (ext2_superblock_get_rev_major(fs->superblock) == 0) { 121 121 *o_read_only = false; 122 return EOK;122 return 0; 123 123 } 124 124 … … 129 129 read_only = ext2_superblock_get_features_read_only(fs->superblock); 130 130 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 134 132 incompatible &= ~EXT2_SUPPORTED_INCOMPATIBLE_FEATURES; 135 133 read_only &= ~EXT2_SUPPORTED_READ_ONLY_FEATURES; … … 173 171 / EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE; 174 172 175 / * Block group descriptor table starts at the next block after superblock */173 // Block group descriptor table starts at the next block after superblock 176 174 block_id = ext2_superblock_get_first_block(fs->superblock) + 1; 177 175 178 / * Find the block containing the descriptor we are looking for */176 // Find the block containing the descriptor we are looking for 179 177 block_id += bgid / descriptors_per_block; 180 178 offset = (bgid % descriptors_per_block) * EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE; … … 242 240 inodes_per_group = ext2_superblock_get_inodes_per_group(fs->superblock); 243 241 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 247 243 index -= 1; 248 244 block_group = index / inodes_per_group; … … 273 269 274 270 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 279 272 280 273 *ref = newref; … … 322 315 block_t *block; 323 316 324 /* Handle simple case when we are dealing with direct reference */325 317 if (iblock < EXT2_INODE_DIRECT_BLOCKS) { 326 318 current_block = ext2_inode_get_direct_block(inode, (uint32_t)iblock); … … 329 321 } 330 322 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 334 325 block_ids_per_block = ext2_superblock_get_block_size(fs->superblock) / sizeof(uint32_t); 335 326 limits[0] = EXT2_INODE_DIRECT_BLOCKS; … … 341 332 } 342 333 343 / * Determine the indirection level needed to get the desired block */334 // Determine the indirection level needed to get the desired block 344 335 level = -1; 345 336 for (i = 1; i < 4; i++) { … … 354 345 } 355 346 356 /* Compute offsets for the topmost level */357 347 block_offset_in_level = iblock - limits[level-1]; 358 348 current_block = ext2_inode_get_indirect_block(inode, level-1); 359 349 offset_in_block = block_offset_in_level / blocks_per_level[level-1]; 360 350 361 /* Navigate through other levels, until we find the block number362 * or find null reference meaning we are dealing with sparse file363 */364 351 while (level > 0) { 365 352 rc = block_get(&block, fs->device, current_block, 0); … … 377 364 378 365 if (current_block == 0) { 379 /* This is a sparse file */380 366 *fblock = 0; 381 367 return EOK; … … 384 370 level -= 1; 385 371 386 /* If we are on the last level, break here as387 * there is no next level to visit388 */389 372 if (level == 0) { 390 373 break; 391 374 } 392 375 393 /* Visit the next level */394 376 block_offset_in_level %= blocks_per_level[level]; 395 377 offset_in_block = block_offset_in_level / blocks_per_level[level-1]; … … 403 385 /** 404 386 * 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 been407 * used (and tested) yet408 387 * 409 388 * @param fs pointer to filesystem … … 441 420 idx = 0; 442 421 443 / * Read the block group descriptor */422 // Read the block group descriptor 444 423 rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg); 445 424 if (rc != EOK) { … … 465 444 } 466 445 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 468 447 bb_block = ext2_block_group_get_block_bitmap_block(bg->block_group); 469 448 … … 473 452 } 474 453 475 / * Use all blocks from this block group */454 // Use all blocks from this block group 476 455 for (bb_idx = 0; bb_idx < block_size && idx < count; bb_idx++) { 477 456 uint8_t *data = (uint8_t *) block->data; … … 479 458 continue; 480 459 } 481 / * find an empty bit */460 // find an empty bit 482 461 uint8_t mask; 483 462 for (mask = 1, bb_bit = 0;
Note:
See TracChangeset
for help on using the changeset viewer.