swissChili | 8efa492 | 2021-03-02 16:34:49 -0800 | [diff] [blame] | 1 | #include "vfs.h" |
| 2 | |
swissChili | 6c0519e | 2021-03-07 19:40:23 -0800 | [diff] [blame^] | 3 | struct fs_node root, dev, initrd; |
| 4 | |
swissChili | 8efa492 | 2021-03-02 16:34:49 -0800 | [diff] [blame] | 5 | uint fs_read(struct fs_node *node, size_t offset, size_t size, uchar *buffer) |
| 6 | { |
| 7 | if (!node || !node->vtable || !node->vtable->read) |
| 8 | return 0; |
| 9 | |
| 10 | return node->vtable->read(node, offset, size, buffer); |
| 11 | } |
| 12 | |
| 13 | uint fs_write(struct fs_node *node, size_t offset, size_t size, uchar *buffer) |
| 14 | { |
| 15 | if (!node || !node->vtable || !node->vtable->write) |
| 16 | return 0; |
| 17 | |
| 18 | return node->vtable->write(node, offset, size, buffer); |
| 19 | } |
| 20 | |
| 21 | void fs_open(struct fs_node *node) |
| 22 | { |
| 23 | if (!node || !node->vtable || !node->vtable->open) |
| 24 | return; |
| 25 | |
| 26 | node->vtable->open(node); |
| 27 | } |
| 28 | |
| 29 | void fs_close(struct fs_node *node) |
| 30 | { |
| 31 | if (!node || !node->vtable || !node->vtable->close) |
| 32 | return; |
| 33 | |
| 34 | node->vtable->close(node); |
| 35 | } |
| 36 | |
| 37 | struct fs_dirent *fs_readdir(struct fs_node *node, uint index) |
| 38 | { |
| 39 | if (!node || !node->vtable || !node->vtable->readdir || (node->flags & 7) != FS_DIRECTORY) |
| 40 | return NULL; |
| 41 | |
| 42 | return node->vtable->readdir(node, index); |
| 43 | } |
| 44 | |
| 45 | struct fs_node *fs_finddir(struct fs_node *node, char *name) |
| 46 | { |
| 47 | if (!node || !node->vtable || !node->vtable->finddir || (node->flags & 7) != FS_DIRECTORY) |
| 48 | return NULL; |
| 49 | |
| 50 | return node->vtable->finddir(node, name); |
| 51 | } |
swissChili | 6c0519e | 2021-03-07 19:40:23 -0800 | [diff] [blame^] | 52 | |
| 53 | struct fs_dirent *root_readdir(struct fs_node *node, uint index) |
| 54 | { |
| 55 | |
| 56 | } |
| 57 | |
| 58 | void init_vfs() |
| 59 | { |
| 60 | } |