summaryrefslogtreecommitdiff
path: root/src/kernel/proc.h
diff options
context:
space:
mode:
authordzwdz2022-08-19 17:50:55 +0200
committerdzwdz2022-08-19 17:50:55 +0200
commite9161cdcda9e5170f3ea5f18a8275395004ffce4 (patch)
tree104d2a290c6431012d7ceedbdd4208688e8d1387 /src/kernel/proc.h
parent05f93a814a9b5fa6b0f3223fc51566c84b92d158 (diff)
kernel/proc: abstract away managing handles
Diffstat (limited to 'src/kernel/proc.h')
-rw-r--r--src/kernel/proc.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/kernel/proc.h b/src/kernel/proc.h
index e7946b2..4b256bd 100644
--- a/src/kernel/proc.h
+++ b/src/kernel/proc.h
@@ -48,7 +48,7 @@ struct process {
};
struct vfs_mount *mount;
- struct handle *handles[HANDLE_MAX];
+ struct handle *_handles[HANDLE_MAX];
uint32_t id; /* only for debugging, don't expose to userland */
bool noreap;
@@ -84,5 +84,18 @@ struct process *process_next(struct process *);
handle_t process_find_free_handle(struct process *proc, handle_t start_at);
struct handle *process_handle_get(struct process *, handle_t);
+handle_t process_handle_init(struct process *, enum handle_type, struct handle **);
+handle_t process_handle_dup(struct process *p, handle_t from, handle_t to);
+static inline void process_handle_close(struct process *p, handle_t hid) {
+ // TODO test
+ process_handle_dup(p, -1, hid);
+}
+
+/* Gets a handle and removes the process' reference to it, without decreasing the refcount.
+ * Meant to be used together with process_handle_put. */
+struct handle *process_handle_take(struct process *, handle_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. */
+handle_t process_handle_put(struct process *, struct handle *);
void process_transition(struct process *, enum process_state);