|
SimpleKernel 1.17.0
|
Classes | |
| class | BlockDevice |
| 块设备抽象基类 More... | |
| struct | Dentry |
| Dentry — 目录项缓存(路径名 ↔ Inode 的映射) More... | |
| struct | DirEntry |
| 目录项结构(用于 readdir) More... | |
| struct | File |
| File — 打开的文件实例(每次 open 产生一个) More... | |
| class | FileOps |
| File 操作接口 More... | |
| class | FileSystem |
| 文件系统类型基类 More... | |
| struct | Inode |
| Inode — 文件元数据(独立于路径名) More... | |
| class | InodeOps |
| Inode 操作接口 More... | |
| struct | MountPoint |
| 挂载点 More... | |
| class | MountTable |
| 挂载表管理器 More... | |
| struct | VfsState |
| VFS 全局状态结构体 More... | |
Enumerations | |
| enum class | FileType : uint8_t { kUnknown = 0 , kRegular = 1 , kDirectory = 2 , kCharDevice = 3 , kBlockDevice = 4 , kSymlink = 5 , kFifo = 6 } |
| 文件类型 More... | |
| enum class | OpenFlags : uint32_t { kOReadOnly = 0x0000 , kOWriteOnly = 0x0001 , kOReadWrite = 0x0002 , kOCreate = 0x0040 , kOTruncate = 0x0200 , kOAppend = 0x0400 , kODirectory = 0x010000 } |
| 文件打开标志(兼容 Linux O_* 定义) More... | |
| enum class | SeekWhence : int { kSet = 0 , kCur = 1 , kEnd = 2 } |
| 文件 seek 基准 More... | |
Functions | |
| auto | Close (File *file) -> Expected< void > |
| 关闭文件 | |
| auto | GetMountTable () -> MountTable & |
| 获取全局挂载表实例 | |
| auto | Init () -> Expected< void > |
| VFS 全局初始化 | |
| auto | Lookup (const char *path) -> Expected< Dentry * > |
| 路径解析,查找 dentry | |
| auto | Open (const char *path, OpenFlags flags) -> Expected< File * > |
| 打开文件 | |
| auto | Read (File *file, void *buf, size_t count) -> Expected< size_t > |
| 从文件读取数据 | |
| auto | Write (File *file, const void *buf, size_t count) -> Expected< size_t > |
| 向文件写入数据 | |
| auto | Seek (File *file, int64_t offset, SeekWhence whence) -> Expected< uint64_t > |
| 调整文件偏移量 | |
| auto | MkDir (const char *path) -> Expected< void > |
| 创建目录 | |
| auto | RmDir (const char *path) -> Expected< void > |
| 删除目录 | |
| auto | Unlink (const char *path) -> Expected< void > |
| 删除文件 | |
| auto | ReadDir (File *file, DirEntry *dirent, size_t count) -> Expected< size_t > |
| 读取目录内容 | |
| auto | GetRootDentry () -> Dentry * |
| 获取根目录 dentry | |
| constexpr auto | operator| (OpenFlags lhs, OpenFlags rhs) -> OpenFlags |
| 按位或 | |
| constexpr auto | operator& (OpenFlags lhs, OpenFlags rhs) -> OpenFlags |
| 按位与 | |
| constexpr auto | operator~ (OpenFlags flags) -> OpenFlags |
| 按位取反 | |
| constexpr auto | operator|= (OpenFlags &lhs, OpenFlags rhs) -> OpenFlags & |
| 按位或赋值 | |
| constexpr auto | operator&= (OpenFlags &lhs, OpenFlags rhs) -> OpenFlags & |
| 按位与赋值 | |
| constexpr auto | operator== (OpenFlags flags, uint32_t val) -> bool |
| 检查 OpenFlags 是否为零(无标志位设置) | |
| constexpr auto | operator!= (OpenFlags flags, uint32_t val) -> bool |
| 检查 OpenFlags 是否不为零 | |
| auto | GetVfsState () -> VfsState & |
| auto | SkipLeadingSlashes (const char *path) -> const char * |
| 跳过路径中的前导斜杠 | |
| auto | CopyPathComponent (const char *src, char *dst, size_t dst_size) -> size_t |
| 复制路径组件到缓冲区 | |
| auto | FindChild (Dentry *parent, const char *name) -> Dentry * |
| 在 dentry 的子节点中查找指定名称 | |
| auto | AddChild (Dentry *parent, Dentry *child) -> void |
| 添加子 dentry | |
| auto | RemoveChild (Dentry *parent, Dentry *child) -> void |
| 从父 dentry 中移除子 dentry | |
| auto | SetRootDentry (Dentry *dentry) -> void |
| auto | GetMountTableInternal () -> MountTable * |
Variables | |
| static constexpr size_t | kMaxPathLength = 4096 |
| VFS 路径最大长度限制 | |
|
strong |
文件类型
| Enumerator | |
|---|---|
| kUnknown | |
| kRegular | 普通文件 |
| kDirectory | 目录 |
| kCharDevice | 字符设备 |
| kBlockDevice | 块设备 |
| kSymlink | 符号链接 |
| kFifo | 命名管道 |
Definition at line 22 of file vfs_types.hpp.
|
strong |
文件打开标志(兼容 Linux O_* 定义)
| Enumerator | |
|---|---|
| kOReadOnly | |
| kOWriteOnly | |
| kOReadWrite | |
| kOCreate | |
| kOTruncate | |
| kOAppend | |
| kODirectory | 必须是目录 |
Definition at line 39 of file vfs_types.hpp.
|
strong |
文件 seek 基准
| Enumerator | |
|---|---|
| kSet | 从文件开头 |
| kCur | 从当前位置 |
| kEnd | 从文件末尾 |
Definition at line 94 of file vfs_types.hpp.
关闭文件
| file | 文件对象 |
Definition at line 15 of file close.cpp.


| auto vfs::CopyPathComponent | ( | const char * | src, |
| char * | dst, | ||
| size_t | dst_size | ||
| ) | -> size_t |
在 dentry 的子节点中查找指定名称
Definition at line 38 of file vfs.cpp.

| auto vfs::GetMountTable | ( | ) | -> MountTable& |
获取全局挂载表实例
Definition at line 234 of file mount.cpp.

| auto vfs::GetMountTableInternal | ( | ) | -> MountTable* |
| auto vfs::GetRootDentry | ( | ) | -> Dentry* |
| auto vfs::GetVfsState | ( | ) | -> VfsState & |
| auto vfs::Init | ( | ) | -> Expected<void> |
VFS 全局初始化
Definition at line 80 of file vfs.cpp.


路径解析,查找 dentry
| path | 绝对路径(以 / 开头) |
Definition at line 14 of file lookup.cpp.


| auto vfs::MkDir | ( | const char * | path | ) | -> Expected<void> |
创建目录
| path | 目录路径 |
Definition at line 14 of file mkdir.cpp.


打开文件
| path | 文件路径 |
| flags | 打开标志 |
Definition at line 14 of file open.cpp.


|
inlineconstexpr |
检查 OpenFlags 是否不为零
Definition at line 88 of file vfs_types.hpp.
|
inlineconstexpr |
检查 OpenFlags 是否为零(无标志位设置)
Definition at line 82 of file vfs_types.hpp.
按位取反
Definition at line 65 of file vfs_types.hpp.
从文件读取数据
| file | 文件对象 |
| buf | 输出缓冲区 |
| count | 最大读取字节数 |
Definition at line 13 of file read.cpp.


读取目录内容
| file | 目录文件对象 |
| dirent | 输出目录项数组 |
| count | 最多读取的条目数 |
Definition at line 13 of file readdir.cpp.


从父 dentry 中移除子 dentry
Definition at line 63 of file vfs.cpp.

| auto vfs::RmDir | ( | const char * | path | ) | -> Expected<void> |
删除目录
| path | 目录路径 |
Definition at line 15 of file rmdir.cpp.


| auto vfs::Seek | ( | File * | file, |
| int64_t | offset, | ||
| SeekWhence | whence | ||
| ) | -> Expected<uint64_t> |
调整文件偏移量
| file | 文件对象 |
| offset | 偏移量 |
| whence | 基准位置 |
Definition at line 13 of file seek.cpp.


| auto vfs::SetRootDentry | ( | Dentry * | dentry | ) | -> void |
| auto vfs::SkipLeadingSlashes | ( | const char * | path | ) | -> const char * |
| auto vfs::Unlink | ( | const char * | path | ) | -> Expected<void> |
删除文件
| path | 文件路径 |
Definition at line 15 of file unlink.cpp.


向文件写入数据
| file | 文件对象 |
| buf | 输入缓冲区 |
| count | 要写入的字节数 |
Definition at line 13 of file write.cpp.


|
staticconstexpr |
VFS 路径最大长度限制
Definition at line 14 of file vfs_internal.hpp.