aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/fs/vfs.c
diff options
context:
space:
mode:
authorMarvin Borner2020-04-30 20:27:06 +0200
committerMarvin Borner2020-04-30 20:27:06 +0200
commit6c5e31b1e5534748f89233cdebf778247b040cbc (patch)
treed85b9c4905ad7c6d56c29133bca9b9cc2eb28159 /src/kernel/fs/vfs.c
parent8b52d7698e4a9a5abaf730c7da1c4f865cb78f8e (diff)
Started vfs
Diffstat (limited to 'src/kernel/fs/vfs.c')
-rw-r--r--src/kernel/fs/vfs.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/kernel/fs/vfs.c b/src/kernel/fs/vfs.c
new file mode 100644
index 0000000..98ec6fb
--- /dev/null
+++ b/src/kernel/fs/vfs.c
@@ -0,0 +1,49 @@
+#include <stdint.h>
+#include <stddef.h>
+#include <kernel/fs/vfs.h>
+
+struct fs_node *fs_root = NULL;
+
+uint32_t fs_read(struct fs_node *node, uint32_t offset, uint32_t size, char *buf)
+{
+ if (node->read != NULL)
+ return node->read(node, offset, size, buf);
+ else
+ return 0;
+}
+
+uint32_t fs_write(struct fs_node *node, uint32_t offset, uint32_t size, char *buf)
+{
+ if (node->write != NULL)
+ return node->write(node, offset, size, buf);
+ else
+ return 0;
+}
+
+void fs_open(struct fs_node *node)
+{
+ if (node->open != NULL)
+ node->open(node);
+}
+
+void fs_close(struct fs_node *node)
+{
+ if (node->close != NULL)
+ node->close(node);
+}
+
+struct dirent *fs_read_directory(struct fs_node *node, uint32_t index)
+{
+ if ((node->type & DIR_NODE) != 0 && node->find_dir != NULL)
+ return node->read_dir(node, index);
+ else
+ return (struct dirent *)NULL;
+}
+
+struct fs_node *fs_find_directory(struct fs_node *node, char *name)
+{
+ if ((node->type & DIR_NODE) != 0 && node->find_dir != NULL)
+ return node->find_dir(node, name);
+ else
+ return (struct fs_node *)NULL;
+} \ No newline at end of file