diff options
Diffstat (limited to 'kernel/include/kernel/filesystem/inode.hpp')
| -rw-r--r-- | kernel/include/kernel/filesystem/inode.hpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/kernel/include/kernel/filesystem/inode.hpp b/kernel/include/kernel/filesystem/inode.hpp new file mode 100644 index 0000000..b34b921 --- /dev/null +++ b/kernel/include/kernel/filesystem/inode.hpp @@ -0,0 +1,69 @@ +#ifndef TEACH_OS_KERNEL_FILESYSTEM_INODE_HPP +#define TEACH_OS_KERNEL_FILESYSTEM_INODE_HPP + +#include <cstddef> + +namespace kernel::filesystem +{ + /** + @brief Represents an inode in the filesystem. + */ + struct inode + { + /** + @brief Create an inode. + */ + inode() = default; + + /** + @brief Virtual destructor for the inode. + */ + virtual ~inode() = default; + + /** + @brief Reads from the inode into a @p buffer, starting at the specified @p offset and for a given @p size. This + method must be implemented by concrete inode subclasses. + @param buffer Destination buffer. + @param offset Read offset in bytes. + @param size Number of bytes requested. + @return Number of bytes read. + */ + virtual auto read(void * buffer, size_t offset, size_t size) const -> size_t = 0; + + /** + @brief Writes to the inode into a @p buffer, starting at the specified @p offset and for a given @p size. This + method must be implemented by concrete inode subclasses. + @param buffer Source buffer. + @param offset Write offset in bytes. + @param size Number of bytes to write. + @return Number of bytes written. + */ + virtual auto write(void const * buffer, size_t offset, size_t size) -> size_t = 0; + + /** + @brief Returns whether the inode is a directory. + @return true if the inode is a directory, false otherwise. + */ + [[nodiscard]] virtual auto is_directory() const -> bool; + + /** + @brief Returns whether the inode is a regular file. + @return true if the inode is a regular file, false otherwise. + */ + [[nodiscard]] virtual auto is_regular() const -> bool; + + /** + @brief Returns whether the inode is a device. + @return true if the inode is a device, false otherwise. + */ + [[nodiscard]] virtual auto is_device() const -> bool; + + /** + @brief Returns whether the inode is a symbolic link. + @return true if the inode is a symbolic link, false otherwise. + */ + [[nodiscard]] virtual auto is_symbolic_link() const -> bool; + }; +} // namespace kernel::filesystem + +#endif |
