From 881be872675e4cff153c27c641980451c4a3f479 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 14 Jul 2024 19:40:31 +0200 Subject: kernel: make the adhoc VfsQueue queues use ReqQueue instead I'm still not sure if I should use sys/queue.h for this. But yeah, this is more consistent, and it will also let me switch over to O(1) insertions later on. --- src/kernel/syscalls.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/kernel/syscalls.c') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 39115e7..1e1cd2f 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -39,11 +39,11 @@ long _sys_fork(int flags, hid_t __user *fs_front) { } h->backend = kzalloc(sizeof *h->backend, "user fs"); - h->backend->is_user = true; - h->backend->provhcnt = 1; /* child */ h->backend->usehcnt = 1; /* handle */ + h->backend->is_user = true; + h->backend->user.provhcnt = 1; h->backend->user.handler = NULL; - h->backend->queue = NULL; + reqqueue_init(&h->backend->user.queue); child->controlled = h->backend; if (fs_front) { @@ -261,6 +261,7 @@ hid_t _sys_fs_wait(char __user *buf, long max_len, struct ufs_request __user *re /* nothing on the other end. EPIPE seems fitting */ SYSCALL_RETURN(-EPIPE); } + assert(backend->is_user); proc_setstate(proc_cur, PS_WAITS4REQUEST); if (backend->user.handler) @@ -270,11 +271,8 @@ hid_t _sys_fs_wait(char __user *buf, long max_len, struct ufs_request __user *re proc_cur->awaited_req.max_len = max_len; proc_cur->awaited_req.res = res; - // TODO maybe i should use the postqueue stuff here - if (backend->queue) { - VfsReq *req = backend->queue; - backend->queue = req->queue_next; - req->queue_next = NULL; + VfsReq *req = reqqueue_pop(&backend->user.queue); + if (req) { vfsback_useraccept(req); } -- cgit v1.2.3