2#include "pedigree/kernel/syscallError.h"
4#include "MountView-internal.h"
8 if (!parent || parent->provider() != view || !parent->node()->
isDirectory()) {
9 SYSCALL_ERROR(NotADirectory);
12 if (!name.length() || name ==
"." || name ==
"..") {
13 SYSCALL_ERROR(InvalidArgument);
16 for (
size_t i = 0; i < name.length(); ++i) {
18 SYSCALL_ERROR(InvalidArgument);
23 SYSCALL_ERROR(DoesNotExist);
26 if (parent->node()->getFilesystem()->
isReadOnly()) {
27 SYSCALL_ERROR(ReadOnlyFilesystem);
35 if (status == Directory::LookupStatus::NotFound)
37 syscallError(status == Directory::LookupStatus::Found ? Error::FileExists
38 : status ==
Directory::LookupStatus::Retry ? Error::NoMoreProcesses
44bool VfsMountView::isMountpoint(
File* node)
const {
45 if (!m_State || !node)
48 for (
auto* row = m_State->attachments; row; row = row->next)
49 if (row->covered && row->covered->get() == node)
55 return validParent(parent, name,
this) && absent(parent, name) &&
56 parent->node()->getFilesystem()->
createFile(parent->node(), name, mask);
60 return validParent(parent, name,
this) && absent(parent, name) &&
61 parent->node()->getFilesystem()->
createDirectory(parent->node(), name, mask);
65 return validParent(parent, name,
this) && absent(parent, name) &&
66 parent->node()->getFilesystem()->
createSymlink(parent->node(), name, value);
70 if (!validParent(parent, name,
this))
72 auto* source = m_State->path(target);
73 auto* destination = m_State->path(parent);
74 if (!source || source->attachment.get() != destination->attachment.get()) {
75 SYSCALL_ERROR(CrossDeviceLink);
80 SYSCALL_ERROR(NotEnoughPermissions);
84 SYSCALL_ERROR(OperationNotSupported);
87 return absent(parent, name) &&
88 parent->node()->getFilesystem()->
createLink(parent->node(), name, target->node());
91 return validParent(parent, name,
this) &&
92 parent->node()->getFilesystem()->
removeChild(parent->node(), name, expected);
96 bool sourceMustBeDirectory) {
97 if (!validParent(oldParent, oldName,
this) || !validParent(newParent, newName,
this))
99 if (m_State->path(oldParent)->attachment.
get() != m_State->path(newParent)->attachment.
get()) {
100 SYSCALL_ERROR(CrossDeviceLink);
103 return oldParent->node()->getFilesystem()->renameChildren(
104 oldParent->node(), oldName, newParent->node(), newName, noReplace, sourceMustBeDirectory);
static Directory * fromFile(File *pF)
MUST_USE_RESULT LookupStatus lookupChild(const HashedStringView &s, ChildLease &child) const
virtual bool isSocket() const
virtual bool isDirectory()
virtual bool isFifo() const
virtual bool isPipe() const
bool removeChild(File *parent, const String &filename, File *expected)
bool createSymlink(const StringView &path, const String &value, File *pStartNode=0)
bool createDirectory(const StringView &path, uint32_t mask, File *pStartNode=0)
bool createLink(const StringView &path, File *target, File *pStartNode=0)
bool createFile(const StringView &path, uint32_t mask, File *pStartNode=0)
static bool checkAccess(File *pFile, bool bRead, bool bWrite, bool bExecute)