// This file is part of noxos and licensed under the MIT open source license #ifndef NOX_VFS_H #define NOX_VFS_H #include "utils/stdtypes.h" #include "utils/string.h" #include "boot/boot_info.h" #define VFS_MAX_NAME_LENGTH 128 typedef struct vfs_node_T vfs_node_T; typedef enum { FS_RAMFS, FS_ENUM_END } fs_type_E; typedef enum { VFS_NODE_DIRECTORY, VFS_NODE_FILE, VFS_NODE_MOUNT, VFS_NODE_BLOCK_DEVICE, VFS_NODE_ENUM_END } vfs_node_type_E; typedef struct { fs_type_E type; vfs_node_T* root_node; } fs_T; typedef struct { void* buffer; uint64_t buffer_size; bool reclaimable; vfs_node_T* node; } vfs_node_cache_T; struct vfs_node_T{ char name[VFS_MAX_NAME_LENGTH]; vfs_node_type_E type; vfs_node_cache_T* cache; uint64_t size; void* specific; fs_T* filesystem; vfs_node_T* prev; vfs_node_T* next; vfs_node_T* parent; vfs_node_T* childs; }; extern fs_T g_root_fs; vfs_node_cache_T* vfs_node_cache_create (vfs_node_T* node, uint64_t size); void vfs_node_cache_destruct (vfs_node_cache_T* node_cache); vfs_node_T* vfs_node_create (vfs_node_T* parent, string_t name, vfs_node_type_E type, void* specific); void vfs_node_destruct (vfs_node_T* node); void vfs_node_delete (vfs_node_T* node); void vfs_node_dump_info (vfs_node_T* node, uint64_t indent); vfs_node_T* vfs_node_resolve_child (vfs_node_T* node, string_t child_name); vfs_node_T* vfs_file_create (fs_T* filesystem, string_t path); void vfs_file_delete (vfs_node_T* file); void vfs_file_write (vfs_node_T* file, uint64_t position, uint64_t size, uint8_t* buffer_in); void vfs_file_read (vfs_node_T* file, uint64_t position, uint64_t size, uint8_t* buffer_out); vfs_node_T* vfs_directory_create (fs_T* filesystem, string_t path); void vfs_directory_delete (vfs_node_T* directory); void vfs_init (boot_info_T* boot_info); vfs_node_T* vfs_resolve_path (fs_T* filesystem, string_t path); void vfs_unpack_archive_ustar (fs_T* filesystem, void* archive); #endif //NOX_VFS_H