From 9047f1e3f502658de12808015179ab3881a4b03f Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 11 May 2024 20:24:17 +0200 Subject: kernel: refactor handle management out of proc.c --- src/kernel/proc.h | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'src/kernel/proc.h') diff --git a/src/kernel/proc.h b/src/kernel/proc.h index 24206fb..f4b6b97 100644 --- a/src/kernel/proc.h +++ b/src/kernel/proc.h @@ -1,11 +1,9 @@ #pragma once #include -#include +#include #include #include -#define HANDLE_MAX 16 - /* legal transitions described by proc_setstate */ enum proc_state { PS_RUNNING, @@ -66,8 +64,7 @@ struct Proc { }; VfsMount *mount; - Handle **_handles; /* points to Handle *[HANDLE_MAX] */ - uint64_t *handles_refcount; /* works just like pages_refcount */ + HandleSet *hs; // TODO pids should be 64bit. also typedef pid_t uint32_t globalid; /* only for internal use, don't expose to userland */ @@ -130,21 +127,6 @@ _Noreturn void proc_switch_any(void); Proc *proc_next(Proc *root, Proc *p); -hid_t proc_find_free_handle(Proc *proc, hid_t start_at); -Handle *proc_handle_get(Proc *, hid_t); -hid_t proc_handle_init(Proc *, enum handle_type, Handle **); -hid_t proc_handle_dup(Proc *p, hid_t from, hid_t to, int flags); -static inline void proc_handle_close(Proc *p, hid_t hid) { - proc_handle_dup(p, -1, hid, 0); -} - -/* Gets a handle and removes the process' reference to it, without decreasing the refcount. - * Meant to be used together with proc_handle_put. */ -Handle *proc_hid_take(Proc *, hid_t); -/* Put a handle in a process, taking the ownership away from the caller. - * Doesn't increase the refcount on success, decreases it on failure. */ -hid_t proc_handle_put(Proc *, Handle *); - void proc_setstate(Proc *, enum proc_state); size_t pcpy_to(Proc *p, __user void *dst, const void *src, size_t len); -- cgit v1.2.3