Rev 4566 | Rev 4585 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4566 | Rev 4584 | ||
|---|---|---|---|
| Line 106... | Line 106... | ||
| 106 | return; |
106 | return; |
| 107 | } |
107 | } |
| 108 | 108 | ||
| 109 | /* |
109 | /* |
| 110 | * Now we hold a reference to mp_node. |
110 | * Now we hold a reference to mp_node. |
| 111 | * It will be dropped upon the corresponding VFS_UNMOUNT. |
111 | * It will be dropped upon the corresponding VFS_IN_UNMOUNT. |
| 112 | * This prevents the mount point from being deleted. |
112 | * This prevents the mount point from being deleted. |
| 113 | */ |
113 | */ |
| 114 | } else { |
114 | } else { |
| 115 | /* We still don't have the root file system mounted. */ |
115 | /* We still don't have the root file system mounted. */ |
| 116 | if (str_cmp(mp, "/") == 0) { |
116 | if (str_cmp(mp, "/") == 0) { |
| Line 119... | Line 119... | ||
| 119 | * we are almost done. |
119 | * we are almost done. |
| 120 | */ |
120 | */ |
| 121 | 121 | ||
| 122 | /* Tell the mountee that it is being mounted. */ |
122 | /* Tell the mountee that it is being mounted. */ |
| 123 | phone = vfs_grab_phone(fs_handle); |
123 | phone = vfs_grab_phone(fs_handle); |
| 124 | msg = async_send_1(phone, VFS_MOUNTED, |
124 | msg = async_send_1(phone, VFS_OUT_MOUNTED, |
| 125 | (ipcarg_t) dev_handle, &answer); |
125 | (ipcarg_t) dev_handle, &answer); |
| 126 | /* send the mount options */ |
126 | /* send the mount options */ |
| 127 | rc = ipc_data_write_start(phone, (void *)opts, |
127 | rc = ipc_data_write_start(phone, (void *)opts, |
| 128 | str_size(opts)); |
128 | str_size(opts)); |
| 129 | if (rc != EOK) { |
129 | if (rc != EOK) { |
| Line 181... | Line 181... | ||
| 181 | 181 | ||
| 182 | int mountee_phone = vfs_grab_phone(fs_handle); |
182 | int mountee_phone = vfs_grab_phone(fs_handle); |
| 183 | assert(mountee_phone >= 0); |
183 | assert(mountee_phone >= 0); |
| 184 | 184 | ||
| 185 | phone = vfs_grab_phone(mp_res.triplet.fs_handle); |
185 | phone = vfs_grab_phone(mp_res.triplet.fs_handle); |
| 186 | msg = async_send_4(phone, VFS_MOUNT, |
186 | msg = async_send_4(phone, VFS_OUT_MOUNT, |
| 187 | (ipcarg_t) mp_res.triplet.dev_handle, |
187 | (ipcarg_t) mp_res.triplet.dev_handle, |
| 188 | (ipcarg_t) mp_res.triplet.index, |
188 | (ipcarg_t) mp_res.triplet.index, |
| 189 | (ipcarg_t) fs_handle, |
189 | (ipcarg_t) fs_handle, |
| 190 | (ipcarg_t) dev_handle, &answer); |
190 | (ipcarg_t) dev_handle, &answer); |
| 191 | 191 | ||
| Line 435... | Line 435... | ||
| 435 | return; |
435 | return; |
| 436 | } |
436 | } |
| 437 | 437 | ||
| 438 | /* |
438 | /* |
| 439 | * The POSIX interface is open(path, oflag, mode). |
439 | * The POSIX interface is open(path, oflag, mode). |
| 440 | * We can receive oflags and mode along with the VFS_OPEN call; the path |
440 | * We can receive oflags and mode along with the VFS_IN_OPEN call; |
| 441 | * will need to arrive in another call. |
441 | * the path will need to arrive in another call. |
| 442 | * |
442 | * |
| 443 | * We also receive one private, non-POSIX set of flags called lflag |
443 | * We also receive one private, non-POSIX set of flags called lflag |
| 444 | * used to pass information to vfs_lookup_internal(). |
444 | * used to pass information to vfs_lookup_internal(). |
| 445 | */ |
445 | */ |
| 446 | int lflag = IPC_GET_ARG1(*request); |
446 | int lflag = IPC_GET_ARG1(*request); |
| Line 553... | Line 553... | ||
| 553 | /* |
553 | /* |
| 554 | * The following increase in reference count is for the fact that the |
554 | * The following increase in reference count is for the fact that the |
| 555 | * file is being opened and that a file structure is pointing to it. |
555 | * file is being opened and that a file structure is pointing to it. |
| 556 | * It is necessary so that the file will not disappear when |
556 | * It is necessary so that the file will not disappear when |
| 557 | * vfs_node_put() is called. The reference will be dropped by the |
557 | * vfs_node_put() is called. The reference will be dropped by the |
| 558 | * respective VFS_CLOSE. |
558 | * respective VFS_IN_CLOSE. |
| 559 | */ |
559 | */ |
| 560 | vfs_node_addref(node); |
560 | vfs_node_addref(node); |
| 561 | vfs_node_put(node); |
561 | vfs_node_put(node); |
| 562 | 562 | ||
| 563 | /* Success! Return the new file descriptor to the client. */ |
563 | /* Success! Return the new file descriptor to the client. */ |
| Line 630... | Line 630... | ||
| 630 | /* |
630 | /* |
| 631 | * The following increase in reference count is for the fact that the |
631 | * The following increase in reference count is for the fact that the |
| 632 | * file is being opened and that a file structure is pointing to it. |
632 | * file is being opened and that a file structure is pointing to it. |
| 633 | * It is necessary so that the file will not disappear when |
633 | * It is necessary so that the file will not disappear when |
| 634 | * vfs_node_put() is called. The reference will be dropped by the |
634 | * vfs_node_put() is called. The reference will be dropped by the |
| 635 | * respective VFS_CLOSE. |
635 | * respective VFS_IN_CLOSE. |
| 636 | */ |
636 | */ |
| 637 | vfs_node_addref(node); |
637 | vfs_node_addref(node); |
| 638 | vfs_node_put(node); |
638 | vfs_node_put(node); |
| 639 | 639 | ||
| 640 | /* Success! Return the new file descriptor to the client. */ |
640 | /* Success! Return the new file descriptor to the client. */ |
| Line 672... | Line 672... | ||
| 672 | * the same open file at a time. |
672 | * the same open file at a time. |
| 673 | */ |
673 | */ |
| 674 | fibril_mutex_lock(&file->lock); |
674 | fibril_mutex_lock(&file->lock); |
| 675 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
675 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
| 676 | 676 | ||
| 677 | /* Make a VFS_DEVICE request at the destination FS server. */ |
677 | /* Make a VFS_OUT_DEVICE request at the destination FS server. */ |
| 678 | aid_t msg; |
678 | aid_t msg; |
| 679 | ipc_call_t answer; |
679 | ipc_call_t answer; |
| 680 | msg = async_send_2(fs_phone, IPC_GET_METHOD(*request), |
680 | msg = async_send_2(fs_phone, VFS_OUT_DEVICE, file->node->dev_handle, |
| 681 | file->node->dev_handle, file->node->index, &answer); |
681 | file->node->index, &answer); |
| 682 | 682 | ||
| 683 | /* Wait for reply from the FS server. */ |
683 | /* Wait for reply from the FS server. */ |
| 684 | ipcarg_t rc; |
684 | ipcarg_t rc; |
| 685 | async_wait_for(msg, &rc); |
685 | async_wait_for(msg, &rc); |
| 686 | 686 | ||
| Line 706... | Line 706... | ||
| 706 | * the same open file at a time. |
706 | * the same open file at a time. |
| 707 | */ |
707 | */ |
| 708 | fibril_mutex_lock(&file->lock); |
708 | fibril_mutex_lock(&file->lock); |
| 709 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
709 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
| 710 | 710 | ||
| 711 | /* Make a VFS_SYMC request at the destination FS server. */ |
711 | /* Make a VFS_OUT_SYMC request at the destination FS server. */ |
| 712 | aid_t msg; |
712 | aid_t msg; |
| 713 | ipc_call_t answer; |
713 | ipc_call_t answer; |
| 714 | msg = async_send_2(fs_phone, IPC_GET_METHOD(*request), |
714 | msg = async_send_2(fs_phone, VFS_OUT_SYNC, file->node->dev_handle, |
| 715 | file->node->dev_handle, file->node->index, &answer); |
715 | file->node->index, &answer); |
| 716 | 716 | ||
| 717 | /* Wait for reply from the FS server. */ |
717 | /* Wait for reply from the FS server. */ |
| 718 | ipcarg_t rc; |
718 | ipcarg_t rc; |
| 719 | async_wait_for(msg, &rc); |
719 | async_wait_for(msg, &rc); |
| 720 | 720 | ||
| Line 740... | Line 740... | ||
| 740 | * the same open file at a time. |
740 | * the same open file at a time. |
| 741 | */ |
741 | */ |
| 742 | fibril_mutex_lock(&file->lock); |
742 | fibril_mutex_lock(&file->lock); |
| 743 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
743 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
| 744 | 744 | ||
| 745 | /* Make a VFS_CLOSE request at the destination FS server. */ |
745 | /* Make a VFS_OUT_CLOSE request at the destination FS server. */ |
| 746 | aid_t msg; |
746 | aid_t msg; |
| 747 | ipc_call_t answer; |
747 | ipc_call_t answer; |
| 748 | msg = async_send_2(fs_phone, IPC_GET_METHOD(*request), |
748 | msg = async_send_2(fs_phone, VFS_OUT_CLOSE, file->node->dev_handle, |
| 749 | file->node->dev_handle, file->node->index, &answer); |
749 | file->node->index, &answer); |
| 750 | 750 | ||
| 751 | /* Wait for reply from the FS server. */ |
751 | /* Wait for reply from the FS server. */ |
| 752 | ipcarg_t rc; |
752 | ipcarg_t rc; |
| 753 | async_wait_for(msg, &rc); |
753 | async_wait_for(msg, &rc); |
| 754 | 754 | ||
| Line 830... | Line 830... | ||
| 830 | /* Make a VFS_READ/VFS_WRITE request at the destination FS server. */ |
830 | /* Make a VFS_READ/VFS_WRITE request at the destination FS server. */ |
| 831 | aid_t msg; |
831 | aid_t msg; |
| 832 | ipc_call_t answer; |
832 | ipc_call_t answer; |
| 833 | if (!read && file->append) |
833 | if (!read && file->append) |
| 834 | file->pos = file->node->size; |
834 | file->pos = file->node->size; |
| 835 | msg = async_send_3(fs_phone, IPC_GET_METHOD(*request), |
835 | msg = async_send_3(fs_phone, read ? VFS_OUT_READ : VFS_OUT_WRITE, |
| 836 | file->node->dev_handle, file->node->index, file->pos, &answer); |
836 | file->node->dev_handle, file->node->index, file->pos, &answer); |
| 837 | 837 | ||
| 838 | /* |
838 | /* |
| 839 | * Forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the |
839 | * Forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the |
| 840 | * destination FS server. The call will be routed as if sent by |
840 | * destination FS server. The call will be routed as if sent by |
| Line 944... | Line 944... | ||
| 944 | { |
944 | { |
| 945 | ipcarg_t rc; |
945 | ipcarg_t rc; |
| 946 | int fs_phone; |
946 | int fs_phone; |
| 947 | 947 | ||
| 948 | fs_phone = vfs_grab_phone(fs_handle); |
948 | fs_phone = vfs_grab_phone(fs_handle); |
| 949 | rc = async_req_3_0(fs_phone, VFS_TRUNCATE, (ipcarg_t)dev_handle, |
949 | rc = async_req_3_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t)dev_handle, |
| 950 | (ipcarg_t)index, (ipcarg_t)size); |
950 | (ipcarg_t)index, (ipcarg_t)size); |
| 951 | vfs_release_phone(fs_phone); |
951 | vfs_release_phone(fs_phone); |
| 952 | return (int)rc; |
952 | return (int)rc; |
| 953 | } |
953 | } |
| 954 | 954 | ||
| Line 1048... | Line 1048... | ||
| 1048 | } |
1048 | } |
| 1049 | 1049 | ||
| 1050 | /* |
1050 | /* |
| 1051 | * The name has already been unlinked by vfs_lookup_internal(). |
1051 | * The name has already been unlinked by vfs_lookup_internal(). |
| 1052 | * We have to get and put the VFS node to ensure that it is |
1052 | * We have to get and put the VFS node to ensure that it is |
| 1053 | * VFS_DESTROY'ed after the last reference to it is dropped. |
1053 | * VFS_OUT_DESTROY'ed after the last reference to it is dropped. |
| 1054 | */ |
1054 | */ |
| 1055 | vfs_node_t *node = vfs_node_get(&lr); |
1055 | vfs_node_t *node = vfs_node_get(&lr); |
| 1056 | fibril_mutex_lock(&nodes_mutex); |
1056 | fibril_mutex_lock(&nodes_mutex); |
| 1057 | node->lnkcnt--; |
1057 | node->lnkcnt--; |
| 1058 | fibril_mutex_unlock(&nodes_mutex); |
1058 | fibril_mutex_unlock(&nodes_mutex); |