summaryrefslogtreecommitdiff
path: root/Source/Kernel/VFS/DirectoryNode.class.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel/VFS/DirectoryNode.class.cpp')
-rw-r--r--Source/Kernel/VFS/DirectoryNode.class.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/Source/Kernel/VFS/DirectoryNode.class.cpp b/Source/Kernel/VFS/DirectoryNode.class.cpp
index 74c1ff8..55365f0 100644
--- a/Source/Kernel/VFS/DirectoryNode.class.cpp
+++ b/Source/Kernel/VFS/DirectoryNode.class.cpp
@@ -6,6 +6,15 @@ call_t DirectoryNode::m_callTable[] = {
CALL0(0, 0)
};
+DirectoryNode::~DirectoryNode() {
+ if (m_contentLoaded) {
+ for (u32int i = 0; i < m_children.size(); i++) {
+ delete m_children[i];
+ }
+ }
+ if (m_name == "/" && m_parent != NULL) ((DirectoryNode*)(m_parent))->unmount();
+}
+
u32int DirectoryNode::getIdxChildSC(u32int idx) {
if (!runnable()) return (u32int) - 1;
FSNode* n = getChild(idx);
@@ -21,15 +30,29 @@ u32int DirectoryNode::getNameChildSC(u32int name) {
return (u32int) - 1;
}
+u64int DirectoryNode::getLength() {
+ if (m_mounts != 0) return m_mounts->getLength();
+ if (!m_contentLoaded)
+ if (!loadContent())
+ return 0;
+ return m_length;
+}
+
+FSNode* DirectoryNode::getParent() {
+ //if (m_name == "/" and m_parent != 0) return m_parent->getParent();
+ return m_parent;
+}
+
bool DirectoryNode::removable() {
if (!m_contentLoaded)
if (!loadContent())
return false;
- return m_children.empty();
+ return m_children.empty() && (m_mounts == 0);
}
bool DirectoryNode::unmountable() {
if (!m_contentLoaded) return true;
+ if (m_mounts != 0) return false;
for (u32int i = 0; i < m_children.size(); i++) {
if (m_children[i]->type() == NT_DIRECTORY) {
if (!((DirectoryNode*)m_children[i])->unmountable()) return false;
@@ -40,7 +63,22 @@ bool DirectoryNode::unmountable() {
return true;
}
+bool DirectoryNode::mountpointable() {
+ if (!m_contentLoaded)
+ if (!loadContent()) return false;
+ return m_children.empty();
+}
+
+void DirectoryNode::mount(DirectoryNode* childRoot) {
+ m_mounts = childRoot;
+}
+
+void DirectoryNode::unmount() {
+ m_mounts = 0;
+}
+
bool DirectoryNode::loadContent() {
+ if (m_mounts != 0) return m_mounts->loadContent();
if (m_contentLoaded) return true;
bool b = m_fs->loadContents(this);
if (!b) return false;
@@ -50,6 +88,7 @@ bool DirectoryNode::loadContent() {
}
FSNode* DirectoryNode::getChild(u32int index) {
+ if (m_mounts != 0) return m_mounts->getChild(index);
if (!m_contentLoaded)
if (!loadContent())
return NULL;
@@ -58,6 +97,7 @@ FSNode* DirectoryNode::getChild(u32int index) {
}
FSNode* DirectoryNode::getChild(const String& name) {
+ if (m_mounts != 0) return m_mounts->getChild(name);
if (!m_contentLoaded)
if (!loadContent())
return NULL;
@@ -69,18 +109,21 @@ FSNode* DirectoryNode::getChild(const String& name) {
}
FileNode* DirectoryNode::createFile(const String& name) {
+ if (m_mounts != 0) return m_mounts->createFile(name);
FileNode* n = m_fs->createFile(this, name);
m_length = m_children.size();
return n;
}
DirectoryNode* DirectoryNode::createDirectory(const String& name) {
+ if (m_mounts != 0) return m_mounts->createDirectory(name);
DirectoryNode* n = m_fs->createDirectory(this, name);
m_length = m_children.size();
return n;
}
bool DirectoryNode::remove(FSNode* child) {
+ if (m_mounts != 0) return m_mounts->remove(child);
//Check node is indeed one of our childs
if (!m_contentLoaded)
if (!loadContent())