SimpleKernel 1.17.0
Loading...
Searching...
No Matches
vfs_internal.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include "mount.hpp"
8#include "spinlock.hpp"
9#include "vfs.hpp"
10
11namespace vfs {
12
14static constexpr size_t kMaxPathLength = 4096;
15
17struct VfsState {
18 bool initialized = false;
20 Dentry* root_dentry = nullptr;
22};
23
24// 获取 VFS 状态
25[[nodiscard]] auto GetVfsState() -> VfsState&;
26
32[[nodiscard]] auto SkipLeadingSlashes(const char* path) -> const char*;
33
41[[nodiscard]] auto CopyPathComponent(const char* src, char* dst,
42 size_t dst_size) -> size_t;
43
47[[nodiscard]] auto FindChild(Dentry* parent, const char* name) -> Dentry*;
48
52auto AddChild(Dentry* parent, Dentry* child) -> void;
53
57auto RemoveChild(Dentry* parent, Dentry* child) -> void;
58
59} // namespace vfs
自旋锁
Definition spinlock.hpp:27
挂载表管理器
Definition mount.hpp:34
auto RemoveChild(Dentry *parent, Dentry *child) -> void
从父 dentry 中移除子 dentry
Definition vfs.cpp:63
auto AddChild(Dentry *parent, Dentry *child) -> void
添加子 dentry
Definition vfs.cpp:53
auto FindChild(Dentry *parent, const char *name) -> Dentry *
在 dentry 的子节点中查找指定名称
Definition vfs.cpp:38
auto SkipLeadingSlashes(const char *path) -> const char *
跳过路径中的前导斜杠
Definition vfs.cpp:22
auto GetVfsState() -> VfsState &
Definition vfs.cpp:17
auto CopyPathComponent(const char *src, char *dst, size_t dst_size) -> size_t
复制路径组件到缓冲区
Definition vfs.cpp:29
static constexpr size_t kMaxPathLength
VFS 路径最大长度限制
Dentry — 目录项缓存(路径名 ↔ Inode 的映射)
Definition vfs.hpp:41
VFS 全局状态结构体
MountTable * mount_table
Dentry * root_dentry
SpinLock vfs_lock_