aboutsummaryrefslogtreecommitdiff
path: root/kernel/filesystem/include
diff options
context:
space:
mode:
authorLukas Oesch <lukasoesch20@gmail.com>2026-03-11 18:15:54 +0100
committerLukas Oesch <lukasoesch20@gmail.com>2026-03-17 16:42:53 +0100
commit22a32e2ab9fcb779a7359cec9b0244f262661288 (patch)
tree8e76bb110bf821fe4ddf093a8776716b917d5f8c /kernel/filesystem/include
parent7430778a773cfdb97bed3c77c17f7c737706ba6a (diff)
downloadteachos-22a32e2ab9fcb779a7359cec9b0244f262661288.tar.xz
teachos-22a32e2ab9fcb779a7359cec9b0244f262661288.zip
use optional instead of pointer, improve error handling (do not just panic, return std::nullopt)
Diffstat (limited to 'kernel/filesystem/include')
-rw-r--r--kernel/filesystem/include/filesystem/file_descriptor_table.hpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/filesystem/include/filesystem/file_descriptor_table.hpp b/kernel/filesystem/include/filesystem/file_descriptor_table.hpp
index a865d32..44fd428 100644
--- a/kernel/filesystem/include/filesystem/file_descriptor_table.hpp
+++ b/kernel/filesystem/include/filesystem/file_descriptor_table.hpp
@@ -4,6 +4,7 @@
#include "open_file_description.hpp"
#include <array>
+#include <optional>
namespace filesystem
{
@@ -15,13 +16,15 @@ namespace filesystem
~file_descriptor_table() = default;
auto add_file(open_file_description & f) -> int;
- auto get_file(int fd) -> open_file_description &;
+ auto get_file(int fd) -> std::optional<open_file_description>;
auto remove_file(int fd) -> void;
private:
file_descriptor_table() = default;
- std::array<open_file_description *, 32> m_open_files{}; // TODO BA-FS26 use kstd::vector when available
+ // 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{};
};
} // namespace filesystem