The Pedigree Project
0.1
src
modules
system
vfs
MountView.h
1
/* Copyright (c) 2026, Pedigree Developers. */
2
#ifndef PEDIGREE_VFS_MOUNTVIEW_H
3
#define PEDIGREE_VFS_MOUNTVIEW_H
4
5
#include "pedigree/kernel/process/FilesystemContext.h"
6
#include "pedigree/kernel/process/Mutex.h"
7
#include "pedigree/kernel/utilities/String.h"
8
#include "pedigree/kernel/utilities/Vector.h"
9
10
#include "VFS.h"
11
12
class
VfsPath
;
13
class
VfsFilesystemContext
;
14
class
VfsAttachment
;
15
17
class
EXPORTED_PUBLIC
VfsMountView
{
18
public
:
19
struct
ResolveOptions
{
20
bool
followFinal =
true
;
21
bool
requireDirectory =
false
;
22
bool
crossFinalMount =
true
;
23
};
24
struct
MountSnapshot
{
25
uint64_t
id
= 0;
26
uint64_t parentId = 0;
27
VFS::MountIdentity
backing;
28
String
path;
29
};
30
31
explicit
VfsMountView
(
VFS
& vfs);
32
~VfsMountView
();
33
bool
initialise(
Filesystem
* bootRoot);
34
bool
createBootContext(
FilesystemContextOwner
& result);
35
bool
resolve(
const
FilesystemContextRef
& context,
const
FilesystemPathRef
& start,
36
const
String
& path,
const
ResolveOptions
&
options
,
FilesystemPathRef
& result);
37
bool
follow(
const
FilesystemContextRef
& context,
const
FilesystemPathRef
& selected,
38
FilesystemPathRef
& result);
39
bool
resolveParent(
const
FilesystemContextRef
& context,
const
FilesystemPathRef
& start,
40
const
String
& path,
FilesystemPathRef
& parent,
String
& basename);
41
bool
changeCwd(
const
FilesystemContextRef
& context,
const
FilesystemPathRef
& path);
42
bool
changeRoot(
const
FilesystemContextRef
& context,
const
FilesystemPathRef
& path);
43
bool
formatPath(
const
FilesystemContextSnapshot
& context,
const
FilesystemPathRef
& path,
44
String
& result);
45
bool
snapshotMounts(
const
FilesystemContextRef
& context,
Vector<MountSnapshot>
& result);
46
47
enum class
BackingOwnership { External, Attachment };
48
// Attachment ownership transfers only after successful graph publication.
49
// Attachments identify a mounted root, independently of backing identity.
50
bool
attach(
const
FilesystemContextRef
& context,
const
FilesystemPathRef
& covered,
51
Filesystem
* backing, BackingOwnership ownership = BackingOwnership::External);
52
bool
detach(
const
FilesystemContextRef
& context,
const
String
& target,
bool
lazy);
53
bool
detachBackingForShutdown(
Filesystem
* backing);
54
bool
shutdown(
Vector<Filesystem*>
& ownedBackings);
55
bool
pivot(
const
FilesystemContextRef
& context,
const
String
& newRoot,
const
String
& putOld);
56
uint64_t attachmentId(
const
FilesystemPathRef
& path)
const
;
57
bool
isMountpoint(
File
* node)
const
;
58
bool
createFile(
const
FilesystemPathRef
& parent,
const
String
& name, uint32_t mask);
59
bool
createDirectory(
const
FilesystemPathRef
& parent,
const
String
& name, uint32_t mask);
60
bool
createSymlink(
const
FilesystemPathRef
& parent,
const
String
& name,
const
String
& value);
61
bool
createLink(
const
FilesystemPathRef
& parent,
const
String
& name,
62
const
FilesystemPathRef
& target);
63
bool
remove(
const
FilesystemPathRef
& parent,
const
String
& name,
File
* expected =
nullptr
);
64
bool
rename(
const
FilesystemPathRef
& oldParent,
const
String
& oldName,
65
const
FilesystemPathRef
& newParent,
const
String
& newName,
bool
noReplace,
66
bool
sourceMustBeDirectory =
false
);
67
bool
anonymousPath(
File
* retainedNode,
FilesystemPathRef
& result);
68
bool
pathForNode(
const
FilesystemPathRef
& sameAttachment,
File
* retainedNode,
69
FilesystemPathRef
& result);
70
bool
samePath(
const
FilesystemPathRef
& first,
const
FilesystemPathRef
& second)
const
;
71
72
// Boot/fixture enrollment only; never resolves a raw File to a guessed mount.
73
bool
bootRootPath(
FilesystemPathRef
& result);
74
#if HOSTED && PEDIGREE_HOSTED_SMOKE_TESTS
75
bool
quiescentForHostedTest()
const
;
76
#endif
77
78
private
:
79
friend
class
VfsPath
;
80
friend
class
VfsFilesystemContext
;
81
struct
State;
82
State* m_State;
83
VFS
& m_Vfs;
84
VfsMountView
(
const
VfsMountView
&) =
delete
;
85
VfsMountView
& operator=(
const
VfsMountView
&) =
delete
;
86
};
87
88
#endif
File
Definition
File.h:74
FilesystemContextOwner
Definition
FilesystemContext.h:41
Filesystem
Definition
Filesystem.h:40
SharedPointer< FilesystemContext >
String
Definition
String.h:43
VFS::MountIdentity
Definition
VFS.h:86
VFS
Definition
VFS.h:58
Vector
A vector / dynamic array.
Definition
Vector.h:33
VfsAttachment
Definition
MountView-internal.h:32
VfsFilesystemContext
Definition
MountView-internal.h:74
VfsMountView
Definition
MountView.h:17
VfsPath
Definition
MountView-internal.h:45
FilesystemContextSnapshot
Definition
FilesystemContext.h:22
VfsMountView::MountSnapshot
Definition
MountView.h:24
VfsMountView::ResolveOptions
Definition
MountView.h:19
options
Definition
vfork-benchmark/main.c:28
Generated on Thu Sep 24 2026 06:24:01 for The Pedigree Project by
1.9.8