aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/fs/vfs.c
blob: 6471f1b618278fa387f5beae79e57f85349d33be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stddef.h>
#include <kernel/fs/vfs.h>

struct fs_node *fs_root = NULL;

uint32_t read_fs_node(struct fs_node *node, size_t offset, size_t size, char *buf)
{
	if (node->read != NULL)
		return node->read(node, offset, size, buf);
	else
		return 0;
}

uint32_t write_fs_node(struct fs_node *node, size_t offset, size_t size, char *buf)
{
	if (node->write != NULL)
		return node->write(node, offset, size, buf);
	else
		return 0;
}

void open_fs_node(struct fs_node *node, bool read, bool write)
{
	if (node->open != NULL)
		node->open(node);
}

void close_fs_node(struct fs_node *node)
{
	if (node->close != NULL)
		node->close(node);
}

struct dir_entry *read_dir_node(struct fs_node *node, size_t index)
{
	if ((node->type & DIR_NODE) != 0 && node->read_dir != NULL)
		return node->read_dir(node, index);
	else
		return NULL;
}

struct fs_node *find_dir_node(struct fs_node *node, char *name)
{
	if ((node->type & DIR_NODE) != 0 && node->find_dir != NULL)
		return node->find_dir(node, name);
	else
		return NULL;
}