aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/fs/vfs.c
diff options
context:
space:
mode:
authorMarvin Borner2019-10-31 17:47:40 +0100
committerGitHub2019-10-31 17:47:40 +0100
commitc7e755cb843593db1eedb26c5c24932bbe743745 (patch)
treead14da17e6d0d883e68cc6eacc99ae522036dda8 /src/kernel/fs/vfs.c
parentfd4f0a11126a20e75d72f8f2e6d418598fd5f37d (diff)
parent40a214f3c69a3d7da8c2f9bed5038dfa0ab72d4b (diff)
Merged pull request usermode
Added usermode
Diffstat (limited to 'src/kernel/fs/vfs.c')
-rw-r--r--src/kernel/fs/vfs.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/kernel/fs/vfs.c b/src/kernel/fs/vfs.c
new file mode 100644
index 0000000..5591a60
--- /dev/null
+++ b/src/kernel/fs/vfs.c
@@ -0,0 +1,43 @@
+#include <kernel/fs/vfs.h>
+
+fs_node_t *fs_root = 0;
+
+uint32_t read_fs(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer) {
+ if (node->read != 0)
+ return node->read(node, offset, size, buffer);
+ else
+ return 0;
+}
+
+uint32_t write_fs(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer) {
+ if (node->write != 0)
+ return node->write(node, offset, size, buffer);
+ else
+ return 0;
+}
+
+void open_fs(fs_node_t *node, uint8_t read, uint8_t write) {
+ if (node->open != 0)
+ return node->open(node);
+}
+
+void close_fs(fs_node_t *node) {
+ if (node->close != 0)
+ return node->close(node);
+}
+
+struct dirent *readdir_fs(fs_node_t *node, uint32_t index) {
+ if ((node->flags & 0x7) == FS_DIRECTORY &&
+ node->readdir != 0)
+ return node->readdir(node, index);
+ else
+ return 0;
+}
+
+fs_node_t *finddir_fs(fs_node_t *node, char *name) {
+ if ((node->flags & 0x7) == FS_DIRECTORY &&
+ node->finddir != 0)
+ return node->finddir(node, name);
+ else
+ return 0;
+}