# Filesystem Layer ```mermaid --- title: Filesystem Structures --- classDiagram class vmp_t{ block_device-t *dev_driver vfs_fs_t *fs_driver char name[16] uint8_t block_buff[BLOCK_DEVICE_BLOCK_SIZE] unsigned int mounted : 1 unsigned int read_only : 1 uint8_t subdev union fs_data } class block_device_t { bool_t active char name[16] uint8_t num_sub_devices int (*init)(block_device_t *dev) int (*finish)(void) int (*read_block)(uint32_t block_num, uint8_t *buff, uint8_t subdev) int (*write_block)(uint32_t block_num, uint8_t *buff, uint8_t subdev) void *driver_data } class vfs_fs_t { uint8_t type int (*handles_path)(const char *pathname) char *name block_device_t *dev vfs_t api } class fs_data <<union>> { ext2_fs_t e2fs } class vfile_t { char path[PATH_MAX] bool_t open vmp_t *mp union file_fs_data } class file_fs_data <<union>> { ext2_file_t e2dir } class vfs.fs { vmp_t *(*mount)(vmp_t *mp) int (*unmount)(vmp_t *mp) int (*open)(vfile_t *pwd, const char *fname) int (*read)(vfile_t *file, char *buf, size_t n_bytes) int (*write)(vfile_t *file, const char *buf, size_t n_bytes) int (*close)(vfile_t *file) } class vfs.chardev { } block_device_t <|-- vmp_t vfs_fs_t <|-- vmp_t file_fs_data <|-- vfile_t ``` Another attempt: ```mermaid erDiagram direction BT vmp_t:::fs ||--|| ORDER : places vmp_t { block_device-t *dev_driver vfs_fs_t *fs_driver char name[16] uint8_t block_buff[BLOCK_DEVICE_BLOCK_SIZE] unsigned int mounted unsigned int read_only uint8_t subdev union fs_data } ORDER { int orderNumber string deliveryAddress } vfile_t { char path[PATH_MAX] bool_t open vmp_t *mp union file_fs_data } classDef fs fill:#0ce,stroke:#333,stroke-width:4px ``` > [!NOTE] > These diagrams are evolving as I am in the process of implementing > the code for this. Anything could change, so come back often.