Mercurial > lcfOS
annotate cos/kernel/fs.c @ 220:3f6c30a5d234
Major change in expression parsing to enable pointers and structs
author | Windel Bouwman |
---|---|
date | Sat, 06 Jul 2013 21:32:20 +0200 |
parents | 3a6a9b929db0 |
children |
rev | line source |
---|---|
32
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
1 |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
2 #include "kernel.h" |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
3 |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
4 uint64_t read_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
5 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
6 if (node->read != 0) |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
7 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
8 return node->read(node, offset, size, buffer); |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
9 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
10 else |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
11 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
12 return 0; |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
13 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
14 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
15 |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
16 uint64_t write_fs(fs_node_t *node, uint64_t offset, uint64_t size, uint8_t *buffer) |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
17 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
18 if (node->write != 0) |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
19 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
20 return node->write(node, offset, size, buffer); |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
21 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
22 else |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
23 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
24 return 0; |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
25 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
26 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
27 |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
28 void open_fs(fs_node_t *node) |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
29 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
30 if (node->open != 0) |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
31 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
32 node->open(node); |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
33 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
34 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
35 |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
36 void close_fs(fs_node_t *node) |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
37 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
38 if (node->close != 0) |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
39 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
40 node->close(node); |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
41 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
42 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
43 |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
44 // TODO: why not return an fs_node_t* ? |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
45 fs_dirent_t* readdir_fs(fs_node_t *node, int i) |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
46 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
47 if (node->readdir != 0) |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
48 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
49 return node->readdir(node, i); |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
50 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
51 else |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
52 { |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
53 return 0; |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
54 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
55 } |
3a6a9b929db0
Added initial ramdisk and some virtual file system functions
windel
parents:
diff
changeset
|
56 |