comparison 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
comparison
equal deleted inserted replaced
31:88590c42320f 32:3a6a9b929db0
1
2 #include "kernel.h"
3
4 uint64_t read_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer)
5 {
6 if (node->read != 0)
7 {
8 return node->read(node, offset, size, buffer);
9 }
10 else
11 {
12 return 0;
13 }
14 }
15
16 uint64_t write_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer)
17 {
18 if (node->write != 0)
19 {
20 return node->write(node, offset, size, buffer);
21 }
22 else
23 {
24 return 0;
25 }
26 }
27
28 void open_fs(fs_node_t *node)
29 {
30 if (node->open != 0)
31 {
32 node->open(node);
33 }
34 }
35
36 void close_fs(fs_node_t *node)
37 {
38 if (node->close != 0)
39 {
40 node->close(node);
41 }
42 }
43
44 // TODO: why not return an fs_node_t* ?
45 fs_dirent_t* readdir_fs(fs_node_t *node, int i)
46 {
47 if (node->readdir != 0)
48 {
49 return node->readdir(node, i);
50 }
51 else
52 {
53 return 0;
54 }
55 }
56