blob: 4a584ebf0212507abfb3f4bc89b04f43566427f6 [file] [log] [blame]
swissChili8efa4922021-03-02 16:34:49 -08001#include "vfs.h"
2
swissChili6c0519e2021-03-07 19:40:23 -08003struct fs_node root, dev, initrd;
4
swissChili8efa4922021-03-02 16:34:49 -08005uint 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
13uint 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
21void 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
29void 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
37struct 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
45struct 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}
swissChili6c0519e2021-03-07 19:40:23 -080052
53struct fs_dirent *root_readdir(struct fs_node *node, uint index)
54{
55
56}
57
58void init_vfs()
59{
60}