The Pedigree Project
0.1
src
system
include
pedigree
kernel
process
FilesystemContext.h
1
/* Copyright (c) 2026, Pedigree Developers. */
2
#ifndef PEDIGREE_PROCESS_FILESYSTEMCONTEXT_H
3
#define PEDIGREE_PROCESS_FILESYSTEMCONTEXT_H
4
5
#include "pedigree/kernel/compiler.h"
6
#include "pedigree/kernel/processor/types.h"
7
#include "pedigree/kernel/utilities/SharedPointer.h"
8
#include "pedigree/kernel/utilities/utility.h"
9
10
class
File
;
11
13
class
EXPORTED_PUBLIC
FilesystemPath
{
14
public
:
15
virtual
~FilesystemPath
() =
default
;
16
// Borrowed for the lifetime of the path reference, including after detach.
17
virtual
File
* node()
const
= 0;
18
virtual
const
void
* provider()
const
= 0;
19
};
20
using
FilesystemPathRef
=
SharedPointer<FilesystemPath>
;
21
23
class
EXPORTED_PUBLIC
FilesystemWriteLease
{
24
public
:
25
virtual
~FilesystemWriteLease
() =
default
;
26
};
27
28
struct
EXPORTED_PUBLIC
FilesystemContextSnapshot
{
29
FilesystemPathRef
root;
30
FilesystemPathRef
cwd;
31
uint64_t contextGeneration = 0;
32
uint64_t topologyGeneration = 0;
33
};
34
35
class
EXPORTED_PUBLIC
FilesystemContextOwner
;
36
class
EXPORTED_PUBLIC
FilesystemContext
{
37
public
:
38
virtual
~FilesystemContext
() =
default
;
39
virtual
const
void
* provider()
const
{
40
return
nullptr
;
41
}
42
virtual
bool
snapshot(
FilesystemContextSnapshot
& result)
const
= 0;
43
// The provider enrolls the unpublished child before returning success.
44
virtual
bool
forkForProcess(
FilesystemContextOwner
& result)
const
= 0;
45
virtual
void
retireProcessOwner() = 0;
46
};
47
using
FilesystemContextRef
=
SharedPointer<FilesystemContext>
;
48
50
class
EXPORTED_PUBLIC
FilesystemContextOwner
{
51
public
:
52
FilesystemContextOwner
() =
default
;
53
FilesystemContextOwner
(
FilesystemContextOwner
&& other) noexcept
54
: m_Context(pedigree_std::move(other.m_Context)) {}
55
FilesystemContextOwner
& operator=(
FilesystemContextOwner
&& other)
noexcept
{
56
if
(
this
!= &other) {
57
reset();
58
m_Context = pedigree_std::move(other.m_Context);
59
}
60
return
*
this
;
61
}
62
~FilesystemContextOwner
() {
63
reset();
64
}
65
66
FilesystemContextRef
reference()
const
{
67
return
m_Context;
68
}
69
explicit
operator
bool()
const
{
70
return
static_cast<
bool
>
(m_Context);
71
}
72
void
reset() {
73
FilesystemContextRef
retired(pedigree_std::move(m_Context));
74
if
(retired)
75
retired->retireProcessOwner();
76
}
77
// Providers call this only after enrollment, with the original control block.
78
static
FilesystemContextOwner
adopt(
FilesystemContextRef
&& context) {
79
FilesystemContextOwner
result;
80
result.m_Context = pedigree_std::move(context);
81
return
result;
82
}
83
84
private
:
85
FilesystemContextOwner
(
const
FilesystemContextOwner
&) =
delete
;
86
FilesystemContextOwner
& operator=(
const
FilesystemContextOwner
&) =
delete
;
87
FilesystemContextRef
m_Context;
88
};
89
90
#endif
File
Definition
File.h:75
FilesystemContextOwner
Definition
FilesystemContext.h:50
FilesystemContext
Definition
FilesystemContext.h:36
FilesystemPath
Definition
FilesystemContext.h:13
FilesystemWriteLease
Definition
FilesystemContext.h:23
SharedPointer< FilesystemPath >
FilesystemContextSnapshot
Definition
FilesystemContext.h:28
Generated on Sat Oct 3 2026 06:38:07 for The Pedigree Project by
1.9.8