diff options
author | dzwdz | 2022-05-02 18:43:49 +0200 |
---|---|---|
committer | dzwdz | 2022-05-02 18:43:49 +0200 |
commit | 8513ae3c3e83ec8835bc0d1355284a9ddd928693 (patch) | |
tree | e5acf926b8bb3ad6a7660cb4ea5f7500c9255fb1 /src/kernel/handle.c | |
parent | 5abfbff30588e70efb5fc414f32b4bbda333f3f8 (diff) |
kernel/vfs: pass `close()` calls to fs handlers
Diffstat (limited to 'src/kernel/handle.c')
-rw-r--r-- | src/kernel/handle.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/kernel/handle.c b/src/kernel/handle.c index d7f19b3..91832a0 100644 --- a/src/kernel/handle.c +++ b/src/kernel/handle.c @@ -2,6 +2,7 @@ #include <kernel/mem/alloc.h> #include <kernel/panic.h> #include <kernel/proc.h> +#include <kernel/vfs/request.h> struct handle *handle_init(enum handle_type type) { struct handle *h = kmalloc(sizeof *h); @@ -13,15 +14,25 @@ struct handle *handle_init(enum handle_type type) { void handle_close(struct handle *h) { if (!h) return; assert(h->refcount > 0); - if (--(h->refcount) == 0) { - // TODO call close() in handler - // TODO count allocations and frees + if (--(h->refcount) > 0) return; - // TODO sanity check to check if refcount is true. handle_sanity? - - // TODO tests which would catch premature frees - // by that i mean duplicating a handle and killing the original process - h->type = HANDLE_INVALID; - kfree(h); + if (h->type == HANDLE_FILE) { + vfs_request_create((struct vfs_request) { + .type = VFSOP_CLOSE, + .id = h->file.id, + .caller = NULL, + .backend = h->file.backend, + }); } + + // TODO handle close(HANDLE_FS_FRONT) + + // TODO count allocations and frees + + // TODO sanity check to check if refcount is true. handle_sanity? + + // TODO tests which would catch premature frees + // by that i mean duplicating a handle and killing the original process + h->type = HANDLE_INVALID; + kfree(h); } |