summaryrefslogtreecommitdiff
path: root/src/kernel/vfs
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/vfs')
-rw-r--r--src/kernel/vfs/mount.c1
-rw-r--r--src/kernel/vfs/request.c16
-rw-r--r--src/kernel/vfs/request.h4
3 files changed, 19 insertions, 2 deletions
diff --git a/src/kernel/vfs/mount.c b/src/kernel/vfs/mount.c
index c962ba5..423bf10 100644
--- a/src/kernel/vfs/mount.c
+++ b/src/kernel/vfs/mount.c
@@ -6,6 +6,7 @@ struct vfs_mount *vfs_mount_seed(void) {
struct vfs_mount *mount = kmalloc(sizeof *mount);
struct vfs_backend *backend = kmalloc(sizeof *backend);
backend->type = VFS_BACK_ROOT;
+ backend->potential_handlers = 1;
*mount = (struct vfs_mount){
.prev = NULL,
.prefix = "",
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);
+}
diff --git a/src/kernel/vfs/request.h b/src/kernel/vfs/request.h
index ce5a7fb..1e3ef60 100644
--- a/src/kernel/vfs/request.h
+++ b/src/kernel/vfs/request.h
@@ -13,6 +13,8 @@ enum vfs_backend_type {
struct vfs_backend {
enum vfs_backend_type type;
+ size_t potential_handlers; // 0 - orphaned
+
// only used with VFS_BACK_USER
struct process *handler;
struct process *queue;
@@ -45,3 +47,5 @@ struct vfs_request {
int vfs_request_create(struct vfs_request);
int vfs_request_accept(struct vfs_request *);
int vfs_request_finish(struct vfs_request *, int ret);
+
+void vfs_request_cancel(struct vfs_request *, int ret);