summaryrefslogtreecommitdiff
path: root/src/kernel/handle.h
diff options
context:
space:
mode:
authordzwdz2021-09-04 15:25:40 +0200
committerdzwdz2021-09-04 15:25:40 +0200
commit57ce367309de9ac1b1938202156eac554420bb2a (patch)
tree7be24257975d47a7db6e4c5a999b6e1951142ff3 /src/kernel/handle.h
parenta5bd09d5a995400c4f4ec1270e1ad380d238783c (diff)
rename file descriptors to handles
Diffstat (limited to 'src/kernel/handle.h')
-rw-r--r--src/kernel/handle.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/kernel/handle.h b/src/kernel/handle.h
new file mode 100644
index 0000000..4b066ad
--- /dev/null
+++ b/src/kernel/handle.h
@@ -0,0 +1,47 @@
+#pragma once
+#include <kernel/types.h>
+#include <stddef.h>
+
+#define HANDLE_MAX 16
+
+typedef int handle_t; // TODO duplicated in syscalls.h
+
+enum handle_type {
+ HANDLE_EMPTY,
+ HANDLE_SPECIAL_TTY,
+};
+
+struct handle {
+ enum handle_type type;
+};
+
+
+enum handleop { // describes the operations which can be done on handles
+ HANDLEOP_MOUNT, // also closes the original handle
+ HANDLEOP_OPEN,
+
+ HANDLEOP_READ,
+ HANDLEOP_WRITE,
+ HANDLEOP_CLOSE,
+};
+
+struct handleop_args {
+ enum handleop type;
+ struct handle *handle;
+ union {
+ struct { // HANDLEOP_MOUNT
+ struct mount *target;
+ } mnt;
+ struct { // HANDLEOP_OPEN
+ struct handle *target;
+ const char *path; // relative to the mount point
+ size_t len;
+ } open;
+ struct { // HANDLEOP_READ, HANDLEOP_WRITE
+ user_ptr ptr;
+ size_t len;
+ } rw;
+ };
+};
+
+int handleop_dispatch(struct handleop_args args);