diff options
author | dzwdz | 2022-05-04 13:49:38 +0200 |
---|---|---|
committer | dzwdz | 2022-05-04 13:49:38 +0200 |
commit | 3bf07641ee5ba1c6ec56b81a7f34abe1267d3ac1 (patch) | |
tree | 2eee4442a5aba9fe3a29078a2e8187d999af83a3 /src/kernel/handle.c | |
parent | 9692ed2f93777e1060837b97687509f8a22c2b60 (diff) |
kernel: refcount vfs_backend
what a mess
Diffstat (limited to 'src/kernel/handle.c')
-rw-r--r-- | src/kernel/handle.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/kernel/handle.c b/src/kernel/handle.c index 91832a0..f5255c0 100644 --- a/src/kernel/handle.c +++ b/src/kernel/handle.c @@ -16,19 +16,22 @@ void handle_close(struct handle *h) { assert(h->refcount > 0); if (--(h->refcount) > 0) return; - if (h->type == HANDLE_FILE) { - vfs_request_create((struct vfs_request) { - .type = VFSOP_CLOSE, - .id = h->file.id, - .caller = NULL, - .backend = h->file.backend, - }); + switch (h->type) { + case HANDLE_FILE: + vfs_request_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(); } - // 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 |