2#include "pedigree/kernel/syscallError.h"
4#include "MountView-internal.h"
9 if (!writer.protects(view.m_Vfs) || !path(reference) || !path(context.root)) {
10 SYSCALL_ERROR(InvalidArgument);
15 for (
size_t depth = 0; depth < 4096; ++depth) {
16 if (view.samePath(current, context.root)) {
17 result = suffix.length() ? pedigree_std::move(suffix) :
String(
"/");
20 auto* entry = path(current);
21 if (entry->node() == entry->attachment->root) {
26 auto* row = find(entry->attachment->id);
29 covered = row->covered;
32 if (!parent || !covered) {
33 SYSCALL_ERROR(DoesNotExist);
37 if (!makePath(parent, covered->
get(), mountpoint))
39 current = pedigree_std::move(mountpoint);
44 entry->node()->getNamespace(parent, name);
45 if (!parent.get() || !name.length()) {
46 SYSCALL_ERROR(DoesNotExist);
52 if (component.length() >= 4096) {
53 SYSCALL_ERROR(NameTooLong);
56 suffix = pedigree_std::move(component);
58 if (!makePath(entry->attachment, parent.get(), next))
60 current = pedigree_std::move(next);
62 SYSCALL_ERROR(LoopExists);
73 if (context.topologyGeneration != m_State->topology) {
74 SYSCALL_ERROR(NoMoreProcesses);
78 return m_State->format(context, path, result, writer);
83 if (!m_State || !context)
87 uint64_t parentId = 0;
93 if (!context->snapshot(fs))
98 for (
auto* row = m_State->attachments; row; row = row->next)
101 if (!rows.tryReserve(count) || !snapshots.tryReserve(count)) {
102 SYSCALL_ERROR(OutOfMemory);
107 for (
auto* row = m_State->attachments; row; row = row->next) {
109 copy.attachment = row->attachment;
110 copy.parentId = row->parent ? row->parent->id : row->attachment->id;
111 rows.
pushBack(pedigree_std::move(copy));
114 for (
auto& row : rows) {
116 MountSnapshot snapshot;
117 if (!m_State->makePath(row.attachment, row.attachment->root, root))
119 if (m_State->path(fs.root)->attachment.
get() == row.attachment.get()) {
120 snapshot.path =
String(
"/");
122 if (!m_State->beneath(root, fs.root))
124 if (!m_State->format(fs, root, snapshot.path, writer))
127 snapshot.id = row.attachment->id;
128 snapshot.parentId = row.parentId;
129 snapshot.backing = row.attachment->backing.identity();
130 snapshots.
pushBack(pedigree_std::move(snapshot));
132 result.
swap(snapshots);
A vector / dynamic array.
void pushBack(const T &value)
void swap(Iterator a, Iterator b)