Rev 4584 | Rev 4587 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4584 | Rev 4585 | ||
---|---|---|---|
Line 639... | Line 639... | ||
639 | 639 | ||
640 | /* Success! Return the new file descriptor to the client. */ |
640 | /* Success! Return the new file descriptor to the client. */ |
641 | ipc_answer_1(rid, EOK, fd); |
641 | ipc_answer_1(rid, EOK, fd); |
642 | } |
642 | } |
643 | 643 | ||
644 | void vfs_node(ipc_callid_t rid, ipc_call_t *request) |
- | |
645 | { |
- | |
646 | int fd = IPC_GET_ARG1(*request); |
- | |
647 | - | ||
648 | /* Lookup the file structure corresponding to the file descriptor. */ |
- | |
649 | vfs_file_t *file = vfs_file_get(fd); |
- | |
650 | if (!file) { |
- | |
651 | ipc_answer_0(rid, ENOENT); |
- | |
652 | return; |
- | |
653 | } |
- | |
654 | - | ||
655 | ipc_answer_3(rid, EOK, file->node->fs_handle, file->node->dev_handle, |
- | |
656 | file->node->index); |
- | |
657 | } |
- | |
658 | - | ||
659 | void vfs_device(ipc_callid_t rid, ipc_call_t *request) |
- | |
660 | { |
- | |
661 | int fd = IPC_GET_ARG1(*request); |
- | |
662 | - | ||
663 | /* Lookup the file structure corresponding to the file descriptor. */ |
- | |
664 | vfs_file_t *file = vfs_file_get(fd); |
- | |
665 | if (!file) { |
- | |
666 | ipc_answer_0(rid, ENOENT); |
- | |
667 | return; |
- | |
668 | } |
- | |
669 | - | ||
670 | /* |
- | |
671 | * Lock the open file structure so that no other thread can manipulate |
- | |
672 | * the same open file at a time. |
- | |
673 | */ |
- | |
674 | fibril_mutex_lock(&file->lock); |
- | |
675 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
- | |
676 | - | ||
677 | /* Make a VFS_OUT_DEVICE request at the destination FS server. */ |
- | |
678 | aid_t msg; |
- | |
679 | ipc_call_t answer; |
- | |
680 | msg = async_send_2(fs_phone, VFS_OUT_DEVICE, file->node->dev_handle, |
- | |
681 | file->node->index, &answer); |
- | |
682 | - | ||
683 | /* Wait for reply from the FS server. */ |
- | |
684 | ipcarg_t rc; |
- | |
685 | async_wait_for(msg, &rc); |
- | |
686 | - | ||
687 | vfs_release_phone(fs_phone); |
- | |
688 | fibril_mutex_unlock(&file->lock); |
- | |
689 | - | ||
690 | ipc_answer_1(rid, EOK, IPC_GET_ARG1(answer)); |
- | |
691 | } |
- | |
692 | - | ||
693 | void vfs_sync(ipc_callid_t rid, ipc_call_t *request) |
644 | void vfs_sync(ipc_callid_t rid, ipc_call_t *request) |
694 | { |
645 | { |
695 | int fd = IPC_GET_ARG1(*request); |
646 | int fd = IPC_GET_ARG1(*request); |
696 | 647 | ||
697 | /* Lookup the file structure corresponding to the file descriptor. */ |
648 | /* Lookup the file structure corresponding to the file descriptor. */ |
Line 974... | Line 925... | ||
974 | 925 | ||
975 | fibril_mutex_unlock(&file->lock); |
926 | fibril_mutex_unlock(&file->lock); |
976 | ipc_answer_0(rid, (ipcarg_t)rc); |
927 | ipc_answer_0(rid, (ipcarg_t)rc); |
977 | } |
928 | } |
978 | 929 | ||
- | 930 | void vfs_fstat(ipc_callid_t rid, ipc_call_t *request) |
|
- | 931 | { |
|
- | 932 | int fd = IPC_GET_ARG1(*request); |
|
- | 933 | size_t size = IPC_GET_ARG2(*request); |
|
- | 934 | ipcarg_t rc; |
|
- | 935 | ||
- | 936 | vfs_file_t *file = vfs_file_get(fd); |
|
- | 937 | if (!file) { |
|
- | 938 | ipc_answer_0(rid, ENOENT); |
|
- | 939 | return; |
|
- | 940 | } |
|
- | 941 | ||
- | 942 | ipc_callid_t callid; |
|
- | 943 | if (!ipc_data_read_receive(&callid, NULL)) { |
|
- | 944 | ipc_answer_0(callid, EINVAL); |
|
- | 945 | ipc_answer_0(rid, EINVAL); |
|
- | 946 | return; |
|
- | 947 | } |
|
- | 948 | ||
- | 949 | fibril_mutex_lock(&file->lock); |
|
- | 950 | ||
- | 951 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
|
- | 952 | ||
- | 953 | aid_t msg; |
|
- | 954 | msg = async_send_3(fs_phone, VFS_OUT_STAT, file->node->dev_handle, |
|
- | 955 | file->node->index, true, NULL); |
|
- | 956 | ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); |
|
- | 957 | async_wait_for(msg, &rc); |
|
- | 958 | vfs_release_phone(fs_phone); |
|
- | 959 | ||
- | 960 | fibril_mutex_unlock(&file->lock); |
|
- | 961 | ipc_answer_0(rid, rc); |
|
- | 962 | } |
|
- | 963 | ||
- | 964 | void vfs_stat(ipc_callid_t rid, ipc_call_t *request) |
|
- | 965 | { |
|
- | 966 | } |
|
- | 967 | ||
979 | void vfs_mkdir(ipc_callid_t rid, ipc_call_t *request) |
968 | void vfs_mkdir(ipc_callid_t rid, ipc_call_t *request) |
980 | { |
969 | { |
981 | int mode = IPC_GET_ARG1(*request); |
970 | int mode = IPC_GET_ARG1(*request); |
982 | 971 | ||
983 | size_t len; |
972 | size_t len; |