diff options
author | Benji Dial <benji@benjidial.net> | 2024-01-20 17:59:40 -0500 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-01-20 17:59:40 -0500 |
commit | 7199e74aa22e592a3b77bdd81f735edca5470596 (patch) | |
tree | 66e935372acc5d6e013f764965f2a9d81814f809 /include/hilbert/kernel/storage.hpp | |
parent | 53135e2592c21cb9b2609bf95242aaf1f19233da (diff) | |
download | hilbert-os-7199e74aa22e592a3b77bdd81f735edca5470596.tar.gz |
update
Diffstat (limited to 'include/hilbert/kernel/storage.hpp')
-rw-r--r-- | include/hilbert/kernel/storage.hpp | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/include/hilbert/kernel/storage.hpp b/include/hilbert/kernel/storage.hpp deleted file mode 100644 index ea40d86..0000000 --- a/include/hilbert/kernel/storage.hpp +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef HILBERT_KERNEL_STORAGE_HPP -#define HILBERT_KERNEL_STORAGE_HPP - -#include <hilbert/kernel/utility.hpp> -#include <cstdint> - -namespace hilbert::kernel::storage { - - typedef uint64_t node_id_t; - typedef uint64_t directory_iter_t; - - enum class file_type { - regular_file, - directory, - symlink - }; - - enum class bd_result { - success, - out_of_bounds, - device_error - }; - - enum class fs_result { - success, - device_error, - fs_corrupt - }; - - struct dir_entry { - utility::string name; - node_id_t node; - file_type type; - //only used if type is regular_file. - uint64_t length; - //only used if type is symlink. - utility::string target; - }; - - class file_system_instance { - - public: - virtual ~file_system_instance() {} - - virtual fs_result get_root_node(node_id_t &out) = 0; - - //it is assumed that this is a directory. sets iter_out - //to a value that can be passed to subsequent calls - //to get_next_child with the same argument for node. - virtual fs_result get_first_child(node_id_t node, std::optional<dir_entry> &out, directory_iter_t &iter_out) = 0; - - //it is assumed that this is a directory. sets iter_out - //to a value that can be passed to subsequent calls - //to get_next_child with the same argument for node. - virtual fs_result get_next_child(node_id_t node, std::optional<dir_entry> &out, directory_iter_t &iter) = 0; - - //it is assumed that this is a regular file and that - //the region requested is within the bounds of the file. - virtual fs_result read_bytes_from_file(node_id_t node, uint64_t start, uint64_t count, void *into) = 0; - - }; - - class block_device { - - private: - uint8_t *block_cache; - uint64_t block_cache_i; - - //it is assumed that this block is within the bounds of the device. - bd_result load_cache_block(uint64_t i); - - protected: - //implemented in driver. it is assumed that the - //blocks are within the bounds of the device. - virtual bd_result read_blocks_no_cache(uint64_t start, uint64_t count, void *into) = 0; - - //it is assumed that this is only called once, by the driver, after - //block_size and block_count have been set, and before read_bytes or - //write_bytes can be called (e.g. in the derived class's constructor). - void allocate_block_cache(); - - public: - //set by storage component - file_system_instance *mounted_as; - //set by storage component - utility::uuid id; - - //set by driver - uint64_t block_size; - //set by driver - uint64_t block_count; - - virtual ~block_device() { - if (block_cache) - delete block_cache; - } - - bd_result read_bytes(uint64_t start, uint64_t count, void *into); - - }; - -} - -#endif |