2#include "pedigree/kernel/syscallError.h"
3#include "pedigree/kernel/utilities/Pointers.h"
7VFS::NamespaceMutation::NamespaceMutation(
VFS& vfs) : m_Vfs(vfs), m_Lock(vfs.m_PathMutationLock) {
8 __atomic_add_fetch(&m_Vfs.m_PathGeneration, 1, __ATOMIC_ACQ_REL);
10VFS::NamespaceMutation::~NamespaceMutation() {
11 __atomic_add_fetch(&m_Vfs.m_PathGeneration, 1, __ATOMIC_RELEASE);
13uint64_t VFS::NamespaceMutation::generation()
const {
14 return m_Vfs.namespaceGeneration();
17 return __atomic_load_n(&m_PathGeneration, __ATOMIC_ACQUIRE);
20 return __atomic_load_n(&m_MountView, __ATOMIC_ACQUIRE);
23 auto* view = mountView();
26 if (!view->shutdown(ownedBackings))
28 __atomic_store_n(&m_MountView,
static_cast<VfsMountView*
>(
nullptr), __ATOMIC_RELEASE);
32bool VFS::initialiseMountView() {
39 if (!view.get()->createBootContext(bootstrap))
41 auto context = bootstrap.reference();
45 if (!importedPoints.tryReserve(mounts.
count())) {
46 SYSCALL_ERROR(OutOfMemory);
50 options.requireDirectory =
true;
51 options.crossFinalMount =
false;
52 for (
const auto&
mount : mounts) {
59 !view.get()->attach(context, point, backing))
61 importedPoints.
pushBack(pedigree_std::move(point));
66 NamespaceMutation writer(*
this);
68 SYSCALL_ERROR(DeviceBusy);
73 for (
const auto& point : importedPoints)
74 Directory::fromFile(point->node())->setReparsePoint(nullptr);
75 __atomic_store_n(&m_MountView, view.releaseOwnership(), __ATOMIC_RELEASE);
static UniquePointer< T > adopt(T *pointer)
Filesystem * getFilesystemAt(const String &path) const
bool mount(Disk *pDisk, String &stableName, Filesystem **pMountedFs=nullptr)
void getMounts(Vector< MountSnapshot > &mounts) const
bool shutdownMountView(Vector< Filesystem * > &ownedBackings)
Filesystem * getRootFilesystem() const
uint64_t namespaceGeneration() const
A vector / dynamic array.
void pushBack(const T &value)