Changeset 1ac1ab4 in mainline for uspace/lib/ext4/libext4_directory.c
- Timestamp:
- 2012-03-31T20:00:15Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a2fa350
- Parents:
- 38384ae
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_directory.c
r38384ae r1ac1ab4 186 186 187 187 uint32_t next_block_phys_idx; 188 rc = ext4_filesystem_get_inode_data_block_index(it-> fs,189 it->inode_ref,next_block_idx, &next_block_phys_idx);188 rc = ext4_filesystem_get_inode_data_block_index(it->inode_ref, 189 next_block_idx, &next_block_phys_idx); 190 190 if (rc != EOK) { 191 191 return rc; … … 260 260 } 261 261 262 int ext4_directory_append_block(ext4_ filesystem_t *fs,263 ext4_inode_ref_t *inode_ref,uint32_t *fblock, uint32_t *iblock)262 int ext4_directory_append_block(ext4_inode_ref_t *inode_ref, 263 uint32_t *fblock, uint32_t *iblock) 264 264 { 265 265 int rc; 266 266 267 ext4_superblock_t *sb = inode_ref->fs->superblock; 268 267 269 // Compute next block index and allocate data block 268 uint64_t inode_size = ext4_inode_get_size( fs->superblock, inode_ref->inode);269 uint32_t block_size = ext4_superblock_get_block_size( fs->superblock);270 uint64_t inode_size = ext4_inode_get_size(sb, inode_ref->inode); 271 uint32_t block_size = ext4_superblock_get_block_size(sb); 270 272 271 273 assert(inode_size % block_size == 0); … … 275 277 276 278 uint32_t phys_block; 277 rc = ext4_balloc_alloc_block( fs,inode_ref, &phys_block);279 rc = ext4_balloc_alloc_block(inode_ref, &phys_block); 278 280 if (rc != EOK) { 279 281 return rc; 280 282 } 281 283 282 rc = ext4_filesystem_set_inode_data_block_index( fs,inode_ref, new_block_idx, phys_block);284 rc = ext4_filesystem_set_inode_data_block_index(inode_ref, new_block_idx, phys_block); 283 285 if (rc != EOK) { 284 ext4_balloc_free_block( fs,inode_ref, phys_block);286 ext4_balloc_free_block(inode_ref, phys_block); 285 287 return rc; 286 288 } … … 313 315 } 314 316 315 int ext4_directory_add_entry(ext4_ filesystem_t *fs, ext4_inode_ref_t * parent,317 int ext4_directory_add_entry(ext4_inode_ref_t * parent, 316 318 const char *name, ext4_inode_ref_t *child) 317 319 { … … 319 321 320 322 EXT4FS_DBG("adding entry to directory \%u [ino = \%u, name = \%s]", parent->index, child->index, name); 323 324 ext4_filesystem_t *fs = parent->fs; 321 325 322 326 // Index adding (if allowed) … … 324 328 ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX)) { 325 329 326 rc = ext4_directory_dx_add_entry( fs,parent, child, name);330 rc = ext4_directory_dx_add_entry(parent, child, name); 327 331 328 332 // Check if index is not corrupted … … 356 360 for (iblock = 0; iblock < total_blocks; ++iblock) { 357 361 358 rc = ext4_filesystem_get_inode_data_block_index( fs,parent, iblock, &fblock);362 rc = ext4_filesystem_get_inode_data_block_index(parent, iblock, &fblock); 359 363 if (rc != EOK) { 360 364 return rc; … … 384 388 // No free block found - needed to allocate next block 385 389 386 rc = ext4_directory_append_block( fs,parent, &fblock, &iblock);390 rc = ext4_directory_append_block(parent, &fblock, &iblock); 387 391 if (rc != EOK) { 388 392 return rc; … … 411 415 } 412 416 413 int ext4_directory_find_entry(ext4_filesystem_t *fs, 414 ext4_directory_search_result_t *result, ext4_inode_ref_t *parent, 415 const char *name) 417 int ext4_directory_find_entry(ext4_directory_search_result_t *result, 418 ext4_inode_ref_t *parent, const char *name) 416 419 { 417 420 int rc; 418 421 uint32_t name_len = strlen(name); 419 422 423 ext4_superblock_t *sb = parent->fs->superblock; 424 420 425 // Index search 421 if (ext4_superblock_has_feature_compatible( fs->superblock, EXT4_FEATURE_COMPAT_DIR_INDEX) &&426 if (ext4_superblock_has_feature_compatible(sb, EXT4_FEATURE_COMPAT_DIR_INDEX) && 422 427 ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX)) { 423 428 424 rc = ext4_directory_dx_find_entry(result, fs,parent, name_len, name);429 rc = ext4_directory_dx_find_entry(result, parent, name_len, name); 425 430 426 431 // Check if index is not corrupted … … 437 442 438 443 uint32_t iblock, fblock; 439 uint32_t block_size = ext4_superblock_get_block_size( fs->superblock);440 uint32_t inode_size = ext4_inode_get_size( fs->superblock, parent->inode);444 uint32_t block_size = ext4_superblock_get_block_size(sb); 445 uint32_t inode_size = ext4_inode_get_size(sb, parent->inode); 441 446 uint32_t total_blocks = inode_size / block_size; 442 447 443 448 for (iblock = 0; iblock < total_blocks; ++iblock) { 444 449 445 rc = ext4_filesystem_get_inode_data_block_index( fs,parent, iblock, &fblock);450 rc = ext4_filesystem_get_inode_data_block_index(parent, iblock, &fblock); 446 451 if (rc != EOK) { 447 452 return rc; … … 449 454 450 455 block_t *block; 451 rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);456 rc = block_get(&block, parent->fs->device, fblock, BLOCK_FLAGS_NONE); 452 457 if (rc != EOK) { 453 458 return rc; … … 456 461 // find block entry 457 462 ext4_directory_entry_ll_t *res_entry; 458 rc = ext4_directory_find_in_block(block, fs->superblock, name_len, name, &res_entry);463 rc = ext4_directory_find_in_block(block, sb, name_len, name, &res_entry); 459 464 if (rc == EOK) { 460 465 result->block = block; … … 476 481 477 482 478 int ext4_directory_remove_entry(ext4_filesystem_t* fs, 479 ext4_inode_ref_t *parent, const char *name) 483 int ext4_directory_remove_entry(ext4_inode_ref_t *parent, const char *name) 480 484 { 481 485 int rc; 482 486 483 if (!ext4_inode_is_type( fs->superblock, parent->inode,487 if (!ext4_inode_is_type(parent->fs->superblock, parent->inode, 484 488 EXT4_INODE_MODE_DIRECTORY)) { 485 489 return ENOTDIR; … … 487 491 488 492 ext4_directory_search_result_t result; 489 rc = ext4_directory_find_entry( fs,&result, parent, name);493 rc = ext4_directory_find_entry(&result, parent, name); 490 494 if (rc != EOK) { 491 495 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.