Changeset ca3d77a in mainline
- Timestamp:
- 2012-01-28T10:51:56Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7c506ced
- Parents:
- fe56c08a
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_directory.c
rfe56c08a rca3d77a 263 263 const char *entry_name, ext4_inode_ref_t *child) 264 264 { 265 EXT4FS_DBG("adding dentry \%s to child inode \%u to directory \%u", entry_name, child->index, inode_ref->index);266 267 265 int rc; 268 266 … … 281 279 uint32_t entry_inode = ext4_directory_entry_ll_get_inode(it.current); 282 280 uint16_t rec_len = ext4_directory_entry_ll_get_entry_length(it.current); 283 284 EXT4FS_DBG("inode = \%u, rec_len == \%u, required_len = \%u", entry_inode, rec_len, required_len);285 281 286 282 if ((entry_inode == 0) && (rec_len >= required_len)) { … … 377 373 } 378 374 375 // Fill block with zeroes 376 memset(new_block->data, 0, block_size); 377 379 378 ext4_directory_entry_ll_t *block_entry = new_block->data; 380 379 -
uspace/lib/ext4/libext4_filesystem.c
rfe56c08a rca3d77a 284 284 285 285 // TODO extents, dir_index etc... 286 286 287 rc = ext4_filesystem_get_inode_ref(fs, index, inode_ref); 287 288 if (rc != EOK) { … … 325 326 int rc; 326 327 327 // release all indirect blocks328 // release all indirect (no data) blocks 328 329 329 330 // 1) Single indirect … … 332 333 rc = ext4_balloc_free_block(fs, inode_ref, fblock); 333 334 if (rc != EOK) { 334 // TODO error335 return rc; 335 336 } 336 337 … … 443 444 ext4_inode_ref_t *inode_ref, aoff64_t new_size) 444 445 { 446 int rc; 447 445 448 if (! ext4_inode_can_truncate(fs->superblock, inode_ref->inode)) { 446 449 // Unable to truncate … … 454 457 } 455 458 459 // It's not suppported to make the larger file 456 460 if (old_size < new_size) { 457 // Currently not supported to expand the file458 // TODO459 EXT4FS_DBG("trying to expand the file");460 461 return EINVAL; 461 462 } … … 463 464 aoff64_t size_diff = old_size - new_size; 464 465 uint32_t block_size = ext4_superblock_get_block_size(fs->superblock); 465 uint32_t blocks_count = size_diff / block_size;466 uint32_t diff_blocks_count = size_diff / block_size; 466 467 if (size_diff % block_size != 0) { 467 blocks_count++;468 } 469 470 uint32_t total_blocks= old_size / block_size;468 diff_blocks_count++; 469 } 470 471 uint32_t old_blocks_count = old_size / block_size; 471 472 if (old_size % block_size != 0) { 472 total_blocks++;473 old_blocks_count++; 473 474 } 474 475 475 476 // starting from 1 because of logical blocks are numbered from 0 476 for (uint32_t i = 1; i <= blocks_count; ++i) { 477 // TODO check retval 478 ext4_filesystem_release_inode_block(fs, inode_ref, total_blocks - i); 477 for (uint32_t i = 1; i <= diff_blocks_count; ++i) { 478 rc = ext4_filesystem_release_inode_block(fs, inode_ref, old_blocks_count - i); 479 if (rc != EOK) { 480 return rc; 481 } 479 482 } 480 483 -
uspace/srv/fs/ext4fs/ext4fs_ops.c
rfe56c08a rca3d77a 373 373 int ext4fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags) 374 374 { 375 EXT4FS_DBG("");376 375 int rc; 377 376 … … 405 404 } 406 405 407 EXT4FS_DBG("allocated");408 409 406 enode->inode_ref = inode_ref; 410 407 enode->instance = inst; … … 430 427 *rfn = fs_node; 431 428 432 EXT4FS_DBG("finished");433 434 // TODO435 429 return EOK; 436 430 } … … 439 433 int ext4fs_destroy_node(fs_node_t *fn) 440 434 { 441 EXT4FS_DBG("");442 435 int rc; 443 436 … … 450 443 451 444 if (has_children) { 452 EXT4FS_DBG("destroying non-empty node");453 445 ext4fs_node_put(fn); 454 446 return EINVAL; … … 489 481 int ext4fs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name) 490 482 { 491 EXT4FS_DBG("");492 493 483 int rc; 494 484 … … 497 487 return ENAMETOOLONG; 498 488 } 499 500 EXT4FS_DBG("name checked");501 502 489 ext4fs_node_t *parent = EXT4FS_NODE(pfn); 503 490 ext4fs_node_t *child = EXT4FS_NODE(cfn); … … 509 496 return rc; 510 497 } 511 512 EXT4FS_DBG("dentry added");513 498 514 499 // Fill new dir -> add '.' and '..' entries … … 520 505 return rc; 521 506 } 522 523 EXT4FS_DBG("added dot");524 507 525 508 rc = ext4_directory_add_entry(fs, child->inode_ref, "..", parent->inode_ref); … … 530 513 } 531 514 532 EXT4FS_DBG("added dotdot");533 534 515 uint16_t parent_links = ext4_inode_get_links_count(parent->inode_ref->inode); 535 516 parent_links++; … … 552 533 int ext4fs_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name) 553 534 { 554 // EXT4FS_DBG("unlinking \%s", name);555 556 535 int rc; 557 536 … … 559 538 rc = ext4fs_has_children(&has_children, cfn); 560 539 if (rc != EOK) { 561 EXT4FS_DBG("\%s error: \%u", name, rc);562 540 return rc; 563 541 } … … 573 551 rc = ext4_directory_remove_entry(fs, parent, name); 574 552 if (rc != EOK) { 575 EXT4FS_DBG("\%s removing entry failed: \%u", name, rc);576 553 return rc; 577 554 } … … 1086 1063 rc = ext4fs_node_get(&fn, service_id, index); 1087 1064 if (rc != EOK) { 1088 EXT4FS_DBG("node get error");1089 1065 return rc; 1090 1066 } … … 1096 1072 ext4fs_node_put(fn); 1097 1073 async_answer_0(callid, rc); 1098 EXT4FS_DBG("data write recv");1099 1074 return rc; 1100 1075 } … … 1136 1111 rc = ext4_filesystem_set_inode_data_block_index(fs, inode_ref, iblock, fblock); 1137 1112 if (rc != EOK) { 1138 EXT4FS_DBG("ERROR: setting index failed"); 1113 ext4_balloc_free_block(fs, inode_ref, fblock); 1114 ext4fs_node_put(fn); 1115 async_answer_0(callid, rc); 1116 return rc; 1139 1117 } 1140 1118 inode_ref->dirty = true;
Note:
See TracChangeset
for help on using the changeset viewer.