summaryrefslogtreecommitdiff
path: root/src/kernel/vfs
diff options
context:
space:
mode:
authordzwdz2021-09-12 17:53:48 +0200
committerdzwdz2021-09-12 17:53:48 +0200
commit3ea9657aaaf02709c8f216285b095af29e76491c (patch)
tree36dfe7038f2ff829791ccdaf18b0ee71744207a6 /src/kernel/vfs
parent5090829984cd4b3238d3f42eaad2431f1fd5282b (diff)
implement part of `fs_respond`
Diffstat (limited to 'src/kernel/vfs')
-rw-r--r--src/kernel/vfs/request.c28
1 files changed, 17 insertions, 11 deletions
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 <kernel/vfs/root.h>
// 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))