Changeset 47a89fe in mainline
- Timestamp:
- 2012-01-21T12:55:43Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 86c71de
- Parents:
- 5614c7f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/ext4fs/ext4fs_ops.c
r5614c7f r47a89fe 369 369 int ext4fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags) 370 370 { 371 EXT4FS_DBG("not supported"); 372 371 EXT4FS_DBG(""); 372 int rc; 373 374 ext4fs_node_t *enode; 375 enode = malloc(sizeof(ext4fs_node_t)); 376 if (enode == NULL) { 377 return ENOMEM; 378 } 379 380 fs_node_t *fs_node; 381 fs_node = malloc(sizeof(fs_node_t)); 382 if (fs_node == NULL) { 383 free(enode); 384 return ENOMEM; 385 } 386 387 ext4fs_instance_t *inst; 388 rc = ext4fs_instance_get(service_id, &inst); 389 if (rc != EOK) { 390 free(enode); 391 free(fs_node); 392 return rc; 393 } 394 395 ext4_inode_ref_t *inode_ref; 396 rc = ext4_filesystem_alloc_inode(inst->filesystem, &inode_ref); 397 if (rc != EOK) { 398 free(enode); 399 free(fs_node); 400 return rc; 401 } 402 403 EXT4FS_DBG("inode allocated"); 373 404 // TODO 374 405 return ENOTSUP; 406 407 rc = ext4_filesystem_init_inode(inst->filesystem, inode_ref, flags); 408 if (rc != EOK) { 409 free(enode); 410 free(fs_node); 411 ext4_filesystem_free_inode(inst->filesystem, inode_ref); 412 return rc; 413 } 414 415 enode->inode_ref = inode_ref; 416 enode->instance = inst; 417 enode->references = 1; 418 419 link_initialize(&enode->link); 420 421 unsigned long key[] = { 422 [OPEN_NODES_DEV_HANDLE_KEY] = inst->service_id, 423 [OPEN_NODES_INODE_KEY] = inode_ref->index, 424 }; 425 426 fibril_mutex_lock(&open_nodes_lock); 427 hash_table_insert(&open_nodes, key, &enode->link); 428 fibril_mutex_unlock(&open_nodes_lock); 429 inst->open_nodes_count++; 430 431 enode->inode_ref->dirty = true; 432 433 fs_node_initialize(fs_node); 434 fs_node->data = enode; 435 enode->fs_node = fs_node; 436 *rfn = fs_node; 437 438 // TODO 439 return EOK; 375 440 } 376 441 … … 427 492 int ext4fs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name) 428 493 { 429 EXT4FS_DBG("not supported"); 430 431 // TODO 432 return ENOTSUP; 494 int rc; 495 496 // Check maximum name length 497 if (strlen(name) > EXT4_DIRECTORY_FILENAME_LEN) { 498 return ENAMETOOLONG; 499 } 500 501 ext4fs_node_t *parent = EXT4FS_NODE(pfn); 502 ext4fs_node_t *child = EXT4FS_NODE(cfn); 503 ext4_filesystem_t *fs = parent->instance->filesystem; 504 505 // Add entry to parent directory 506 rc = ext4_directory_add_entry(fs, parent->inode_ref, name, child->inode_ref->index); 507 if (rc != EOK) { 508 return rc; 509 } 510 511 // Fill new dir -> add '.' and '..' entries 512 if (ext4_inode_is_type(fs->superblock, child->inode_ref->inode, EXT4_INODE_MODE_DIRECTORY)) { 513 514 rc = ext4_directory_add_entry(fs, child->inode_ref, ".", child->inode_ref->index); 515 if (rc != EOK) { 516 ext4_directory_remove_entry(fs, parent->inode_ref, name); 517 return rc; 518 } 519 520 rc = ext4_directory_add_entry(fs, child->inode_ref, "..", parent->inode_ref->index); 521 if (rc != EOK) { 522 ext4_directory_remove_entry(fs, parent->inode_ref, name); 523 ext4_directory_remove_entry(fs, child->inode_ref, "."); 524 return rc; 525 } 526 527 uint16_t parent_links = ext4_inode_get_links_count(parent->inode_ref->inode); 528 parent_links++; 529 ext4_inode_set_links_count(parent->inode_ref->inode, parent_links); 530 531 parent->inode_ref->dirty = true; 532 533 } 534 535 uint16_t child_links = ext4_inode_get_links_count(child->inode_ref->inode); 536 child_links++; 537 ext4_inode_set_links_count(child->inode_ref->inode, child_links); 538 539 child->inode_ref->dirty = true; 540 541 return EOK; 433 542 } 434 543
Note:
See TracChangeset
for help on using the changeset viewer.