summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/request.c
diff options
context:
space:
mode:
authordzwdz2022-04-15 23:42:43 +0200
committerdzwdz2022-04-15 23:42:43 +0200
commit42e4b941b70499f5cf10f41126af1634821d72d5 (patch)
tree6b56775263837b7883b7a05a7603bc59274ce05d /src/kernel/vfs/request.c
parent26849aa2b3f49cbad8be4688800667e2d89aa5db (diff)
kernel/vfs: don't hang on orphaned vfs calls
Diffstat (limited to 'src/kernel/vfs/request.c')
-rw-r--r--src/kernel/vfs/request.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index 687f456..277c353 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -14,7 +14,7 @@ int vfs_request_create(struct vfs_request req_) {
process_current->waits4fs.req = req_;
req = &process_current->waits4fs.req;
- if (!req->backend)
+ if (!req->backend || !req->backend->potential_handlers)
return vfs_request_finish(req, -1);
switch (req->backend->type) {
@@ -89,10 +89,22 @@ int vfs_request_finish(struct vfs_request *req, int ret) {
ret = handle;
}
- if (req->input.kern) kfree(req->input.buf_kern);
+ if (req->input.kern)
+ kfree(req->input.buf_kern);
assert(req->caller->state == PS_WAITS4FS || req->caller->state == PS_WAITS4IRQ);
process_transition(req->caller, PS_RUNNING);
regs_savereturn(&req->caller->regs, ret);
return ret;
}
+
+void vfs_request_cancel(struct vfs_request *req, int ret) {
+ if (req->input.kern)
+ kfree(req->input.buf_kern);
+
+ // ret must always be negative, so it won't be confused with a success
+ if (ret > 0) ret = -ret;
+ if (ret == 0) ret = -1;
+ regs_savereturn(&req->caller->regs, ret);
+ process_transition(req->caller, PS_RUNNING);
+}