diff options
| author | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-17 11:49:13 +0100 |
|---|---|---|
| committer | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-17 16:44:35 +0100 |
| commit | 5801be615a50bf465a9663b7f75cafbcf0870f5c (patch) | |
| tree | e3a6df2863ba9b6b24c76219bc685975be5e69d3 | |
| parent | 471888c64ed490b1f1dbaa2c2f67a1e8d315905a (diff) | |
| download | teachos-5801be615a50bf465a9663b7f75cafbcf0870f5c.tar.xz teachos-5801be615a50bf465a9663b7f75cafbcf0870f5c.zip | |
use kstd::vector instead of std::array and replace plain-pointers with kstd::shared_ptr
29 files changed, 160 insertions, 154 deletions
diff --git a/kapi/include/kapi/boot_module/boot_module_registry.hpp b/kapi/include/kapi/boot_module/boot_module_registry.hpp index eeb01ff..70b5592 100644 --- a/kapi/include/kapi/boot_module/boot_module_registry.hpp +++ b/kapi/include/kapi/boot_module/boot_module_registry.hpp @@ -3,7 +3,8 @@ #include "kapi/boot_module/boot_module.hpp" -#include <array> +#include <kstd/vector> + #include <cstddef> namespace kapi::boot_modules @@ -15,15 +16,13 @@ namespace kapi::boot_modules // ! providing access to them for the rest of the kernel. struct boot_module_registry { - using range_type = std::array<boot_module, 1>; // TODO BA-FS26 use kstd::vector when available - + using range_type = kstd::vector<boot_module>; using value_type = range_type::value_type; using const_reference = range_type::const_reference; - using const_iterator = range_type::const_iterator; - using const_reverse_iterator = range_type::const_reverse_iterator; + using const_iterator = range_type::const_pointer; + using const_reverse_iterator = range_type::const_pointer; using size_type = range_type::size_type; - using difference_type = range_type::difference_type; [[nodiscard]] auto begin() const noexcept -> const_iterator { @@ -97,7 +96,7 @@ namespace kapi::boot_modules auto add_boot_module(boot_module module) -> void { - m_modules.at(0) = module; // TODO BA-FS26 push back when kstd::vector is available + m_modules.push_back(module); } private: diff --git a/kernel/devices/include/devices/storage/ram_disk/ram_disk_device.hpp b/kernel/devices/include/devices/storage/ram_disk/ram_disk_device.hpp index 678ee99..1edf48c 100644 --- a/kernel/devices/include/devices/storage/ram_disk/ram_disk_device.hpp +++ b/kernel/devices/include/devices/storage/ram_disk/ram_disk_device.hpp @@ -14,8 +14,6 @@ namespace devices::storage::ram_disk */ struct ram_disk_device : block_device { - ram_disk_device(); // TODO BA-FS26 remove when kstd::vector is available - /** * @brief Create a RAM disk for the @p module. * @param module Boot module providing the memory region. diff --git a/kernel/devices/include/devices/storage/storage_controller.hpp b/kernel/devices/include/devices/storage/storage_controller.hpp index d10d27d..e90b01c 100644 --- a/kernel/devices/include/devices/storage/storage_controller.hpp +++ b/kernel/devices/include/devices/storage/storage_controller.hpp @@ -3,7 +3,9 @@ #include "devices/device.hpp" -#include <array> +#include <kstd/memory> +#include <kstd/vector> + #include <cstddef> namespace devices::storage @@ -46,8 +48,7 @@ namespace devices::storage [[nodiscard]] auto devices_count() const -> size_t; // TODO BA-FS26 add comment - // TODO BA-FS26 use kstd::vector when available - [[nodiscard]] auto all_devices() const -> std::array<devices::device *, 1> const &; + [[nodiscard]] auto all_devices() const -> kstd::vector<kstd::shared_ptr<devices::device>> const &; /** * @brief Find a managed device by major/minor numbers. @@ -55,12 +56,12 @@ namespace devices::storage * @param minor Device minor number. * @return Matching block device, or nullptr if no device matches. */ - [[nodiscard]] auto device_by_minor(size_t minor) const -> device *; + [[nodiscard]] auto device_by_minor(size_t minor) const -> kstd::shared_ptr<devices::device>; protected: size_t m_major{}; size_t m_minors_per_device{}; - std::array<devices::device *, 1> m_devices{}; // TODO BA-FS26 use kstd::vector when available + kstd::vector<kstd::shared_ptr<devices::device>> m_devices{}; }; } // namespace devices::storage diff --git a/kernel/devices/include/devices/storage/storage_management.hpp b/kernel/devices/include/devices/storage/storage_management.hpp index 550db65..dc2f6c9 100644 --- a/kernel/devices/include/devices/storage/storage_management.hpp +++ b/kernel/devices/include/devices/storage/storage_management.hpp @@ -4,7 +4,9 @@ #include "devices/device.hpp" #include "devices/storage/storage_controller.hpp" -#include <array> +#include <kstd/memory> +#include <kstd/vector> + #include <cstddef> namespace devices::storage @@ -40,11 +42,10 @@ namespace devices::storage * * Assigns controller IDs (major number range and minors per device). */ - auto add_controller(storage_controller * controller) -> void; + auto add_controller(kstd::shared_ptr<storage_controller> controller) -> void; // TODO BA-FS26 add comment - // TODO BA-FS26 use kstd::vector when available - [[nodiscard]] auto all_controllers() const -> std::array<storage_controller *, 1> const &; + [[nodiscard]] auto all_controllers() const -> kstd::vector<kstd::shared_ptr<storage_controller>> const &; /** * @brief Find a device by major/minor numbers. @@ -52,13 +53,13 @@ namespace devices::storage * @param minor Device minor number. * @return Matching device, or nullptr if no device matches. */ - auto device_by_major_minor(size_t major, size_t minor) -> device *; + auto device_by_major_minor(size_t major, size_t minor) -> kstd::shared_ptr<device>; /** * @brief Determine the boot device. * @return Boot device, or nullptr if it cannot be determined. */ - auto determine_boot_device() -> device *; + auto determine_boot_device() -> kstd::shared_ptr<device>; private: /** @@ -66,7 +67,7 @@ namespace devices::storage */ storage_management() = default; - std::array<storage_controller *, 1> m_controllers{}; // TODO BA-FS26 use kstd::vector when available + kstd::vector<kstd::shared_ptr<storage_controller>> m_controllers{}; }; } // namespace devices::storage diff --git a/kernel/devices/src/storage/ram_disk/ram_disk_controller.cpp b/kernel/devices/src/storage/ram_disk/ram_disk_controller.cpp index b57dcfb..3d14faf 100644 --- a/kernel/devices/src/storage/ram_disk/ram_disk_controller.cpp +++ b/kernel/devices/src/storage/ram_disk/ram_disk_controller.cpp @@ -4,22 +4,14 @@ #include "devices/storage/ram_disk/ram_disk_device.hpp" +#include <kstd/memory> #include <kstd/print> #include <algorithm> -#include <array> #include <cstddef> -#include <optional> namespace devices::storage::ram_disk { - namespace - { - // TODO BA-FS26 @Felix gibts besseren weg (ausser dynamic Memory) - // TODO BA-FS26 remove again, when dynamic memory available - constinit auto static active_ram_disk_device = std::optional<ram_disk_device>{}; - } // namespace - ram_disk_controller::ram_disk_controller(kapi::boot_modules::boot_module_registry const * registry) : m_boot_module_registry(registry) {} @@ -30,10 +22,7 @@ namespace devices::storage::ram_disk std::ranges::for_each(*m_boot_module_registry, [this, ¤t_device_index](auto const & module) { auto const minor = current_device_index++ * m_minors_per_device; - - // TODO BA-FS26 use push_back from kstd::vector when available - active_ram_disk_device.emplace(module, m_major, minor); - m_devices.at(0) = &*active_ram_disk_device; + m_devices.push_back(kstd::make_shared<ram_disk_device>(module, m_major, minor)); }); } } // namespace devices::storage::ram_disk
\ No newline at end of file diff --git a/kernel/devices/src/storage/ram_disk/ram_disk_device.cpp b/kernel/devices/src/storage/ram_disk/ram_disk_device.cpp index 774e949..6ff2a83 100644 --- a/kernel/devices/src/storage/ram_disk/ram_disk_device.cpp +++ b/kernel/devices/src/storage/ram_disk/ram_disk_device.cpp @@ -28,10 +28,6 @@ namespace devices::storage::ram_disk } } // namespace - ram_disk_device::ram_disk_device() // TODO BA-FS26 remove when kstd::vector is available - : block_device(0, 0, determine_device_name(0), RAM_DISK_BLOCK_SIZE) - {} - ram_disk_device::ram_disk_device(kapi::boot_modules::boot_module const & module, size_t major, size_t minor) : block_device(major, minor, determine_device_name(minor), RAM_DISK_BLOCK_SIZE) , m_boot_module(module) diff --git a/kernel/devices/src/storage/storage_controller.cpp b/kernel/devices/src/storage/storage_controller.cpp index d9bc806..16d40f4 100644 --- a/kernel/devices/src/storage/storage_controller.cpp +++ b/kernel/devices/src/storage/storage_controller.cpp @@ -2,8 +2,10 @@ #include "devices/device.hpp" +#include <kstd/memory> +#include <kstd/vector> + #include <algorithm> -#include <array> #include <cstddef> namespace devices::storage @@ -19,7 +21,7 @@ namespace devices::storage return m_major; } - auto storage_controller::device_by_minor(size_t minor) const -> device * + auto storage_controller::device_by_minor(size_t minor) const -> kstd::shared_ptr<devices::device> { auto it = std::ranges::find_if(m_devices, [minor](auto const & device) { return device->minor() == minor; }); @@ -35,7 +37,7 @@ namespace devices::storage return m_devices.size(); } - auto storage_controller::all_devices() const -> std::array<devices::device *, 1> const & + auto storage_controller::all_devices() const -> kstd::vector<kstd::shared_ptr<devices::device>> const & { return m_devices; } diff --git a/kernel/devices/src/storage/storage_management.cpp b/kernel/devices/src/storage/storage_management.cpp index e1f1bcc..00449fb 100644 --- a/kernel/devices/src/storage/storage_management.cpp +++ b/kernel/devices/src/storage/storage_management.cpp @@ -7,8 +7,10 @@ #include "devices/storage/ram_disk/ram_disk_controller.hpp" #include "devices/storage/storage_controller.hpp" +#include <kstd/memory> +#include <kstd/vector> + #include <algorithm> -#include <array> #include <cstddef> #include <optional> @@ -21,8 +23,6 @@ namespace devices::storage constinit size_t static next_free_major = START_MAJOR; constinit auto static active_storage_management = std::optional<storage_management>{}; - // TODO BA-FS26 remove again, when dynamic memory available - constinit auto static active_ram_disk_controller = std::optional<ram_disk::ram_disk_controller>{}; } // namespace auto storage_management::init() -> void @@ -33,8 +33,9 @@ namespace devices::storage } active_storage_management.emplace(storage_management{}); - active_ram_disk_controller.emplace(&kapi::boot_modules::get_boot_module_registry()); - active_storage_management->add_controller(&active_ram_disk_controller.value()); + auto current_ram_disk_controller = + kstd::make_shared<ram_disk::ram_disk_controller>(&kapi::boot_modules::get_boot_module_registry()); + active_storage_management->add_controller(current_ram_disk_controller); std::ranges::for_each(active_storage_management->m_controllers, [](auto controller) { controller->probe(); }); } @@ -49,22 +50,22 @@ namespace devices::storage return *active_storage_management; } - auto storage_management::add_controller(storage_controller * controller) -> void + auto storage_management::add_controller(kstd::shared_ptr<storage_controller> controller) -> void { controller->set_ids(next_free_major++, MINORS_PER_DEVICE); - m_controllers.at(0) = controller; // TODO BA-FS26 use push_back from kstd:vector + m_controllers.push_back(controller); } - auto storage_management::all_controllers() const -> std::array<storage_controller *, 1> const & + auto storage_management::all_controllers() const -> kstd::vector<kstd::shared_ptr<storage_controller>> const & { return m_controllers; } - auto storage_management::device_by_major_minor(size_t major, size_t minor) -> device * + auto storage_management::device_by_major_minor(size_t major, size_t minor) -> kstd::shared_ptr<device> { - device * found = nullptr; + kstd::shared_ptr<device> found = nullptr; - std::ranges::find_if(m_controllers, [&](auto const controller) { + std::ranges::find_if(m_controllers, [&](auto const & controller) { if (controller != nullptr && controller->major() == major) { found = controller->device_by_minor(minor); @@ -76,7 +77,7 @@ namespace devices::storage return found; } - auto storage_management::determine_boot_device() -> device * + auto storage_management::determine_boot_device() -> kstd::shared_ptr<device> { return device_by_major_minor(START_MAJOR, 0); } diff --git a/kernel/filesystem/include/filesystem/custody.hpp b/kernel/filesystem/include/filesystem/custody.hpp index 9ee984d..b6eae22 100644 --- a/kernel/filesystem/include/filesystem/custody.hpp +++ b/kernel/filesystem/include/filesystem/custody.hpp @@ -3,18 +3,20 @@ #include "filesystem/inode.hpp" +#include <kstd/memory> + namespace filesystem { struct custody { - custody(custody * parent, inode * node); + custody(kstd::shared_ptr<custody> parent, kstd::shared_ptr<inode> node); - [[nodiscard]] auto get_inode() const -> inode *; - [[nodiscard]] auto get_parent() const -> custody *; + [[nodiscard]] auto get_inode() const -> kstd::shared_ptr<inode>; + [[nodiscard]] auto get_parent() const -> kstd::shared_ptr<custody>; private: - custody * m_parent; - inode * m_inode; + kstd::shared_ptr<custody> m_parent; + kstd::shared_ptr<inode> m_inode; }; } // namespace filesystem diff --git a/kernel/filesystem/include/filesystem/device_file.hpp b/kernel/filesystem/include/filesystem/device_file.hpp index 033317b..4dce37f 100644 --- a/kernel/filesystem/include/filesystem/device_file.hpp +++ b/kernel/filesystem/include/filesystem/device_file.hpp @@ -5,13 +5,15 @@ #include "devices/device.hpp" #include "filesystem/file.hpp" +#include <kstd/memory> + #include <cstddef> namespace filesystem { struct device_file : file { - explicit device_file(devices::device * device); + explicit device_file(kstd::shared_ptr<devices::device> device); auto open() -> void override; @@ -23,7 +25,7 @@ namespace filesystem std::byte * scratch, void * buffer); auto process_blocks(size_t offset, size_t size, void * buffer, block_op op) const -> size_t; - devices::device * m_device; + kstd::shared_ptr<devices::device> m_device; }; } // namespace filesystem diff --git a/kernel/filesystem/include/filesystem/ext2/ext2_filesystem.hpp b/kernel/filesystem/include/filesystem/ext2/ext2_filesystem.hpp index cba2192..dd52e72 100644 --- a/kernel/filesystem/include/filesystem/ext2/ext2_filesystem.hpp +++ b/kernel/filesystem/include/filesystem/ext2/ext2_filesystem.hpp @@ -5,17 +5,19 @@ #include "filesystem/filesystem.hpp" #include "filesystem/inode.hpp" +#include <kstd/memory> + #include <string_view> namespace filesystem::ext2 { struct ext2_filesystem : filesystem { - auto mount(devices::device * device) -> int override; + auto mount(kstd::shared_ptr<devices::device> device) -> int override; auto lookup(inode const & parent, std::string_view name) -> inode * override; private: - devices::device * m_device{}; + kstd::shared_ptr<devices::device> m_device{}; }; } // namespace filesystem::ext2 diff --git a/kernel/filesystem/include/filesystem/file_descriptor_table.hpp b/kernel/filesystem/include/filesystem/file_descriptor_table.hpp index 3ac03d1..6d78532 100644 --- a/kernel/filesystem/include/filesystem/file_descriptor_table.hpp +++ b/kernel/filesystem/include/filesystem/file_descriptor_table.hpp @@ -3,7 +3,8 @@ #include "open_file_description.hpp" -#include <array> +#include <kstd/vector> + #include <optional> namespace filesystem @@ -23,8 +24,7 @@ namespace filesystem file_descriptor_table() = default; // TODO BA-FS26 use kstd::shared_ptr when available - // TODO BA-FS26 use kstd::vector when available - std::array<std::optional<open_file_description>, 32> m_open_files{}; + kstd::vector<std::optional<open_file_description>> m_open_files{}; }; } // namespace filesystem diff --git a/kernel/filesystem/include/filesystem/filesystem.hpp b/kernel/filesystem/include/filesystem/filesystem.hpp index 8deb336..eabefc0 100644 --- a/kernel/filesystem/include/filesystem/filesystem.hpp +++ b/kernel/filesystem/include/filesystem/filesystem.hpp @@ -4,6 +4,8 @@ #include "devices/device.hpp" #include "filesystem/inode.hpp" +#include <kstd/memory> + #include <string_view> namespace filesystem @@ -12,11 +14,10 @@ namespace filesystem { virtual ~filesystem() = default; - virtual auto mount(devices::device * device) -> int = 0; + virtual auto mount(kstd::shared_ptr<devices::device> device) -> int = 0; virtual auto lookup(inode const & parent, std::string_view name) -> inode * = 0; - [[nodiscard]] auto root_inode() -> inode *; - [[nodiscard]] auto root_inode() const -> inode const *; + [[nodiscard]] auto root_inode() const -> inode const &; protected: inode m_root_inode{}; // TODO BA-FS26 set during mount? diff --git a/kernel/filesystem/include/filesystem/inode.hpp b/kernel/filesystem/include/filesystem/inode.hpp index bceabb6..2b5ee6c 100644 --- a/kernel/filesystem/include/filesystem/inode.hpp +++ b/kernel/filesystem/include/filesystem/inode.hpp @@ -4,6 +4,8 @@ #include "devices/device.hpp" #include "filesystem/inode_metadata.hpp" +#include <kstd/memory> + #include <cstddef> namespace filesystem @@ -12,7 +14,7 @@ namespace filesystem { inode() = default; explicit inode(inode_kind kind); - explicit inode(devices::device * device); + explicit inode(kstd::shared_ptr<devices::device> device); [[nodiscard]] auto metadata() const -> inode_metadata; @@ -22,14 +24,14 @@ namespace filesystem [[nodiscard]] auto is_block_device() const -> bool; [[nodiscard]] auto major_device() const -> size_t; [[nodiscard]] auto minor_device() const -> size_t; - [[nodiscard]] auto backing_device() const -> devices::device *; + [[nodiscard]] auto backing_device() const -> kstd::shared_ptr<devices::device>; auto read(void * buffer, size_t offset, size_t size) const -> size_t; auto write(void const * buffer, size_t offset, size_t size) -> size_t; private: inode_kind m_kind{inode_kind::regular}; - devices::device * m_device{}; + kstd::shared_ptr<devices::device> m_device{}; }; } // namespace filesystem diff --git a/kernel/filesystem/include/filesystem/inode_file.hpp b/kernel/filesystem/include/filesystem/inode_file.hpp index c091280..512f51d 100644 --- a/kernel/filesystem/include/filesystem/inode_file.hpp +++ b/kernel/filesystem/include/filesystem/inode_file.hpp @@ -4,13 +4,15 @@ #include "filesystem/file.hpp" #include "filesystem/inode.hpp" +#include <kstd/memory> + #include <cstddef> namespace filesystem { struct inode_file : file { - explicit inode_file(inode * inode); + explicit inode_file(kstd::shared_ptr<inode> inode); auto open() -> void override; @@ -18,7 +20,7 @@ namespace filesystem auto write(void const * buffer, size_t offset, size_t size) -> size_t override; private: - inode * m_inode; + kstd::shared_ptr<inode> m_inode; }; } // namespace filesystem diff --git a/kernel/filesystem/include/filesystem/mount.hpp b/kernel/filesystem/include/filesystem/mount.hpp index fe5d9cc..f28de74 100644 --- a/kernel/filesystem/include/filesystem/mount.hpp +++ b/kernel/filesystem/include/filesystem/mount.hpp @@ -3,21 +3,22 @@ #include "filesystem/filesystem.hpp" +#include <kstd/memory> + #include <string_view> namespace filesystem { struct mount { - mount() = default; // TODO BA-FS26 remove again when kstd::vector is available and used in vfs - mount(std::string_view const & path, filesystem * fs); + mount(std::string_view const & path, kstd::shared_ptr<filesystem> fs); [[nodiscard]] auto path() const -> std::string_view; - [[nodiscard]] auto get_filesystem() const -> filesystem *; + [[nodiscard]] auto get_filesystem() const -> kstd::shared_ptr<filesystem>; private: std::string_view m_path; - filesystem * m_filesystem{}; + kstd::shared_ptr<filesystem> m_filesystem{}; }; } // namespace filesystem diff --git a/kernel/filesystem/include/filesystem/open_file_description.hpp b/kernel/filesystem/include/filesystem/open_file_description.hpp index 1589196..035b0ee 100644 --- a/kernel/filesystem/include/filesystem/open_file_description.hpp +++ b/kernel/filesystem/include/filesystem/open_file_description.hpp @@ -2,6 +2,7 @@ #define TEACH_OS_KERNEL_FILESYSTEM_OPEN_FILE_DESCRIPTION_HPP #include "file.hpp" +#include <kstd/memory> #include <cstddef> @@ -9,7 +10,7 @@ namespace filesystem { struct open_file_description { - open_file_description(file * file); + open_file_description(kstd::shared_ptr<file> file); ~open_file_description() = default; @@ -17,7 +18,7 @@ namespace filesystem auto write(void const * buffer, size_t size) -> size_t; private: - file * m_file; + kstd::shared_ptr<file> m_file; size_t m_offset; }; diff --git a/kernel/filesystem/include/filesystem/vfs.hpp b/kernel/filesystem/include/filesystem/vfs.hpp index 1d95d4a..9c89044 100644 --- a/kernel/filesystem/include/filesystem/vfs.hpp +++ b/kernel/filesystem/include/filesystem/vfs.hpp @@ -3,11 +3,14 @@ #include "devices/device.hpp" #include "filesystem/custody.hpp" +#include "filesystem/ext2/ext2_filesystem.hpp" #include "filesystem/inode.hpp" #include "filesystem/mount.hpp" #include "filesystem/open_file_description.hpp" -#include <array> +#include <kstd/memory> +#include <kstd/vector> + #include <optional> #include <string_view> @@ -26,17 +29,17 @@ namespace filesystem struct device_node_entry { std::string_view name; - inode node; + kstd::shared_ptr<inode> node; }; vfs() = default; - auto make_device_node(devices::device * device) -> void; + auto make_device_node(kstd::shared_ptr<devices::device> device) -> void; [[nodiscard]] auto resolve_path(std::string_view path) -> std::optional<custody>; + kstd::shared_ptr<ext2::ext2_filesystem> m_root_fs; std::optional<mount> m_root_mount; - std::array<mount, 10> m_mounts; // TODO BA-FS26 remove when kstd::vector is available and used - std::array<std::optional<device_node_entry>, 10> - m_device_nodes; // TODO BA-FS26 use kstd::vector // TODO BA-FS26 remove again, use + // kstd::vector<mount> m_mounts; // TODO BA-FS26 really needed? + kstd::vector<std::optional<device_node_entry>> m_device_nodes; // TODO BA-FS26 remove again, use devtempfs }; } // namespace filesystem diff --git a/kernel/filesystem/src/custody.cpp b/kernel/filesystem/src/custody.cpp index 614e63b..7a58229 100644 --- a/kernel/filesystem/src/custody.cpp +++ b/kernel/filesystem/src/custody.cpp @@ -4,9 +4,11 @@ #include "filesystem/inode.hpp" +#include <kstd/memory> + namespace filesystem { - custody::custody(custody * parent, inode * node) + custody::custody(kstd::shared_ptr<custody> parent, kstd::shared_ptr<inode> node) : m_parent(parent) , m_inode(node) { @@ -16,12 +18,12 @@ namespace filesystem } } - auto custody::get_inode() const -> inode * + auto custody::get_inode() const -> kstd::shared_ptr<inode> { return m_inode; } - auto custody::get_parent() const -> custody * + auto custody::get_parent() const -> kstd::shared_ptr<custody> { return m_parent; } diff --git a/kernel/filesystem/src/device_file.cpp b/kernel/filesystem/src/device_file.cpp index f11638e..882c9b1 100644 --- a/kernel/filesystem/src/device_file.cpp +++ b/kernel/filesystem/src/device_file.cpp @@ -6,14 +6,15 @@ #include "devices/device.hpp" #include <kstd/cstring> +#include <kstd/memory> +#include <kstd/vector> #include <algorithm> -#include <array> #include <cstddef> namespace filesystem { - device_file::device_file(devices::device * device) + device_file::device_file(kstd::shared_ptr<devices::device> device) : m_device(device) { if (!m_device) @@ -90,7 +91,13 @@ namespace filesystem return 0; } - auto * block_dev = static_cast<devices::block_device *>(m_device); + // @Felix rtti not activated why? e.g. dynamic_cast does not work, whats with std::dynamic_pointer_cast + // online: rtti overhead, bad design, ... ? + auto * block_dev = static_cast<devices::block_device *>(m_device.get()); + if (block_dev == nullptr) + { + kapi::system::panic("[FILESYSTEM] device_file: expected block_device."); + } size_t const block_size = block_dev->block_size(); size_t const capacity = block_dev->capacity(); @@ -99,8 +106,7 @@ name |
