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
11
namespace
vfs
{
12
14
static
constexpr
size_t
kMaxPathLength
= 4096;
15
17
struct
VfsState
{
18
bool
initialized
=
false
;
19
MountTable
*
mount_table
=
nullptr
;
20
Dentry
*
root_dentry
=
nullptr
;
21
SpinLock
vfs_lock_
{
"vfs"
};
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
52
auto
AddChild
(Dentry* parent, Dentry* child) -> void;
53
57
auto
RemoveChild
(Dentry* parent, Dentry* child) -> void;
58
59
}
// namespace vfs
SpinLock
自旋锁
Definition
spinlock.hpp:27
vfs::MountTable
挂载表管理器
Definition
mount.hpp:34
mount.hpp
vfs
Definition
device_node.hpp:28
vfs::RemoveChild
auto RemoveChild(Dentry *parent, Dentry *child) -> void
从父 dentry 中移除子 dentry
Definition
vfs.cpp:63
vfs::AddChild
auto AddChild(Dentry *parent, Dentry *child) -> void
添加子 dentry
Definition
vfs.cpp:53
vfs::FindChild
auto FindChild(Dentry *parent, const char *name) -> Dentry *
在 dentry 的子节点中查找指定名称
Definition
vfs.cpp:38
vfs::SkipLeadingSlashes
auto SkipLeadingSlashes(const char *path) -> const char *
跳过路径中的前导斜杠
Definition
vfs.cpp:22
vfs::GetVfsState
auto GetVfsState() -> VfsState &
Definition
vfs.cpp:17
vfs::CopyPathComponent
auto CopyPathComponent(const char *src, char *dst, size_t dst_size) -> size_t
复制路径组件到缓冲区
Definition
vfs.cpp:29
vfs::kMaxPathLength
static constexpr size_t kMaxPathLength
VFS 路径最大长度限制
Definition
vfs_internal.hpp:14
spinlock.hpp
vfs::Dentry
Dentry — 目录项缓存(路径名 ↔ Inode 的映射)
Definition
vfs.hpp:41
vfs::VfsState
VFS 全局状态结构体
Definition
vfs_internal.hpp:17
vfs::VfsState::initialized
bool initialized
Definition
vfs_internal.hpp:18
vfs::VfsState::mount_table
MountTable * mount_table
Definition
vfs_internal.hpp:19
vfs::VfsState::root_dentry
Dentry * root_dentry
Definition
vfs_internal.hpp:20
vfs::VfsState::vfs_lock_
SpinLock vfs_lock_
Definition
vfs_internal.hpp:21
vfs.hpp
src
filesystem
vfs
vfs_internal.hpp
Generated by
1.9.8