Rev 2734 | Rev 2742 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2734 | Rev 2735 | ||
---|---|---|---|
Line 588... | Line 588... | ||
588 | } |
588 | } |
589 | 589 | ||
590 | void vfs_mkdir(ipc_callid_t rid, ipc_call_t *request) |
590 | void vfs_mkdir(ipc_callid_t rid, ipc_call_t *request) |
591 | { |
591 | { |
592 | int mode = IPC_GET_ARG1(*request); |
592 | int mode = IPC_GET_ARG1(*request); |
593 | size_t len; |
- | |
594 | 593 | ||
- | 594 | size_t len; |
|
595 | ipc_callid_t callid; |
595 | ipc_callid_t callid; |
596 | 596 | ||
597 | if (!ipc_data_write_receive(&callid, &len)) { |
597 | if (!ipc_data_write_receive(&callid, &len)) { |
598 | ipc_answer_0(callid, EINVAL); |
598 | ipc_answer_0(callid, EINVAL); |
599 | ipc_answer_0(rid, EINVAL); |
599 | ipc_answer_0(rid, EINVAL); |
Line 627... | Line 627... | ||
627 | rwlock_write_unlock(&namespace_rwlock); |
627 | rwlock_write_unlock(&namespace_rwlock); |
628 | free(path); |
628 | free(path); |
629 | ipc_answer_0(rid, rc); |
629 | ipc_answer_0(rid, rc); |
630 | } |
630 | } |
631 | 631 | ||
- | 632 | void vfs_unlink(ipc_callid_t rid, ipc_call_t *request) |
|
- | 633 | { |
|
- | 634 | int lflag = IPC_GET_ARG1(*request); |
|
- | 635 | ||
- | 636 | size_t len; |
|
- | 637 | ipc_callid_t callid; |
|
- | 638 | ||
- | 639 | if (!ipc_data_write_receive(&callid, &len)) { |
|
- | 640 | ipc_answer_0(callid, EINVAL); |
|
- | 641 | ipc_answer_0(rid, EINVAL); |
|
- | 642 | return; |
|
- | 643 | } |
|
- | 644 | ||
- | 645 | /* |
|
- | 646 | * Now we are on the verge of accepting the path. |
|
- | 647 | * |
|
- | 648 | * There is one optimization we could do in the future: copy the path |
|
- | 649 | * directly into the PLB using some kind of a callback. |
|
- | 650 | */ |
|
- | 651 | char *path = malloc(len); |
|
- | 652 | ||
- | 653 | if (!path) { |
|
- | 654 | ipc_answer_0(callid, ENOMEM); |
|
- | 655 | ipc_answer_0(rid, ENOMEM); |
|
- | 656 | return; |
|
- | 657 | } |
|
- | 658 | ||
- | 659 | int rc; |
|
- | 660 | if ((rc = ipc_data_write_finalize(callid, path, len))) { |
|
- | 661 | ipc_answer_0(rid, rc); |
|
- | 662 | free(path); |
|
- | 663 | return; |
|
- | 664 | } |
|
- | 665 | ||
- | 666 | rwlock_write_lock(&namespace_rwlock); |
|
- | 667 | lflag &= L_DIRECTORY; /* sanitize lflag */ |
|
- | 668 | vfs_lookup_res_t lr; |
|
- | 669 | rc = vfs_lookup_internal(path, len, lflag | L_DESTROY, &lr, NULL); |
|
- | 670 | free(path); |
|
- | 671 | if (rc != EOK) { |
|
- | 672 | rwlock_write_unlock(&namespace_rwlock); |
|
- | 673 | ipc_answer_0(rid, rc); |
|
- | 674 | return; |
|
- | 675 | } |
|
- | 676 | ||
- | 677 | /* |
|
- | 678 | * The name has already been unlinked by vfs_lookup_internal(). |
|
- | 679 | * We have to get and put the VFS node to ensure that it is |
|
- | 680 | * VFS_FREE'd after the last reference to it is dropped. |
|
- | 681 | */ |
|
- | 682 | vfs_node_t *node = vfs_node_get(&lr); |
|
- | 683 | node->lnkcnt--; |
|
- | 684 | rwlock_write_unlock(&namespace_rwlock); |
|
- | 685 | vfs_node_put(node); |
|
- | 686 | ipc_answer_0(rid, EOK); |
|
- | 687 | } |
|
- | 688 | ||
632 | /** |
689 | /** |
633 | * @} |
690 | * @} |
634 | */ |
691 | */ |