From 3ea9657aaaf02709c8f216285b095af29e76491c Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 12 Sep 2021 17:53:48 +0200 Subject: implement part of `fs_respond` --- src/kernel/vfs/request.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/kernel/vfs/request.c') diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index 2ff5d72..a8f2fc0 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -6,23 +6,27 @@ #include // dispatches a VFS operation to the correct process -_Noreturn void vfs_request_create(struct vfs_request req) { +_Noreturn void vfs_request_create(struct vfs_request req_) { + struct vfs_request *req; int ret; - switch (req.backend->type) { + process_current->state = PS_WAITS4FS; + + // the request is owned by the caller + process_current->pending_req = req_; + req = &process_current->pending_req; + + switch (req->backend->type) { case VFS_BACK_ROOT: - ret = vfs_root_handler(&req); - vfs_request_finish(&req, ret); + ret = vfs_root_handler(req); + vfs_request_finish(req, ret); case VFS_BACK_USER: - process_current->state = PS_WAITS4FS; - if (req.backend->handler == NULL) { + if (req->backend->handler == NULL) { // backend isn't ready yet, join the queue - assert(req.backend->queue == NULL); // TODO implement a proper queue - - req.backend->queue = process_current; - process_current->pending_req = req; + assert(req->backend->queue == NULL); // TODO implement a proper queue + req->backend->queue = process_current; process_switch_any(); } else { - vfs_request_pass2handler(&req); + vfs_request_pass2handler(req); } default: panic(); @@ -34,7 +38,9 @@ _Noreturn void vfs_request_pass2handler(struct vfs_request *req) { int len; assert(handler); assert(handler->state == PS_WAITS4REQUEST); + assert(!handler->handled_req); handler->state = PS_RUNNING; + handler->handled_req = req; if (!virt_cpy_from(handler->pages, &len, handler->awaited_req.len, sizeof len)) -- cgit v1.2.3