aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/fs/vfs.c
diff options
context:
space:
mode:
authorMarvin Borner2020-04-21 14:18:20 +0200
committerMarvin Borner2020-04-21 14:18:20 +0200
commit40b98b3eb3f897d3d12199c79b30e2fd9151baf9 (patch)
tree0f10c78c95bd24a4b5cef2a3948dd3abbc1a4eb7 /src/kernel/fs/vfs.c
parentc83104329214bd618444d6e0242bb0317f52dbbc (diff)
Added very basic vfs
Diffstat (limited to 'src/kernel/fs/vfs.c')
-rw-r--r--src/kernel/fs/vfs.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/kernel/fs/vfs.c b/src/kernel/fs/vfs.c
new file mode 100644
index 0000000..075117e
--- /dev/null
+++ b/src/kernel/fs/vfs.c
@@ -0,0 +1,48 @@
+#include <stddef.h>
+#include <kernel/fs/vfs.h>
+
+struct fs_node *fs_root = NULL;
+
+uint32_t read_fs_node(struct fs_node *node, size_t offset, size_t size, char *buf)
+{
+ if (node->read != NULL)
+ return node->read(node, offset, size, buf);
+ else
+ return 0;
+}
+
+uint32_t write_fs_node(struct fs_node *node, size_t offset, size_t size, char *buf)
+{
+ if (node->write != NULL)
+ return node->write(node, offset, size, buf);
+ else
+ return 0;
+}
+
+void open_fs_node(struct fs_node *node, bool read, bool write)
+{
+ if (node->open != NULL)
+ node->open(node);
+}
+
+void close_fs_node(struct fs_node *node)
+{
+ if (node->close != NULL)
+ node->close(node);
+}
+
+struct dir_entry *read_dir_node(struct fs_node *node, size_t index)
+{
+ if ((node->type & DIR_NODE) != 0 && node->read_dir != NULL)
+ return node->read_dir(node, index);
+ else
+ return NULL;
+}
+
+struct fs_node *find_dir_node(struct fs_node *node, char *name)
+{
+ if ((node->type & DIR_NODE) != 0 && node->find_dir != NULL)
+ return node->find_dir(node, name);
+ else
+ return NULL;
+}