Changeset 06d85e5 in mainline for uspace/srv/fs/ext4fs/ext4fs_ops.c
- Timestamp:
- 2012-06-18T11:09:34Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2616a75b
- Parents:
- 9a487cc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/ext4fs/ext4fs_ops.c
r9a487cc r06d85e5 76 76 } ext4fs_node_t; 77 77 78 / / Forward declarations of auxiliary functions78 /* Forward declarations of auxiliary functions */ 79 79 80 80 static int ext4fs_read_directory(ipc_callid_t, aoff64_t, size_t, … … 87 87 static int ext4fs_node_put_core(ext4fs_node_t *); 88 88 89 / / Forward declarations of EXT4 libfs operations.89 /* Forward declarations of EXT4 libfs operations. */ 90 90 91 91 static int ext4fs_root_get(fs_node_t **, service_id_t); … … 106 106 static service_id_t ext4fs_service_get(fs_node_t *node); 107 107 108 / / Static variables108 /* Static variables */ 109 109 110 110 static LIST_INITIALIZE(instance_list); … … 250 250 } 251 251 252 / / Try to find entry252 /* Try to find entry */ 253 253 ext4_directory_search_result_t result; 254 254 rc = ext4_directory_find_entry(&result, eparent->inode_ref, component); … … 261 261 } 262 262 263 / / Load node from search result263 /* Load node from search result */ 264 264 uint32_t inode = ext4_directory_entry_ll_get_inode(result.dentry); 265 265 rc = ext4fs_node_get_core(rfn, eparent->instance, inode); … … 268 268 } 269 269 270 / / Destroy search result structure270 /* Destroy search result structure */ 271 271 rc = ext4_directory_destroy_result(&result); 272 272 if (rc != EOK) { … … 330 330 } 331 331 332 / / Prepare new enode332 /* Prepare new enode */ 333 333 enode = malloc(sizeof(ext4fs_node_t)); 334 334 if (enode == NULL) { … … 337 337 } 338 338 339 / / Prepare new fs_node and initialize339 /* Prepare new fs_node and initialize */ 340 340 fs_node_t *fs_node = malloc(sizeof(fs_node_t)); 341 341 if (fs_node == NULL) { … … 346 346 fs_node_initialize(fs_node); 347 347 348 / / Load i-node from filesystem348 /* Load i-node from filesystem */ 349 349 ext4_inode_ref_t *inode_ref; 350 350 rc = ext4_filesystem_get_inode_ref(inst->filesystem, index, &inode_ref); … … 356 356 } 357 357 358 / / Initialize enode358 /* Initialize enode */ 359 359 enode->inode_ref = inode_ref; 360 360 enode->instance = inst; … … 391 391 enode->instance->open_nodes_count--; 392 392 393 / / Put inode back in filesystem393 /* Put inode back in filesystem */ 394 394 rc = ext4_filesystem_put_inode_ref(enode->inode_ref); 395 395 if (rc != EOK) { … … 397 397 } 398 398 399 / / Destroy data structure399 /* Destroy data structure */ 400 400 free(enode->fs_node); 401 401 free(enode); … … 414 414 int ext4fs_node_open(fs_node_t *fn) 415 415 { 416 / / Stateless operation416 /* Stateless operation */ 417 417 return EOK; 418 418 } … … 460 460 int rc; 461 461 462 / / Allocate enode462 /* Allocate enode */ 463 463 ext4fs_node_t *enode; 464 464 enode = malloc(sizeof(ext4fs_node_t)); … … 467 467 } 468 468 469 / / Allocate fs_node469 /* Allocate fs_node */ 470 470 fs_node_t *fs_node; 471 471 fs_node = malloc(sizeof(fs_node_t)); … … 475 475 } 476 476 477 / / Load instance477 /* Load instance */ 478 478 ext4fs_instance_t *inst; 479 479 rc = ext4fs_instance_get(service_id, &inst); … … 484 484 } 485 485 486 / / Allocate new i-node in filesystem486 /* Allocate new i-node in filesystem */ 487 487 ext4_inode_ref_t *inode_ref; 488 488 rc = ext4_filesystem_alloc_inode(inst->filesystem, &inode_ref, flags); … … 493 493 } 494 494 495 / / Do some interconnections in references495 /* Do some interconnections in references */ 496 496 enode->inode_ref = inode_ref; 497 497 enode->instance = inst; … … 530 530 int rc; 531 531 532 / / If directory, check for children532 /* If directory, check for children */ 533 533 bool has_children; 534 534 rc = ext4fs_has_children(&has_children, fn); … … 546 546 ext4_inode_ref_t *inode_ref = enode->inode_ref; 547 547 548 / / Release data blocks548 /* Release data blocks */ 549 549 rc = ext4_filesystem_truncate_inode(inode_ref, 0); 550 550 if (rc != EOK) { … … 553 553 } 554 554 555 // Handle orphans 555 /* Handle orphans */ 556 // TODO this code should be deleted 556 557 // ext4_filesystem_t *fs = enode->instance->filesystem; 557 558 // uint32_t rev_level = ext4_superblock_get_rev_level(fs->superblock); … … 564 565 // } 565 566 566 // TODO set real deletion time when it will be supported, 567 // temporary set fake time 567 // TODO set real deletion time when it will be supported, temporary set fake time 568 568 // time_t now = time(NULL); 569 569 ext4_inode_set_deletion_time(inode_ref->inode, 0xdeadbeef); 570 570 inode_ref->dirty = true; 571 571 572 / / Free inode572 /* Free inode */ 573 573 rc = ext4_filesystem_free_inode(inode_ref); 574 574 if (rc != EOK) { … … 592 592 int rc; 593 593 594 / / Check maximum name length594 /* Check maximum name length */ 595 595 if (strlen(name) > EXT4_DIRECTORY_FILENAME_LEN) { 596 596 return ENAMETOOLONG; … … 600 600 ext4_filesystem_t *fs = parent->instance->filesystem; 601 601 602 / / Add entry to parent directory602 /* Add entry to parent directory */ 603 603 rc = ext4_directory_add_entry(parent->inode_ref, name, child->inode_ref); 604 604 if (rc != EOK) { … … 606 606 } 607 607 608 / / Fill new dir -> add '.' and '..' entries608 /* Fill new dir -> add '.' and '..' entries */ 609 609 if (ext4_inode_is_type(fs->superblock, child->inode_ref->inode, EXT4_INODE_MODE_DIRECTORY)) { 610 610 … … 622 622 } 623 623 624 / / Initialize directory index if supported624 /* Initialize directory index if supported */ 625 625 if (ext4_superblock_has_feature_compatible( 626 626 fs->superblock, EXT4_FEATURE_COMPAT_DIR_INDEX)) { … … 670 670 } 671 671 672 / / Cannot unlink non-empty node672 /* Cannot unlink non-empty node */ 673 673 if (has_children) { 674 674 return ENOTEMPTY; 675 675 } 676 676 677 / / Remove entry from parent directory677 /* Remove entry from parent directory */ 678 678 ext4_inode_ref_t *parent = EXT4FS_NODE(pfn)->inode_ref; 679 679 rc = ext4_directory_remove_entry(parent, name); … … 682 682 } 683 683 684 / / Decrement links count684 /* Decrement links count */ 685 685 ext4_inode_ref_t * child_inode_ref = EXT4FS_NODE(cfn)->inode_ref; 686 686 … … 688 688 lnk_count--; 689 689 690 / / If directory - handle links from parent690 /* If directory - handle links from parent */ 691 691 if (lnk_count <= 1 && ext4fs_is_directory(cfn)) { 692 692 … … 744 744 ext4_filesystem_t *fs = enode->instance->filesystem; 745 745 746 / / Check if node is directory746 /* Check if node is directory */ 747 747 if (!ext4_inode_is_type(fs->superblock, enode->inode_ref->inode, 748 748 EXT4_INODE_MODE_DIRECTORY)) { … … 830 830 } 831 831 832 / / For regular files return real links count832 /* For regular files return real links count */ 833 833 return lnkcnt; 834 834 } … … 1055 1055 } 1056 1056 1057 / / Load i-node1057 /* Load i-node */ 1058 1058 ext4_inode_ref_t *inode_ref; 1059 1059 rc = ext4_filesystem_get_inode_ref(inst->filesystem, index, &inode_ref); … … 1063 1063 } 1064 1064 1065 / / Read from i-node by type1065 /* Read from i-node by type */ 1066 1066 if (ext4_inode_is_type(inst->filesystem->superblock, inode_ref->inode, 1067 1067 EXT4_INODE_MODE_FILE)) { … … 1183 1183 } 1184 1184 1185 / / Prepare return values1185 /* Prepare return values */ 1186 1186 if (found) { 1187 1187 *rbytes = next - pos; … … 1317 1317 uint32_t block_size = ext4_superblock_get_block_size(fs->superblock); 1318 1318 1319 / / Prevent writing to more than one block1319 /* Prevent writing to more than one block */ 1320 1320 uint32_t bytes = min(len, block_size - (pos % block_size)); 1321 1321 … … 1328 1328 uint32_t fblock; 1329 1329 1330 / / Load inode1330 /* Load inode */ 1331 1331 ext4_inode_ref_t *inode_ref = enode->inode_ref; 1332 1332 rc = ext4_filesystem_get_inode_data_block_index(inode_ref, iblock, &fblock); … … 1337 1337 } 1338 1338 1339 / / Check for sparse file1339 /* Check for sparse file */ 1340 1340 if (fblock == 0) { 1341 1341 … … 1375 1375 } 1376 1376 1377 / / Load target block1377 /* Load target block */ 1378 1378 block_t *write_block; 1379 1379 rc = block_get(&write_block, service_id, fblock, flags); … … 1402 1402 } 1403 1403 1404 / / Do some counting1404 /* Do some counting */ 1405 1405 uint32_t old_inode_size = ext4_inode_get_size(fs->superblock, inode_ref->inode); 1406 1406 if (pos + bytes > old_inode_size) {
Note:
See TracChangeset
for help on using the changeset viewer.