SimpleKernel 1.17.0
Loading...
Searching...
No Matches
filesystem.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include "block_device.hpp"
8#include "vfs_types.hpp"
9
10namespace vfs {
11
18 public:
19 virtual ~FileSystem() = default;
20
25 [[nodiscard]] virtual auto GetName() const -> const char* = 0;
26
33 [[nodiscard]] virtual auto Mount(BlockDevice* device) -> Expected<Inode*> = 0;
34
40 [[nodiscard]] virtual auto Unmount() -> Expected<void> = 0;
41
46 [[nodiscard]] virtual auto Sync() -> Expected<void> = 0;
47
53 [[nodiscard]] virtual auto AllocateInode() -> Expected<Inode*> = 0;
54
62 [[nodiscard]] virtual auto FreeInode(Inode* inode) -> Expected<void> = 0;
63
69 [[nodiscard]] virtual auto GetFileOps() -> FileOps* = 0;
70};
71
72} // namespace vfs
块设备抽象基类
File 操作接口
文件系统类型基类
virtual auto GetFileOps() -> FileOps *=0
获取文件系统的文件操作接口
virtual auto Unmount() -> Expected< void >=0
卸载文件系统
virtual ~FileSystem()=default
virtual auto Mount(BlockDevice *device) -> Expected< Inode * >=0
挂载文件系统
virtual auto Sync() -> Expected< void >=0
将缓存数据刷写到磁盘
virtual auto AllocateInode() -> Expected< Inode * >=0
分配新 inode
virtual auto FreeInode(Inode *inode) -> Expected< void >=0
释放 inode
virtual auto GetName() const -> const char *=0
获取文件系统类型名(如 "ramfs", "fat32")
std::expected< T, Error > Expected
std::expected 别名模板
Definition expected.hpp:365
Inode — 文件元数据(独立于路径名)
Definition vfs.hpp:16