From e55ace0f517ede6f3635341c8adadc7b90aa75c5 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 16 Apr 2022 18:31:21 +0200 Subject: kernel/vfs: be more strict about the state of `vfs_backend.handler` --- src/kernel/syscalls.c | 1 + src/kernel/vfs/request.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 31bd0de..b424bf1 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -206,6 +206,7 @@ int _syscall_fs_wait(char __user *buf, int max_len, struct fs_wait_response __us if (!backend) return -1; process_transition(process_current, PS_WAITS4REQUEST); + assert(!backend->handler); // TODO allow multiple processes to wait on the same backend backend->handler = process_current; /* checking the validity of those pointers here would make * vfs_request_accept simpler. TODO? */ diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index 277c353..ad72264 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -21,9 +21,8 @@ int vfs_request_create(struct vfs_request req_) { case VFS_BACK_ROOT: return vfs_root_handler(req); case VFS_BACK_USER: - if (req->backend->handler - && req->backend->handler->state == PS_WAITS4REQUEST) - { + if (req->backend->handler) { + assert(req->backend->handler->state == PS_WAITS4REQUEST); vfs_request_accept(req); } else { // backend isn't ready yet, join the queue @@ -65,6 +64,7 @@ int vfs_request_accept(struct vfs_request *req) { process_transition(handler, PS_RUNNING); handler->handled_req = req; + req->backend->handler = NULL; regs_savereturn(&handler->regs, 0); return 0; fail: -- cgit v1.2.3