Mercurial > lcfOS
diff cos/kernel/fs.c @ 32:3a6a9b929db0
Added initial ramdisk and some virtual file system functions
author | windel |
---|---|
date | Fri, 13 Jan 2012 18:18:17 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cos/kernel/fs.c Fri Jan 13 18:18:17 2012 +0100 @@ -0,0 +1,56 @@ + +#include "kernel.h" + +uint64_t read_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) +{ + if (node->read != 0) + { + return node->read(node, offset, size, buffer); + } + else + { + return 0; + } +} + +uint64_t write_fs(fs_node_t *node, uint64_t offset, uint64_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) +{ + if (node->open != 0) + { + node->open(node); + } +} + +void close_fs(fs_node_t *node) +{ + if (node->close != 0) + { + node->close(node); + } +} + +// TODO: why not return an fs_node_t* ? +fs_dirent_t* readdir_fs(fs_node_t *node, int i) +{ + if (node->readdir != 0) + { + return node->readdir(node, i); + } + else + { + return 0; + } +} +