Rev 3424 | Rev 3536 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3424 | Rev 3425 | ||
|---|---|---|---|
| Line 69... | Line 69... | ||
| 69 | 69 | ||
| 70 | void vfs_mount(ipc_callid_t rid, ipc_call_t *request) |
70 | void vfs_mount(ipc_callid_t rid, ipc_call_t *request) |
| 71 | { |
71 | { |
| 72 | dev_handle_t dev_handle; |
72 | dev_handle_t dev_handle; |
| 73 | vfs_node_t *mp_node = NULL; |
73 | vfs_node_t *mp_node = NULL; |
| - | 74 | ipc_callid_t callid; |
|
| - | 75 | ipc_call_t data; |
|
| 74 | int rc; |
76 | int rc; |
| 75 | int phone; |
77 | int phone; |
| - | 78 | size_t size; |
|
| 76 | 79 | ||
| 77 | /* |
80 | /* |
| 78 | * We expect the library to do the device-name to device-handle |
81 | * We expect the library to do the device-name to device-handle |
| 79 | * translation for us, thus the device handle will arrive as ARG1 |
82 | * translation for us, thus the device handle will arrive as ARG1 |
| 80 | * in the request. |
83 | * in the request. |
| Line 84... | Line 87... | ||
| 84 | /* |
87 | /* |
| 85 | * For now, don't make use of ARG2 and ARG3, but they can be used to |
88 | * For now, don't make use of ARG2 and ARG3, but they can be used to |
| 86 | * carry mount options in the future. |
89 | * carry mount options in the future. |
| 87 | */ |
90 | */ |
| 88 | 91 | ||
| 89 | ipc_callid_t callid; |
- | |
| 90 | size_t size; |
- | |
| 91 | - | ||
| 92 | /* |
92 | /* |
| 93 | * Now, we expect the client to send us data with the name of the file |
93 | * Now, we expect the client to send us data with the name of the file |
| 94 | * system. |
94 | * system. |
| 95 | */ |
95 | */ |
| 96 | if (!ipc_data_write_receive(&callid, &size)) { |
96 | if (!ipc_data_write_receive(&callid, &size)) { |
| Line 113... | Line 113... | ||
| 113 | char fs_name[FS_NAME_MAXLEN + 1]; |
113 | char fs_name[FS_NAME_MAXLEN + 1]; |
| 114 | (void) ipc_data_write_finalize(callid, fs_name, size); |
114 | (void) ipc_data_write_finalize(callid, fs_name, size); |
| 115 | fs_name[size] = '\0'; |
115 | fs_name[size] = '\0'; |
| 116 | 116 | ||
| 117 | /* |
117 | /* |
| - | 118 | * Wait for IPC_M_PING so that we can return an error if we don't know |
|
| - | 119 | * fs_name. |
|
| - | 120 | */ |
|
| - | 121 | callid = async_get_call(&data); |
|
| - | 122 | if (IPC_GET_METHOD(data) != IPC_M_PING) { |
|
| - | 123 | ipc_answer_0(callid, ENOTSUP); |
|
| - | 124 | ipc_answer_0(rid, ENOTSUP); |
|
| - | 125 | return; |
|
| - | 126 | } |
|
| - | 127 | ||
| - | 128 | /* |
|
| 118 | * Check if we know a file system with the same name as is in fs_name. |
129 | * Check if we know a file system with the same name as is in fs_name. |
| 119 | * This will also give us its file system handle. |
130 | * This will also give us its file system handle. |
| 120 | */ |
131 | */ |
| 121 | fs_handle_t fs_handle = fs_name_to_handle(fs_name, true); |
132 | fs_handle_t fs_handle = fs_name_to_handle(fs_name, true); |
| 122 | if (!fs_handle) { |
133 | if (!fs_handle) { |
| - | 134 | ipc_answer_0(callid, ENOENT); |
|
| 123 | ipc_answer_0(rid, ENOENT); |
135 | ipc_answer_0(rid, ENOENT); |
| 124 | return; |
136 | return; |
| 125 | } |
137 | } |
| 126 | 138 | ||
| - | 139 | /* Acknowledge that we know fs_name. */ |
|
| - | 140 | ipc_answer_0(callid, EOK); |
|
| - | 141 | ||
| 127 | /* Now, we want the client to send us the mount point. */ |
142 | /* Now, we want the client to send us the mount point. */ |
| 128 | if (!ipc_data_write_receive(&callid, &size)) { |
143 | if (!ipc_data_write_receive(&callid, &size)) { |
| 129 | ipc_answer_0(callid, EINVAL); |
144 | ipc_answer_0(callid, EINVAL); |
| 130 | ipc_answer_0(rid, EINVAL); |
145 | ipc_answer_0(rid, EINVAL); |
| 131 | return; |
146 | return; |
| Line 188... | Line 203... | ||
| 188 | */ |
203 | */ |
| 189 | rwlock_write_unlock(&namespace_rwlock); |
204 | rwlock_write_unlock(&namespace_rwlock); |
| 190 | } else { |
205 | } else { |
| 191 | /* We still don't have the root file system mounted. */ |
206 | /* We still don't have the root file system mounted. */ |
| 192 | if ((size == 1) && (buf[0] == '/')) { |
207 | if ((size == 1) && (buf[0] == '/')) { |
| - | 208 | vfs_lookup_res_t mr_res; |
|
| - | 209 | vfs_node_t *mr_node; |
|
| - | 210 | ipcarg_t rindex; |
|
| - | 211 | ipcarg_t rsize; |
|
| - | 212 | ipcarg_t rlnkcnt; |
|
| - | 213 | ||
| 193 | /* |
214 | /* |
| 194 | * For this simple, but important case, |
215 | * For this simple, but important case, |
| 195 | * we are almost done. |
216 | * we are almost done. |
| 196 | */ |
217 | */ |
| 197 | free(buf); |
218 | free(buf); |
| 198 | 219 | ||
| 199 | /* Tell the mountee that it is being mounted. */ |
220 | /* Tell the mountee that it is being mounted. */ |
| 200 | phone = vfs_grab_phone(fs_handle); |
221 | phone = vfs_grab_phone(fs_handle); |
| 201 | rc = async_req_1_0(phone, VFS_MOUNTED, |
222 | rc = async_req_1_3(phone, VFS_MOUNTED, |
| 202 | (ipcarg_t) dev_handle); |
223 | (ipcarg_t) dev_handle, &rindex, &rsize, &rlnkcnt); |
| 203 | vfs_release_phone(phone); |
224 | vfs_release_phone(phone); |
| 204 | 225 | ||
| 205 | if (rc == EOK) { |
226 | if (rc != EOK) { |
| 206 | rootfs.fs_handle = fs_handle; |
227 | futex_up(&rootfs_futex); |
| 207 | rootfs.dev_handle = dev_handle; |
228 | ipc_answer_0(rid, rc); |
| - | 229 | return; |
|
| 208 | } |
230 | } |
| 209 | 231 | ||
| - | 232 | mr_res.triplet.fs_handle = fs_handle; |
|
| - | 233 | mr_res.triplet.dev_handle = dev_handle; |
|
| - | 234 | mr_res.triplet.index = (fs_index_t) rindex; |
|
| - | 235 | mr_res.size = (size_t) rsize; |
|
| - | 236 | mr_res.lnkcnt = (unsigned) rlnkcnt; |
|
| - | 237 | ||
| - | 238 | rootfs.fs_handle = fs_handle; |
|
| - | 239 | rootfs.dev_handle = dev_handle; |
|
| 210 | futex_up(&rootfs_futex); |
240 | futex_up(&rootfs_futex); |
| - | 241 | ||
| - | 242 | /* Add reference to the mounted root. */ |
|
| - | 243 | mr_node = vfs_node_get(&mr_res); |
|
| - | 244 | assert(mr_node); |
|
| - | 245 | ||
| 211 | ipc_answer_0(rid, rc); |
246 | ipc_answer_0(rid, rc); |
| 212 | return; |
247 | return; |
| 213 | } else { |
248 | } else { |
| 214 | /* |
249 | /* |
| 215 | * We can't resolve this without the root filesystem |
250 | * We can't resolve this without the root filesystem |
| Line 372... | Line 407... | ||
| 372 | } |
407 | } |
| 373 | 408 | ||
| 374 | void vfs_close(ipc_callid_t rid, ipc_call_t *request) |
409 | void vfs_close(ipc_callid_t rid, ipc_call_t *request) |
| 375 | { |
410 | { |
| 376 | int fd = IPC_GET_ARG1(*request); |
411 | int fd = IPC_GET_ARG1(*request); |
| 377 | if (fd >= MAX_OPEN_FILES) { |
- | |
| 378 | ipc_answer_0(rid, EBADF); |
- | |
| 379 | return; |
- | |
| 380 | } |
- | |
| 381 | vfs_fd_free(fd); |
412 | int rc = vfs_fd_free(fd); |
| 382 | ipc_answer_0(rid, EOK); |
413 | ipc_answer_0(rid, rc); |
| 383 | } |
414 | } |
| 384 | 415 | ||
| 385 | static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) |
416 | static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) |
| 386 | { |
417 | { |
| 387 | 418 | ||