blob: 59ccaf5b07bf334e25b93f1bba14161e54eb66e7 [file] [log] [blame]
swissChili8efa4922021-03-02 16:34:49 -08001#include "vfs.h"
2
3uint fs_read(struct fs_node *node, size_t offset, size_t size, uchar *buffer)
4{
5 if (!node || !node->vtable || !node->vtable->read)
6 return 0;
7
8 return node->vtable->read(node, offset, size, buffer);
9}
10
11uint fs_write(struct fs_node *node, size_t offset, size_t size, uchar *buffer)
12{
13 if (!node || !node->vtable || !node->vtable->write)
14 return 0;
15
16 return node->vtable->write(node, offset, size, buffer);
17}
18
19void fs_open(struct fs_node *node)
20{
21 if (!node || !node->vtable || !node->vtable->open)
22 return;
23
24 node->vtable->open(node);
25}
26
27void fs_close(struct fs_node *node)
28{
29 if (!node || !node->vtable || !node->vtable->close)
30 return;
31
32 node->vtable->close(node);
33}
34
35struct fs_dirent *fs_readdir(struct fs_node *node, uint index)
36{
37 if (!node || !node->vtable || !node->vtable->readdir || (node->flags & 7) != FS_DIRECTORY)
38 return NULL;
39
40 return node->vtable->readdir(node, index);
41}
42
43struct fs_node *fs_finddir(struct fs_node *node, char *name)
44{
45 if (!node || !node->vtable || !node->vtable->finddir || (node->flags & 7) != FS_DIRECTORY)
46 return NULL;
47
48 return node->vtable->finddir(node, name);
49}