aboutsummaryrefslogtreecommitdiff
path: root/kernel/filesystem/include
diff options
context:
space:
mode:
authorLukas Oesch <lukasoesch20@gmail.com>2026-03-15 20:37:14 +0100
committerLukas Oesch <lukasoesch20@gmail.com>2026-03-17 16:43:15 +0100
commit760752ef2045aaceb0393911a0919f9bc0104282 (patch)
treeecd7b04a9f21c9984bf6ada8b7e2b74bb43dc32d /kernel/filesystem/include
parent6d8ae9c708d43ab3d98d6a1f2fbb4e5f74a4a2aa (diff)
downloadteachos-760752ef2045aaceb0393911a0919f9bc0104282.tar.xz
teachos-760752ef2045aaceb0393911a0919f9bc0104282.zip
implement first inode draft, fix make_device_node, implement first draft of resolve_path (currently with temp m_device_nodes in vfs -> has later to be deleted again, just for tests)
Diffstat (limited to 'kernel/filesystem/include')
-rw-r--r--kernel/filesystem/include/filesystem/filesystem.hpp4
-rw-r--r--kernel/filesystem/include/filesystem/inode.hpp15
-rw-r--r--kernel/filesystem/include/filesystem/vfs.hpp15
3 files changed, 31 insertions, 3 deletions
diff --git a/kernel/filesystem/include/filesystem/filesystem.hpp b/kernel/filesystem/include/filesystem/filesystem.hpp
index a5a1047..2077ed6 100644
--- a/kernel/filesystem/include/filesystem/filesystem.hpp
+++ b/kernel/filesystem/include/filesystem/filesystem.hpp
@@ -12,10 +12,10 @@ namespace filesystem
virtual auto mount(devices::device * device) -> int = 0;
- [[nodiscard]] auto root_inode() const -> inode *;
+ [[nodiscard]] auto root_inode() const -> inode const &;
protected:
- inode * m_root_inode{}; // TODO BA-FS26 set during mount?
+ inode m_root_inode{}; // TODO BA-FS26 set during mount?
};
} // namespace filesystem
diff --git a/kernel/filesystem/include/filesystem/inode.hpp b/kernel/filesystem/include/filesystem/inode.hpp
index 44ec09a..eb8440f 100644
--- a/kernel/filesystem/include/filesystem/inode.hpp
+++ b/kernel/filesystem/include/filesystem/inode.hpp
@@ -1,13 +1,28 @@
#ifndef TEACH_OS_KERNEL_FILESYSTEM_INODE_HPP
#define TEACH_OS_KERNEL_FILESYSTEM_INODE_HPP
+#include "devices/device.hpp"
+
#include <cstddef>
+
namespace filesystem
{
struct inode
{
+ inode() = default;
+ explicit inode(devices::device * device);
+
+ [[nodiscard]] auto is_device() const -> bool;
+ [[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 *;
+
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:
+ devices::device * m_device{};
};
} // namespace filesystem
diff --git a/kernel/filesystem/include/filesystem/vfs.hpp b/kernel/filesystem/include/filesystem/vfs.hpp
index 182666d..a881241 100644
--- a/kernel/filesystem/include/filesystem/vfs.hpp
+++ b/kernel/filesystem/include/filesystem/vfs.hpp
@@ -2,10 +2,14 @@
#define TEACH_OS_KERNEL_FILESYSTEM_VFS_HPP
#include "devices/device.hpp"
+#include "filesystem/custody.hpp"
+#include "filesystem/inode.hpp"
#include "filesystem/mount.hpp"
+#include "filesystem/open_file_description.hpp"
#include <array>
#include <optional>
+#include <string_view>
namespace filesystem
{
@@ -16,13 +20,22 @@ namespace filesystem
~vfs() = default;
- auto make_device_node(devices::device * device) -> void;
+ auto open(std::string_view path) -> std::optional<open_file_description>;
private:
+ struct device_node_entry
+ {
+ std::string_view name;
+ inode node;
+ };
+
vfs() = default;
+ auto make_device_node(devices::device * device) -> void;
+ [[nodiscard]] auto resolve_path(std::string_view path) -> std::optional<custody>;
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
};
} // namespace filesystem