summaryrefslogtreecommitdiff
path: root/src/kernel/handle.c
diff options
context:
space:
mode:
authordzwdz2022-05-06 15:00:25 +0200
committerdzwdz2022-05-06 15:00:25 +0200
commit31d654e6503229c52172d72eaa018e1f274b6d48 (patch)
tree386a9e2d98c10592fc04808d31dd1a1da784742a /src/kernel/handle.c
parentc868eb79353cf1da06c00bbd426fbf8aed7b81c9 (diff)
kernel: remove the union in `struct handle`
Diffstat (limited to 'src/kernel/handle.c')
-rw-r--r--src/kernel/handle.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/kernel/handle.c b/src/kernel/handle.c
index 103c788..ac8db1f 100644
--- a/src/kernel/handle.c
+++ b/src/kernel/handle.c
@@ -16,22 +16,17 @@ void handle_close(struct handle *h) {
assert(h->refcount > 0);
if (--(h->refcount) > 0) return;
- switch (h->type) {
- case HANDLE_FILE:
- vfsreq_create((struct vfs_request) {
- .type = VFSOP_CLOSE,
- .id = h->file.id,
- .caller = NULL,
- .backend = h->file.backend,
- });
- vfs_backend_refdown(h->file.backend);
- break;
- case HANDLE_FS_FRONT:
- vfs_backend_refdown(h->fs.backend);
- break;
- case HANDLE_INVALID: panic_invalid_state();
+ if (h->type == HANDLE_FILE) {
+ vfsreq_create((struct vfs_request) {
+ .type = VFSOP_CLOSE,
+ .id = h->file_id,
+ .caller = NULL,
+ .backend = h->backend,
+ });
}
+ vfs_backend_refdown(h->backend);
+
// TODO sanity check to check if refcount is true. handle_sanity?
// TODO tests which would catch premature frees