diff options
author | Marvin Borner | 2020-04-21 14:18:20 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-21 14:18:20 +0200 |
commit | 40b98b3eb3f897d3d12199c79b30e2fd9151baf9 (patch) | |
tree | 0f10c78c95bd24a4b5cef2a3948dd3abbc1a4eb7 /src/kernel/fs/vfs.h | |
parent | c83104329214bd618444d6e0242bb0317f52dbbc (diff) |
Added very basic vfs
Diffstat (limited to 'src/kernel/fs/vfs.h')
-rw-r--r-- | src/kernel/fs/vfs.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/kernel/fs/vfs.h b/src/kernel/fs/vfs.h new file mode 100644 index 0000000..41d80eb --- /dev/null +++ b/src/kernel/fs/vfs.h @@ -0,0 +1,66 @@ +#ifndef MELVIX_VFS_H +#define MELVIX_VFS_H + +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +#define MAX_NAME_LENGTH 128 + +enum node_type { + FILE_NODE = 1, + DIR_NODE, + CHAR_DEV_NODE, + BLOCK_DEV_NODE, + PIPE_NODE, + SYMLINK_NODE, + MOUNTPOINT_NODE = 8 +}; + +struct fs_node; +struct dir_entry; + +typedef uint32_t (*read)(struct fs_node *, size_t, size_t, char *); +typedef uint32_t (*write)(struct fs_node *, size_t, size_t, char *); +typedef void (*open)(struct fs_node *); +typedef void (*close)(struct fs_node *); + +typedef struct dir_entry *(*read_dir)(struct fs_node *, size_t); +typedef struct fs_node *(*find_dir)(struct fs_node *, char *); + +struct fs_node { + char name[MAX_NAME_LENGTH]; + uint32_t length; + uint32_t inode; + uint32_t permissions; + uint32_t uid; + uint32_t gid; + enum node_type type; + + struct fs_node *node_ptr; + + void *impl; + + read read; + write write; + open open; + close close; + read_dir read_dir; + find_dir find_dir; +}; + +struct dir_entry { + char name[MAX_NAME_LENGTH]; + uint32_t inode; +}; + +struct fs_node *fs_root; + +uint32_t read_fs_node(struct fs_node *node, size_t offset, size_t size, char *buf); +uint32_t write_fs_node(struct fs_node *node, size_t offset, size_t size, char *buf); +void open_fs_node(struct fs_node *node, bool read, bool write); +void close_fs_node(struct fs_node *node); +struct dir_entry *read_dir_node(struct fs_node *node, size_t index); +struct fs_node *find_dir_node(struct fs_node *node, char *name); + +#endif |