summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/request.c
diff options
context:
space:
mode:
authordzwdz2022-04-07 22:33:03 +0200
committerdzwdz2022-04-07 22:33:03 +0200
commitab74da4bfff9d37b7b5f5f98bda7edfc2ebc3ea6 (patch)
treed44fc9ee4c1b1a41bc1f6646ba497aba6b272473 /src/kernel/vfs/request.c
parent6a71c766e60a9ac12876a0ea8a10c997df2507a3 (diff)
kernel/vfs: fix panic when using an user fs which hadn't yet wait()ed
Diffstat (limited to 'src/kernel/vfs/request.c')
-rw-r--r--src/kernel/vfs/request.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index 0214ca7..761b619 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -25,15 +25,17 @@ int vfs_request_create(struct vfs_request req_) {
ret = vfs_request_finish(req, ret);
return ret;
case VFS_BACK_USER:
- if (req->backend->handler == NULL) {
+ if (req->backend->handler
+ && req->backend->handler->state == PS_WAITS4REQUEST)
+ {
+ vfs_request_pass2handler(req);
+ } else {
// backend isn't ready yet, join the queue
struct process **iter = &req->backend->queue;
while (*iter != NULL)
iter = &(*iter)->waits4fs.queue_next;
*iter = process_current;
process_switch_any();
- } else {
- vfs_request_pass2handler(req);
}
default:
panic_invalid_state();
@@ -45,7 +47,7 @@ _Noreturn void vfs_request_pass2handler(struct vfs_request *req) {
struct fs_wait_response res = {0};
int len;
assert(handler);
- assert(handler->state == PS_WAITS4REQUEST);
+ assert(handler->state == PS_WAITS4REQUEST); // TODO currently callers have to ensure that the handler is in the correct state. should they?
assert(!handler->handled_req);
handler->state = PS_RUNNING;
handler->handled_req = req;