diff options
author | dzwdz | 2022-04-14 08:04:52 +0200 |
---|---|---|
committer | dzwdz | 2022-04-14 08:04:52 +0200 |
commit | acf27b6071884c7a0939f26f47d3895d134f5088 (patch) | |
tree | bab672f76f9ec050bf48eb69c9fb469c2ecfd850 /src/kernel/vfs/request.c | |
parent | cd096cf7aa7b96e04a68d059efe3239d77d25d78 (diff) |
kernel: slightly clean up `vfs/request.c`
Diffstat (limited to 'src/kernel/vfs/request.c')
-rw-r--r-- | src/kernel/vfs/request.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index e8bf147..0ac0b3a 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -7,6 +7,7 @@ int vfs_request_create(struct vfs_request req_) { struct vfs_request *req; + assert(process_current->state == PS_RUNNING); process_current->state = PS_WAITS4FS; process_current->waits4fs.queue_next = NULL; @@ -43,21 +44,15 @@ int vfs_request_accept(struct vfs_request *req) { struct fs_wait_response res = {0}; int len; assert(handler); - assert(handler->state == PS_WAITS4REQUEST); // TODO currently callers have to ensure that the handler is in the correct state. should they? + assert(handler->state == PS_WAITS4REQUEST); assert(!handler->handled_req); len = min(req->input.len, handler->awaited_req.max_len); - // TODO having to separately handle copying from kernel and userland stinks - if (req->input.kern) { - if (!virt_cpy_to(handler->pages, - handler->awaited_req.buf, req->input.buf_kern, len)) - goto fail; // can't copy buffer - } else { - if (!virt_cpy(handler->pages, handler->awaited_req.buf, - req->caller->pages, req->input.buf, len)) - goto fail; // can't copy buffer - } + // wouldn't it be kinda nice to have a fake kernel "process"? + if (!virt_cpy(handler->pages, handler->awaited_req.buf, + req->input.kern ? NULL : req->caller->pages, req->input.buf, len)) + goto fail; // can't copy buffer res.len = len; res.capacity = req->output.len; @@ -97,6 +92,7 @@ int vfs_request_finish(struct vfs_request *req, int ret) { if (req->input.kern) kfree(req->input.buf_kern); + assert(req->caller->state = PS_WAITS4FS); req->caller->state = PS_RUNNING; regs_savereturn(&req->caller->regs, ret); return ret; |