summaryrefslogtreecommitdiff
path: root/Source/Kernel/FileSystems/RamFS
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel/FileSystems/RamFS')
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFS.class.cpp11
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFS.class.h6
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFileNode.class.h2
3 files changed, 15 insertions, 4 deletions
diff --git a/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp b/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
index 5997841..e6370d0 100644
--- a/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
+++ b/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
@@ -1,30 +1,36 @@
#include "RamFS.class.h"
#include <VFS/DirectoryNode.class.h>
#include "RamFileNode.class.h"
+#include <VFS/VFS.ns.h>
RamFS::RamFS() {
}
RamFS::~RamFS() {
- delete m_rootNode;
}
RamFS* RamFS::mount(u32int maxSize, DirectoryNode* mountpoint) {
+ if (mountpoint != 0 and !mountpoint->mountpointable()) return 0;
RamFS* rfs = new RamFS();
rfs->m_maxSize = maxSize;
rfs->m_usedSize = 0;
rfs->m_isWritable = true;
rfs->m_rootNode = new DirectoryNode("/", rfs, mountpoint);
+ if (mountpoint != 0) mountpoint->mount(rfs->m_rootNode);
+ VFS::registerFilesystem(rfs);
return rfs;
}
RamFS* RamFS::mount(u8int *ptr, u32int maxSize, DirectoryNode* mountpoint, bool writable) {
+ if (mountpoint != 0 and !mountpoint->mountpointable()) return 0;
RamFS* rfs = new RamFS();
rfs->m_maxSize = maxSize;
rfs->m_usedSize = 0;
rfs->m_isWritable = true;
rfs->m_rootNode = new DirectoryNode("/", rfs, mountpoint);
+ if (mountpoint != 0) mountpoint->mount(rfs->m_rootNode);
+ VFS::registerFilesystem(rfs);
union {
u8int* c;
@@ -81,7 +87,7 @@ RamFS* RamFS::mount(u8int *ptr, u32int maxSize, DirectoryNode* mountpoint, bool
}
bool RamFS::unmount() {
- return m_rootNode->unmountable();
+ return true;
}
bool RamFS::setName(FSNode* node, String name) { return true; }
@@ -164,6 +170,7 @@ bool RamFS::remove(DirectoryNode* parent, FSNode* node) {
if (node->type() == NT_FILE) {
u8int *d = ((RamFileNode*)node)->m_data;
if (d != 0) Mem::free(d);
+ ((RamFileNode*)node)->m_data = 0;
}
return true;
}
diff --git a/Source/Kernel/FileSystems/RamFS/RamFS.class.h b/Source/Kernel/FileSystems/RamFS/RamFS.class.h
index 1d60796..0368e60 100644
--- a/Source/Kernel/FileSystems/RamFS/RamFS.class.h
+++ b/Source/Kernel/FileSystems/RamFS/RamFS.class.h
@@ -17,10 +17,10 @@ struct initrd_file_header {
class RamFS : public FileSystem {
private:
- ~RamFS();
+ virtual ~RamFS();
RamFS(const RamFS& other);
RamFS();
- bool unmount(); //TO BE USED ONLY BY VFS::UNMOUNT (when will exist...)
+ bool unmount();
u32int m_maxSize;
u32int m_usedSize;
@@ -43,6 +43,8 @@ class RamFS : public FileSystem {
FileNode* createFile(DirectoryNode* parent, String name);
DirectoryNode* createDirectory(DirectoryNode* parent, String name);
bool remove(DirectoryNode* parent, FSNode* node);
+
+ Partition* getPart() { return 0; }
};
#endif
diff --git a/Source/Kernel/FileSystems/RamFS/RamFileNode.class.h b/Source/Kernel/FileSystems/RamFS/RamFileNode.class.h
index d600630..2abad64 100644
--- a/Source/Kernel/FileSystems/RamFS/RamFileNode.class.h
+++ b/Source/Kernel/FileSystems/RamFS/RamFileNode.class.h
@@ -11,6 +11,8 @@ class RamFileNode : public FileNode {
u32int uid = 0, u32int gid = 0) :
FileNode(name, fs, parent, 0, permissions, uid, gid), m_data(0) {}
+ ~RamFileNode() { if (m_data != 0) delete m_data; }
+
u8int *m_data; //We don't take care of allocation/freeing here, RamFS:: does that for us
void setLength(u32int length) { m_length = length; }