2#include "pedigree/kernel/syscallError.h"
3#include "pedigree/kernel/utilities/Pointers.h"
7#include "pedigree/kernel/process/Process.h"
8#include "pedigree/kernel/process/Thread.h"
9#include "pedigree/kernel/processor/Processor.h"
10#include "pedigree/kernel/processor/ProcessorInformation.h"
13VFS::NamespaceMutation::NamespaceMutation(
VFS& vfs) : m_Vfs(vfs), m_Lock(vfs.m_PathMutationLock) {
14 __atomic_add_fetch(&m_Vfs.m_PathGeneration, 1, __ATOMIC_ACQ_REL);
16VFS::NamespaceMutation::~NamespaceMutation() {
17 __atomic_add_fetch(&m_Vfs.m_PathGeneration, 1, __ATOMIC_RELEASE);
19uint64_t VFS::NamespaceMutation::generation()
const {
20 return m_Vfs.namespaceGeneration();
23 return __atomic_load_n(&m_PathGeneration, __ATOMIC_ACQUIRE);
28 if (thread && thread->getParent()) {
29 auto context = thread->getParent()->acquireFilesystemContext();
30 if (
auto* view = VfsMountView::fromContext(context)) {
35 return bootMountView();
38 return __atomic_load_n(&m_MountView, __ATOMIC_ACQUIRE);
41 auto* view = bootMountView();
44 if (!view->shutdown(ownedBackings))
46 __atomic_store_n(&m_MountView,
static_cast<VfsMountView*
>(
nullptr), __ATOMIC_RELEASE);
50bool VFS::initialiseMountView() {
58 if (!view.get()->createBootContext(bootstrap))
60 auto context = bootstrap.reference();
63 getMountsLocked(mounts);
64 if (!importedPoints.tryReserve(mounts.
count())) {
65 SYSCALL_ERROR(OutOfMemory);
69 options.requireDirectory =
true;
70 options.crossFinalMount =
false;
71 for (
const auto&
mount : mounts) {
78 !view.get()->attach(context, point, backing))
80 importedPoints.
pushBack(pedigree_std::move(point));
85 NamespaceMutation writer(*
this);
87 SYSCALL_ERROR(DeviceBusy);
92 for (
const auto& point : importedPoints)
93 Directory::fromFile(point->node())->setReparsePoint(nullptr);
94 __atomic_store_n(&m_MountView, view.releaseOwnership(), __ATOMIC_RELEASE);
static ProcessorInformation & information()
static UniquePointer< T > adopt(T *pointer)
Filesystem * getFilesystemAt(const String &path) const
bool mount(Disk *pDisk, String &stableName, Filesystem **pMountedFs=nullptr)
bool shutdownMountView(Vector< Filesystem * > &ownedBackings)
Filesystem * getRootFilesystem() const
uint64_t namespaceGeneration() const
A vector / dynamic array.
void pushBack(const T &value)