diff options
| author | Marcel Braun <marcel.braun@ost.ch> | 2026-04-16 22:04:32 +0200 |
|---|---|---|
| committer | Marcel Braun <marcel.braun@ost.ch> | 2026-04-16 22:04:32 +0200 |
| commit | f642efb5cf199d3bbb8e3b01c451c71a1fbeabf8 (patch) | |
| tree | 7e680dd885a59678d7075d352ee623f659d64d48 /kernel/include | |
| parent | 3c210c07c60fbe9378cfb720847e8c1d3c763ead (diff) | |
| parent | e70ea2357a80386b0a12138201b353d942910296 (diff) | |
| download | teachos-f642efb5cf199d3bbb8e3b01c451c71a1fbeabf8.tar.xz teachos-f642efb5cf199d3bbb8e3b01c451c71a1fbeabf8.zip | |
Merge branch 'syscall-interface' into 'develop-BA-FS26'
Add fs syscall handler
See merge request teachos/kernel!23
Diffstat (limited to 'kernel/include')
6 files changed, 32 insertions, 37 deletions
diff --git a/kernel/include/kernel/filesystem/devfs/filesystem.hpp b/kernel/include/kernel/filesystem/devfs/filesystem.hpp index 137eca3..3a52403 100644 --- a/kernel/include/kernel/filesystem/devfs/filesystem.hpp +++ b/kernel/include/kernel/filesystem/devfs/filesystem.hpp @@ -1,8 +1,6 @@ #ifndef TEACH_OS_KERNEL_FILESYSTEM_DEVFS_FILESYSTEM_HPP #define TEACH_OS_KERNEL_FILESYSTEM_DEVFS_FILESYSTEM_HPP -#include "kapi/devices/device.hpp" - #include "kernel/filesystem/filesystem.hpp" #include "kernel/filesystem/inode.hpp" @@ -23,10 +21,10 @@ namespace kernel::filesystem::devfs { /** @brief Initializes the devfs instance and builds the device inode table. - @param device Backing device passed by the generic filesystem interface (not required by devfs). + @param backing_inode Backing inode passed by the vfs (not required by devfs). @return The result of the mount operation. */ - auto mount(kstd::shared_ptr<kapi::devices::device> const & device) -> operation_result override; + auto mount(kstd::shared_ptr<kernel::filesystem::inode> const & backing_inode) -> operation_result override; /** @brief Looks up an inode by @p name within a @p parent directory. diff --git a/kernel/include/kernel/filesystem/ext2/filesystem.hpp b/kernel/include/kernel/filesystem/ext2/filesystem.hpp index a71385f..9112866 100644 --- a/kernel/include/kernel/filesystem/ext2/filesystem.hpp +++ b/kernel/include/kernel/filesystem/ext2/filesystem.hpp @@ -1,8 +1,6 @@ #ifndef TEACH_OS_KERNEL_FILESYSTEM_EXT2_FILESYSTEM_HPP #define TEACH_OS_KERNEL_FILESYSTEM_EXT2_FILESYSTEM_HPP -#include "kapi/devices/device.hpp" - #include "kernel/filesystem/ext2/block_group_descriptor.hpp" #include "kernel/filesystem/ext2/inode.hpp" #include "kernel/filesystem/ext2/superblock.hpp" @@ -46,11 +44,11 @@ namespace kernel::filesystem::ext2 struct filesystem : kernel::filesystem::filesystem { /** - @brief Initializes the ext2 filesystem with the given @p device. - @param device The device to mount. + @brief Initializes the ext2 filesystem with the given @p backing_inode. + @param backing_inode The backing inode to mount. @return The result of the mount operation. */ - auto mount(kstd::shared_ptr<kapi::devices::device> const & device) -> operation_result override; + auto mount(kstd::shared_ptr<kernel::filesystem::inode> const & backing_inode) -> operation_result override; /** @brief Looks up an inode by @p name within a @p parent directory. diff --git a/kernel/include/kernel/filesystem/file_descriptor_table.hpp b/kernel/include/kernel/filesystem/file_descriptor_table.hpp index 5d52c19..5dd91e7 100644 --- a/kernel/include/kernel/filesystem/file_descriptor_table.hpp +++ b/kernel/include/kernel/filesystem/file_descriptor_table.hpp @@ -50,8 +50,9 @@ namespace kernel::filesystem /** @brief Remove a file from the descriptor table. @param fd The file descriptor index to remove. + @return 0 on success, or -1 on failure. */ - auto remove_file(int fd) -> void; + auto remove_file(int fd) -> int; private: file_descriptor_table() = default; diff --git a/kernel/include/kernel/filesystem/filesystem.hpp b/kernel/include/kernel/filesystem/filesystem.hpp index ef6929a..099caee 100644 --- a/kernel/include/kernel/filesystem/filesystem.hpp +++ b/kernel/include/kernel/filesystem/filesystem.hpp @@ -1,8 +1,6 @@ #ifndef TEACH_OS_KERNEL_FILESYSTEM_FILESYSTEM_HPP #define TEACH_OS_KERNEL_FILESYSTEM_FILESYSTEM_HPP -#include "kapi/devices/device.hpp" - #include "kernel/filesystem/inode.hpp" #include <kstd/memory> @@ -32,22 +30,23 @@ namespace kernel::filesystem virtual ~filesystem() = default; /** - @brief Probes the given @p device to determine if it contains a recognizable filesystem, and if so, mounts it and - returns a pointer to the mounted filesystem instance. This method iterates through known filesystem types and - attempts to initialize it with the device until the mount was successful or all types have been tried. - @param device The device to probe and mount. + @brief Probes the given @p backing_inode to determine if it contains a recognizable filesystem, and if so, mounts it + and returns a pointer to the mounted filesystem instance. This method iterates through known filesystem types and + attempts to initialize it with the backing inode until the mount was successful or all types have been tried. + @param backing_inode The inode to probe and mount. @return A pointer to the mounted filesystem instance if successful, or a null pointer if no recognizable filesystem - is found on the device. - @warning Panics if @p device is null. + is found on the backing inode. + @warning Panics if @p backing_inode is null. */ - auto static probe_and_mount(kstd::shared_ptr<kapi::devices::device> const & device) -> kstd::shared_ptr<filesystem>; + auto static probe_and_mount(kstd::shared_ptr<inode> const & backing_inode) -> kstd::shared_ptr<filesystem>; /** - @brief Initializes the filesystem with the given @p device. - @param device The device to mount. + @brief Initializes the filesystem with the given @p backing_inode. + @param backing_inode The inode to use as the backing inode for the filesystem. (This is typically the inode + representing the block device or another inode which contains the filesystem data.) @return The result of the mount operation. */ - virtual auto mount(kstd::shared_ptr<kapi::devices::device> const & device) -> operation_result; + virtual auto mount(kstd::shared_ptr<inode> const & backing_inode) -> operation_result; /** @brief Looks up a child inode within the given @p parent inode with the specified @p name. This method must be @@ -65,13 +64,13 @@ namespace kernel::filesystem [[nodiscard]] auto root_inode() const -> kstd::shared_ptr<inode> const &; /** - @brief Returns a reference to the device associated with the filesystem. + @brief Returns a reference to the backing inode of the filesystem. */ - [[nodiscard]] auto device() const -> kstd::shared_ptr<kapi::devices::device> const &; + [[nodiscard]] auto backing_inode() const -> kstd::shared_ptr<inode> const &; protected: kstd::shared_ptr<inode> m_root_inode{}; - kstd::shared_ptr<kapi::devices::device> m_device{}; + kstd::shared_ptr<inode> m_backing_inode{}; kstd::vector<kstd::shared_ptr<inode>> m_inodes{}; }; diff --git a/kernel/include/kernel/filesystem/rootfs/filesystem.hpp b/kernel/include/kernel/filesystem/rootfs/filesystem.hpp index 0155c41..e14a1ee 100644 --- a/kernel/include/kernel/filesystem/rootfs/filesystem.hpp +++ b/kernel/include/kernel/filesystem/rootfs/filesystem.hpp @@ -1,8 +1,6 @@ #ifndef TEACH_OS_KERNEL_FILESYSTEM_ROOTFS_FILESYSTEM_HPP #define TEACH_OS_KERNEL_FILESYSTEM_ROOTFS_FILESYSTEM_HPP -#include "kapi/devices/device.hpp" - #include "kernel/filesystem/filesystem.hpp" #include "kernel/filesystem/inode.hpp" @@ -23,11 +21,11 @@ namespace kernel::filesystem::rootfs struct filesystem : kernel::filesystem::filesystem { /** - @brief Initializes the rootfs filesystem with the given @p device. - @param device The device to mount (not required by rootfs). + @brief Initializes the rootfs filesystem with the given @p backing_inode. + @param backing_inode The backing inode to mount (not required by rootfs). @return The result of the mount operation. */ - auto mount(kstd::shared_ptr<kapi::devices::device> const & device) -> operation_result override; + auto mount(kstd::shared_ptr<kernel::filesystem::inode> const & backing_inode) -> operation_result override; /** @brief Looks up an inode by @p name within a @p parent directory. diff --git a/kernel/include/kernel/filesystem/vfs.hpp b/kernel/include/kernel/filesystem/vfs.hpp index 4dd2a83..2a9d5f7 100644 --- a/kernel/include/kernel/filesystem/vfs.hpp +++ b/kernel/include/kernel/filesystem/vfs.hpp @@ -27,9 +27,10 @@ namespace kernel::filesystem { success = 0, invalid_path = -1, - mount_point_not_found = -2, - filesystem_null = -3, - unmount_failed = -4 + non_existent_path = -2, + mount_point_not_found = -3, + unmount_failed = -4, + invalid_filesystem = -5, }; /** @@ -58,12 +59,12 @@ namespace kernel::filesystem auto open(std::string_view path) -> kstd::shared_ptr<open_file_description>; /** - @brief Mount a @p filesystem at a specific @p path. - @param path The path where the filesystem should be mounted. - @param filesystem The filesystem to mount. + @brief Mount a @p source path to a specific @p target path. + @param source The source of the filesystem to mount. + @param target The path where the filesystem should be mounted. @return The result of the mount operation. */ - auto do_mount(std::string_view path, kstd::shared_ptr<filesystem> const & filesystem) -> operation_result; + auto do_mount(std::string_view source, std::string_view target) -> operation_result; /** @brief Unmount the filesystem mounted at the specified @p path. |
