summaryrefslogtreecommitdiff
path: root/fs/fd.h
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-15 00:30:36 +0200
committerMiguel <m.i@gmx.at>2018-09-15 00:30:36 +0200
commitfe7d0332267ef1e62153b685d2b5574ce624a4bc (patch)
tree0c5bb5af4275b55b141ff598d9daedd99eb12603 /fs/fd.h
parentc4b20a0ebbde1348e1e085e2ea3be35345d92b7c (diff)
reading ext2 files and using our abstractions
Diffstat (limited to 'fs/fd.h')
-rw-r--r--fs/fd.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/fs/fd.h b/fs/fd.h
new file mode 100644
index 0000000..a3bdb5a
--- /dev/null
+++ b/fs/fd.h
@@ -0,0 +1,35 @@
+// SIMPLE FILE DESCRIPTOR //
+
+#ifndef FD_H
+#define FD_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "fifo.h"
+
+enum FD_TYPE{
+ FD_TYPE_FIFO_BUFFERED=1,
+ FD_TYPE_EXT2_FILE=2
+};
+
+typedef struct fd_struct
+{
+ bool (*write)(struct fd_struct*,uint8_t);
+ uint8_t (*read)(struct fd_struct*);
+ bool (*has)(struct fd_struct*);
+ bool (*close)(struct fd_struct*);
+
+ uint8_t type;
+ void *data; // opaque data
+}fd;
+
+uint8_t fd_read(fd*);
+bool fd_has(fd*);
+bool fd_write(fd*,uint8_t);
+bool fd_close(fd*);
+
+fd fd_from_fifo(fifo* f);
+fd fd_from_path(char *path);
+
+#endif