From ed8ff1ff9c4c0f847ffc2ab4624bd999539a0890 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 11 Jul 2024 21:43:50 +0200 Subject: kernel: start cleaning up VfsRequest * I'm being more strict about the linked list state to hopefully ensure I'm not leaking any references. * vfsreq_create was renamed to vfsreq_dispatchcopy as that name feels more clear. It copies its argument, and dispatches it. * Requests for user backends are now handled more like requests for kernel backends - there's an accept() function that accepts a request. --- src/kernel/syscalls.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/kernel/syscalls.c') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 9b0746a..5771b6a 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -85,7 +85,7 @@ hid_t _sys_open(const char __user *path, long len, int flags) { memcpy(path_buf, path_buf + mount->prefix_len, len); } - vfsreq_create((VfsReq) { + vfsreq_dispatchcopy((VfsReq) { .type = VFSOP_OPEN, .input = { .kern = true, @@ -198,7 +198,7 @@ static long simple_vfsop( req.input.buf = buf; req.input.len = len; } - vfsreq_create(req); + vfsreq_dispatchcopy(req); } else if (h->type == HANDLE_PIPE) { if (vfsop == VFSOP_READ || vfsop == VFSOP_WRITE) { /* already checked if this is the correct pipe end */ @@ -238,7 +238,7 @@ long _sys_remove(hid_t hid) { hs_close(proc_cur->hs, hid); SYSCALL_RETURN(-EACCES); } - vfsreq_create((VfsReq) { + vfsreq_dispatchcopy((VfsReq) { .type = VFSOP_REMOVE, .id = h->file_id, .caller = proc_cur, @@ -271,7 +271,14 @@ 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; - vfs_backend_tryaccept(backend); // sets return value + // 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; + vfsback_useraccept(req); + } + return -1; // dummy } -- cgit v1.2.3