Blame
|
1 | # Filesystem Layer |
||||||
| 2 | ||||||||
| 3 | ```mermaid |
|||||||
|
4 | --- |
||||||
|
5 | title: Filesystem Structures |
||||||
|
6 | --- |
||||||
| 7 | classDiagram |
|||||||
|
8 | class vmp_t{ |
||||||
|
9 | block_device-t *dev_driver |
||||||
| 10 | vfs_fs_t *fs_driver |
|||||||
| 11 | char name[16] |
|||||||
| 12 | uint8_t block_buff[BLOCK_DEVICE_BLOCK_SIZE] |
|||||||
| 13 | unsigned int mounted : 1 |
|||||||
| 14 | unsigned int read_only : 1 |
|||||||
| 15 | uint8_t subdev |
|||||||
| 16 | union fs_data |
|||||||
|
17 | } |
||||||
| 18 | class block_device_t { |
|||||||
|
19 | bool_t active |
||||||
| 20 | char name[16] |
|||||||
| 21 | uint8_t num_sub_devices |
|||||||
|
22 | |||||||
|
23 | int (*init)(block_device_t *dev) |
||||||
| 24 | int (*finish)(void) |
|||||||
|
25 | |||||||
|
26 | int (*read_block)(uint32_t block_num, uint8_t *buff, uint8_t subdev) |
||||||
| 27 | int (*write_block)(uint32_t block_num, uint8_t *buff, uint8_t subdev) |
|||||||
|
28 | |||||||
|
29 | void *driver_data |
||||||
|
30 | } |
||||||
|
31 | class vfs_fs_t { |
||||||
|
32 | uint8_t type |
||||||
| 33 | int (*handles_path)(const char *pathname) |
|||||||
| 34 | char *name |
|||||||
| 35 | block_device_t *dev |
|||||||
| 36 | vfs_t api |
|||||||
|
37 | } |
||||||
|
38 | class fs_data <<union>> { |
||||||
|
39 | ext2_fs_t e2fs |
||||||
|
40 | } |
||||||
|
41 | |||||||
|
42 | class vfile_t { |
||||||
| 43 | char path[PATH_MAX] |
|||||||
| 44 | bool_t open |
|||||||
| 45 | vmp_t *mp |
|||||||
| 46 | union file_fs_data |
|||||||
| 47 | } |
|||||||
| 48 | class file_fs_data <<union>> { |
|||||||
|
49 | ext2_file_t e2dir |
||||||
|
50 | } |
||||||
|
51 | class vfs.fs { |
||||||
| 52 | vmp_t *(*mount)(vmp_t *mp) |
|||||||
| 53 | int (*unmount)(vmp_t *mp) |
|||||||
| 54 | int (*open)(vfile_t *pwd, const char *fname) |
|||||||
| 55 | int (*read)(vfile_t *file, char *buf, size_t n_bytes) |
|||||||
| 56 | int (*write)(vfile_t *file, const char *buf, size_t n_bytes) |
|||||||
| 57 | int (*close)(vfile_t *file) |
|||||||
| 58 | } |
|||||||
| 59 | class vfs.chardev { |
|||||||
| 60 | ||||||||
| 61 | } |
|||||||
|
62 | |||||||
|
63 | block_device_t <|-- vmp_t |
||||||
|
64 | vfs_fs_t <|-- vmp_t |
||||||
|
65 | file_fs_data <|-- vfile_t |
||||||
|
66 | |||||||
|
67 | ``` |
||||||
|
68 | |||||||
| 69 | Another attempt: |
|||||||
| 70 | ```mermaid |
|||||||
|
71 | erDiagram |
||||||
|
72 | direction BT |
||||||
|
73 | vmp_t:::fs ||--|| ORDER : places |
||||||
|
74 | vmp_t { |
||||||
|
75 | block_device-t *dev_driver |
||||||
| 76 | vfs_fs_t *fs_driver |
|||||||
|
77 | char name[16] |
||||||
| 78 | uint8_t block_buff[BLOCK_DEVICE_BLOCK_SIZE] |
|||||||
| 79 | unsigned int mounted |
|||||||
| 80 | unsigned int read_only |
|||||||
|
81 | uint8_t subdev |
||||||
| 82 | union fs_data |
|||||||
|
83 | } |
||||||
| 84 | ORDER { |
|||||||
|
85 | int orderNumber |
||||||
|
86 | string deliveryAddress |
||||||
|
87 | } |
||||||
|
88 | vfile_t { |
||||||
| 89 | char path[PATH_MAX] |
|||||||
| 90 | bool_t open |
|||||||
| 91 | vmp_t *mp |
|||||||
| 92 | union file_fs_data |
|||||||
| 93 | } |
|||||||
|
94 | |||||||
|
95 | classDef fs fill:#08d,stroke:#333,stroke-width:4px |
||||||
|
96 | ``` |
||||||
|
97 | > [!NOTE] |
||||||
| 98 | > This diagram is evolving as I am in the process of implementing |
|||||||
| 99 | > the code for this. Anything could change, so come back often. |
|||||||