Rev 2663 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2663 | Rev 2666 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | /** @addtogroup fs |
29 | /** @addtogroup fs |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** |
33 | /** |
34 | * @file vfs_read.c |
34 | * @file vfs_rdwr.c |
35 | * @brief |
35 | * @brief |
36 | */ |
36 | */ |
37 | 37 | ||
38 | #include "vfs.h" |
38 | #include "vfs.h" |
39 | #include <ipc/ipc.h> |
39 | #include <ipc/ipc.h> |
40 | #include <async.h> |
40 | #include <async.h> |
41 | #include <errno.h> |
41 | #include <errno.h> |
42 | 42 | ||
43 | void vfs_read(ipc_callid_t rid, ipc_call_t *request) |
43 | static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) |
44 | { |
44 | { |
45 | 45 | ||
46 | /* |
46 | /* |
47 | * The following code strongly depends on the fact that the files data |
47 | * The following code strongly depends on the fact that the files data |
48 | * structure can be only accessed by a single fibril and all file |
48 | * structure can be only accessed by a single fibril and all file |
Line 63... | Line 63... | ||
63 | ipc_answer_0(rid, ENOENT); |
63 | ipc_answer_0(rid, ENOENT); |
64 | return; |
64 | return; |
65 | } |
65 | } |
66 | 66 | ||
67 | /* |
67 | /* |
68 | * Now we need to receive a call with client's IPC_M_DATA_READ request. |
68 | * Now we need to receive a call with client's |
- | 69 | * IPC_M_DATA_READ/IPC_M_DATA_WRITE request. |
|
69 | */ |
70 | */ |
70 | ipc_callid_t callid; |
71 | ipc_callid_t callid; |
- | 72 | int res; |
|
- | 73 | if (read) |
|
71 | if (!ipc_data_read_receive(&callid, NULL)) { |
74 | res = ipc_data_read_receive(&callid, NULL); |
- | 75 | else |
|
- | 76 | res = ipc_data_write_receive(&callid, NULL, NULL); |
|
- | 77 | if (!res) { |
|
72 | ipc_answer_0(callid, EINVAL); |
78 | ipc_answer_0(callid, EINVAL); |
73 | ipc_answer_0(rid, EINVAL); |
79 | ipc_answer_0(rid, EINVAL); |
74 | return; |
80 | return; |
75 | } |
81 | } |
76 | 82 | ||
77 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
83 | int fs_phone = vfs_grab_phone(file->node->fs_handle); |
78 | 84 | ||
79 | /* |
85 | /* |
80 | * Make a VFS_READ request at the destination FS server. |
86 | * Make a VFS_READ/VFS_WRITE request at the destination FS server. |
81 | */ |
87 | */ |
82 | aid_t msg; |
88 | aid_t msg; |
83 | ipc_call_t answer; |
89 | ipc_call_t answer; |
84 | msg = async_send_3(fs_phone, VFS_READ, file->node->dev_handle, |
90 | msg = async_send_3(fs_phone, IPC_GET_METHOD(*request), |
85 | file->node->index, file->pos, &answer); |
91 | file->node->dev_handle, file->node->index, file->pos, &answer); |
86 | 92 | ||
87 | /* |
93 | /* |
88 | * Forward the IPC_M_DATA_READ request to the destination FS server. |
94 | * Forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the |
89 | * The call will be routed as if sent by ourselves. Note that call |
95 | * destination FS server. The call will be routed as if sent by |
90 | * arguments are immutable in this case so we don't have to bother. |
96 | * ourselves. Note that call arguments are immutable in this case so we |
- | 97 | * don't have to bother. |
|
91 | */ |
98 | */ |
92 | ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); |
99 | ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); |
93 | 100 | ||
94 | vfs_release_phone(fs_phone); |
101 | vfs_release_phone(fs_phone); |
95 | 102 | ||
Line 110... | Line 117... | ||
110 | * return to the client. |
117 | * return to the client. |
111 | */ |
118 | */ |
112 | ipc_answer_1(rid, rc, bytes); |
119 | ipc_answer_1(rid, rc, bytes); |
113 | } |
120 | } |
114 | 121 | ||
- | 122 | ||
- | 123 | void vfs_read(ipc_callid_t rid, ipc_call_t *request) |
|
- | 124 | { |
|
- | 125 | vfs_rdwr(rid, request, true); |
|
- | 126 | } |
|
- | 127 | ||
- | 128 | void vfs_write(ipc_callid_t rid, ipc_call_t *request) |
|
- | 129 | { |
|
- | 130 | vfs_rdwr(rid, request, false); |
|
- | 131 | } |
|
- | 132 | ||
115 | /** |
133 | /** |
116 | * @} |
134 | * @} |
117 | */ |
135 | */ |