42 [[nodiscard]]
auto GetName() const -> const
char* override;
auto Read(vfs::File *file, void *buf, size_t count) -> Expected< size_t > override
从文件读取数据
auto Write(vfs::File *file, const void *buf, size_t count) -> Expected< size_t > override
向文件写入数据
auto Close(vfs::File *file) -> Expected< void > override
关闭文件
auto ReadDir(vfs::File *file, vfs::DirEntry *dirent, size_t count) -> Expected< size_t > override
读取目录项
auto Seek(vfs::File *file, int64_t offset, vfs::SeekWhence whence) -> Expected< uint64_t > override
调整文件偏移量
vfs::Inode * root_inode_
根目录 inode
auto IsDirectoryEmpty(RamInode *dir) -> bool
auto AllocateFileData(size_t size) -> void *
Bump-allocate size bytes from the file data pool.
static constexpr size_t kFileDataPoolSize
File data pool: 1 MB for regular file content.
auto AllocateInode() -> Expected< vfs::Inode * > override
分配新 inode
size_t dir_data_pool_used_
RamInode inodes_[kMaxInodes]
auto operator=(RamFs &&) -> RamFs &=delete
auto Unmount() -> Expected< void > override
卸载 ramfs
auto FindInDirectory(RamInode *dir, const char *name) -> RamDirEntry *
auto Sync() -> Expected< void > override
同步数据到磁盘(ramfs 无操作)
auto Mount(vfs::BlockDevice *device) -> Expected< vfs::Inode * > override
挂载 ramfs
auto GetFileOps() -> vfs::FileOps *
获取文件操作实例
auto AddToDirectory(RamInode *dir, const char *name, vfs::Inode *inode) -> Expected< void >
auto GetRootInode() const -> vfs::Inode *
获取根 inode
auto GetName() const -> const char *override
获取文件系统类型名
static constexpr size_t kInitialCapacity
初始文件容量
auto ExpandFile(RamInode *inode, size_t new_size) -> Expected< void >
auto FreeInode(vfs::Inode *inode) -> Expected< void > override
释放 inode
static constexpr size_t kDirDataPoolSize
Dir data pool: 256 KB for directory entry arrays.
static constexpr size_t kMaxInodes
RamFs(const RamFs &)=delete
auto AllocateDirEntries(size_t count) -> RamDirEntry *
Bump-allocate space for count RamDirEntry from the dir pool.
uint8_t dir_data_pool_[kDirDataPoolSize]
uint8_t file_data_pool_[kFileDataPoolSize]
auto operator=(const RamFs &) -> RamFs &=delete
RamInode * free_list_
空闲 inode 链表头
size_t used_inodes_
已使用的 inode 数量
size_t file_data_pool_used_
auto RemoveFromDirectory(RamInode *dir, const char *name) -> Expected< void >
std::expected< T, Error > Expected
std::expected 别名模板
auto Unlink(const char *path) -> Expected< void >
删除文件
auto Lookup(const char *path) -> Expected< Dentry * >
路径解析,查找 dentry
RamInode * next_free
空闲链表指针
void * data
文件数据(普通文件)或子项列表(目录)
size_t child_count
子项数量(仅目录)
File — 打开的文件实例(每次 open 产生一个)