From 6c5e31b1e5534748f89233cdebf778247b040cbc Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 30 Apr 2020 20:27:06 +0200 Subject: Started vfs --- src/kernel/fs/vfs.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/kernel/fs/vfs.c (limited to 'src/kernel/fs/vfs.c') 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 +#include +#include + +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 -- cgit v1.2.3