Rev 2927 | Rev 3153 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2927 | Rev 3009 | ||
---|---|---|---|
Line 82... | Line 82... | ||
82 | 82 | ||
83 | void vfs_mount(ipc_callid_t rid, ipc_call_t *request) |
83 | void vfs_mount(ipc_callid_t rid, ipc_call_t *request) |
84 | { |
84 | { |
85 | dev_handle_t dev_handle; |
85 | dev_handle_t dev_handle; |
86 | vfs_node_t *mp_node = NULL; |
86 | vfs_node_t *mp_node = NULL; |
- | 87 | int rc; |
|
- | 88 | int phone; |
|
87 | 89 | ||
88 | /* |
90 | /* |
89 | * We expect the library to do the device-name to device-handle |
91 | * We expect the library to do the device-name to device-handle |
90 | * translation for us, thus the device handle will arrive as ARG1 |
92 | * translation for us, thus the device handle will arrive as ARG1 |
91 | * in the request. |
93 | * in the request. |
Line 165... | Line 167... | ||
165 | * Lookup the root node of the filesystem being mounted. |
167 | * Lookup the root node of the filesystem being mounted. |
166 | * In this case, we don't need to take the namespace_futex as the root |
168 | * In this case, we don't need to take the namespace_futex as the root |
167 | * node cannot be removed. However, we do take a reference to it so |
169 | * node cannot be removed. However, we do take a reference to it so |
168 | * that we can track how many times it has been mounted. |
170 | * that we can track how many times it has been mounted. |
169 | */ |
171 | */ |
170 | int rc; |
- | |
171 | vfs_lookup_res_t mr_res; |
172 | vfs_lookup_res_t mr_res; |
172 | rc = lookup_root(fs_handle, dev_handle, &mr_res); |
173 | rc = lookup_root(fs_handle, dev_handle, &mr_res); |
173 | if (rc != EOK) { |
174 | if (rc != EOK) { |
174 | free(buf); |
175 | free(buf); |
175 | ipc_answer_0(rid, rc); |
176 | ipc_answer_0(rid, rc); |
Line 223... | Line 224... | ||
223 | */ |
224 | */ |
224 | rwlock_write_unlock(&namespace_rwlock); |
225 | rwlock_write_unlock(&namespace_rwlock); |
225 | } else { |
226 | } else { |
226 | /* We still don't have the root file system mounted. */ |
227 | /* We still don't have the root file system mounted. */ |
227 | if ((size == 1) && (buf[0] == '/')) { |
228 | if ((size == 1) && (buf[0] == '/')) { |
- | 229 | /* |
|
228 | /* For this simple, but important case, we are done. */ |
230 | * For this simple, but important case, |
229 | rootfs = mr_res.triplet; |
231 | * we are almost done. |
230 | futex_up(&rootfs_futex); |
232 | */ |
231 | free(buf); |
233 | free(buf); |
- | 234 | ||
- | 235 | /* Inform the mount point about the root mount. */ |
|
- | 236 | phone = vfs_grab_phone(mr_res.triplet.fs_handle); |
|
- | 237 | rc = async_req_5_0(phone, VFS_MOUNT, |
|
- | 238 | (ipcarg_t) mr_res.triplet.dev_handle, |
|
- | 239 | (ipcarg_t) mr_res.triplet.index, |
|
- | 240 | (ipcarg_t) mr_res.triplet.fs_handle, |
|
- | 241 | (ipcarg_t) mr_res.triplet.dev_handle, |
|
- | 242 | (ipcarg_t) mr_res.triplet.index); |
|
- | 243 | vfs_release_phone(phone); |
|
- | 244 | ||
- | 245 | if (rc == EOK) |
|
- | 246 | rootfs = mr_res.triplet; |
|
- | 247 | else |
|
- | 248 | vfs_node_put(mr_node); |
|
- | 249 | ||
- | 250 | futex_up(&rootfs_futex); |
|
232 | ipc_answer_0(rid, EOK); |
251 | ipc_answer_0(rid, rc); |
233 | return; |
252 | return; |
234 | } else { |
253 | } else { |
235 | /* |
254 | /* |
236 | * We can't resolve this without the root filesystem |
255 | * We can't resolve this without the root filesystem |
237 | * being mounted first. |
256 | * being mounted first. |
Line 251... | Line 270... | ||
251 | * At this point, we have all necessary pieces: file system and device |
270 | * At this point, we have all necessary pieces: file system and device |
252 | * handles, and we know the mount point VFS node and also the root node |
271 | * handles, and we know the mount point VFS node and also the root node |
253 | * of the file system being mounted. |
272 | * of the file system being mounted. |
254 | */ |
273 | */ |
255 | 274 | ||
- | 275 | /** |
|
- | 276 | * @todo |
|
- | 277 | * Add more IPC parameters so that we can send mount mode/flags. |
|
- | 278 | */ |
|
256 | int phone = vfs_grab_phone(mp_res.triplet.fs_handle); |
279 | phone = vfs_grab_phone(mp_res.triplet.fs_handle); |
257 | /* Later we can use ARG3 to pass mode/flags. */ |
- | |
258 | aid_t req1 = async_send_3(phone, VFS_MOUNT, |
280 | rc = async_req_5_0(phone, VFS_MOUNT, |
259 | (ipcarg_t) mp_res.triplet.dev_handle, |
281 | (ipcarg_t) mp_res.triplet.dev_handle, |
260 | (ipcarg_t) mp_res.triplet.index, 0, NULL); |
282 | (ipcarg_t) mp_res.triplet.index, |
261 | /* The second call uses the same method. */ |
- | |
262 | aid_t req2 = async_send_3(phone, VFS_MOUNT, |
- | |
263 | (ipcarg_t) mr_res.triplet.fs_handle, |
283 | (ipcarg_t) mr_res.triplet.fs_handle, |
264 | (ipcarg_t) mr_res.triplet.dev_handle, |
284 | (ipcarg_t) mr_res.triplet.dev_handle, |
265 | (ipcarg_t) mr_res.triplet.index, NULL); |
285 | (ipcarg_t) mr_res.triplet.index); |
266 | vfs_release_phone(phone); |
286 | vfs_release_phone(phone); |
267 | 287 | ||
268 | ipcarg_t rc1; |
- | |
269 | ipcarg_t rc2; |
- | |
270 | async_wait_for(req1, &rc1); |
- | |
271 | async_wait_for(req2, &rc2); |
- | |
272 | - | ||
273 | if ((rc1 != EOK) || (rc2 != EOK)) { |
288 | if (rc != EOK) { |
274 | /* Mount failed, drop references to mr_node and mp_node. */ |
289 | /* Mount failed, drop references to mr_node and mp_node. */ |
275 | vfs_node_put(mr_node); |
290 | vfs_node_put(mr_node); |
276 | if (mp_node) |
291 | if (mp_node) |
277 | vfs_node_put(mp_node); |
292 | vfs_node_put(mp_node); |
278 | } |
293 | } |
279 | 294 | ||
280 | if (rc2 == EOK) |
- | |
281 | ipc_answer_0(rid, rc1); |
295 | ipc_answer_0(rid, rc); |
282 | else if (rc1 == EOK) |
- | |
283 | ipc_answer_0(rid, rc2); |
- | |
284 | else |
- | |
285 | ipc_answer_0(rid, rc1); |
- | |
286 | } |
296 | } |
287 | 297 | ||
288 | void vfs_open(ipc_callid_t rid, ipc_call_t *request) |
298 | void vfs_open(ipc_callid_t rid, ipc_call_t *request) |
289 | { |
299 | { |
290 | if (!vfs_files_init()) { |
300 | if (!vfs_files_init()) { |