summaryrefslogtreecommitdiff
path: root/Source/Kernel/FileSystems/RamFS
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-09-26 22:17:03 +0200
committerAlexis211 <alexis211@gmail.com>2009-09-26 22:17:03 +0200
commit021831ab981b9df22cd1ac5e5ac51f0f84ef49a7 (patch)
tree90e9eeab0c0f72d65ba4e4ac6a798aa2ae05d7b3 /Source/Kernel/FileSystems/RamFS
parent5d7ad3933bc2de69c2b7d09791adf305de019d8a (diff)
downloadMelon-021831ab981b9df22cd1ac5e5ac51f0f84ef49a7.tar.gz
Melon-021831ab981b9df22cd1ac5e5ac51f0f84ef49a7.zip
Nothing intresting
Diffstat (limited to 'Source/Kernel/FileSystems/RamFS')
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFS.class.cpp47
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFS.class.h9
2 files changed, 41 insertions, 15 deletions
diff --git a/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp b/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
index ca8dd21..a224bf8 100644
--- a/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
+++ b/Source/Kernel/FileSystems/RamFS/RamFS.class.cpp
@@ -2,18 +2,29 @@
#include <VFS/DirectoryNode.class.h>
#include "RamFileNode.class.h"
-RamFS::RamFS(u32int maxSize) {
- m_maxSize = maxSize;
- m_usedSize = 0;
- m_isWritable = true;
- m_rootNode = new DirectoryNode("/", this, NULL);
+RamFS::RamFS() {
}
-RamFS::RamFS(u8int *ptr, u32int maxSize, bool writable) {
- m_maxSize = maxSize;
- m_usedSize = 0;
- m_isWritable = true;
- m_rootNode = new DirectoryNode("/", this, NULL);
+RamFS::~RamFS() {
+ delete m_rootNode;
+}
+
+RamFS* RamFS::mount(u32int maxSize, DirectoryNode* mountpoint) {
+ RamFS* rfs = new RamFS();
+ rfs->m_maxSize = maxSize;
+ rfs->m_usedSize = 0;
+ rfs->m_isWritable = true;
+ rfs->m_rootNode = new DirectoryNode("/", rfs, mountpoint);
+ return rfs;
+}
+
+RamFS* RamFS::mount(u8int *ptr, u32int maxSize, DirectoryNode* mountpoint, bool writable) {
+ RamFS* rfs = new RamFS();
+
+ rfs->m_maxSize = maxSize;
+ rfs->m_usedSize = 0;
+ rfs->m_isWritable = true;
+ rfs->m_rootNode = new DirectoryNode("/", rfs, mountpoint);
union {
u8int* c;
@@ -22,7 +33,11 @@ RamFS::RamFS(u8int *ptr, u32int maxSize, bool writable) {
} curr;
curr.c = ptr;
- if (curr.i->magic != INITRD_MAGIC) return;
+ if (curr.i->magic != INITRD_MAGIC) {
+ delete rfs;
+ return NULL;
+ }
+
u32int files = curr.i->files;
curr.i++; //Increment pointer of size of initrd header
for (u32int i = 0; i < files; i++) {
@@ -32,12 +47,12 @@ RamFS::RamFS(u8int *ptr, u32int maxSize, bool writable) {
String name((const char*)(curr.c));
curr.c += h.name_length + 1; //Increment pointer of length of name
- //Find out a vector conaining parent directories, and set name to the effective file name
+ //Find out a vector containing parent directories, and set name to the effective file name
if (name[0] == WChar("/")) name = name.substr(1, name.size() - 1);
//Find node for parent directory
String mname = "";
- DirectoryNode* parent = m_rootNode;
+ DirectoryNode* parent = rfs->m_rootNode;
for (u32int i = 0; i < name.size(); i++) {
if (name[i] == WChar("/")) {
FSNode* n = parent->getChild(mname);
@@ -61,6 +76,12 @@ RamFS::RamFS(u8int *ptr, u32int maxSize, bool writable) {
}
}
}
+
+ return rfs;
+}
+
+bool RamFS::unmount() {
+ return m_rootNode->unmountable();
}
bool RamFS::setName(FSNode* node, String name) { return true; }
diff --git a/Source/Kernel/FileSystems/RamFS/RamFS.class.h b/Source/Kernel/FileSystems/RamFS/RamFS.class.h
index 0a3f0c4..1d60796 100644
--- a/Source/Kernel/FileSystems/RamFS/RamFS.class.h
+++ b/Source/Kernel/FileSystems/RamFS/RamFS.class.h
@@ -17,12 +17,17 @@ struct initrd_file_header {
class RamFS : public FileSystem {
private:
+ ~RamFS();
+ RamFS(const RamFS& other);
+ RamFS();
+ bool unmount(); //TO BE USED ONLY BY VFS::UNMOUNT (when will exist...)
+
u32int m_maxSize;
u32int m_usedSize;
public:
- RamFS(u32int maxSize); //Creates an empty RAM file system
- RamFS(u8int* ptr, u32int maxSize, bool writable = true); //Creates a RAM file system from data loaded in memory. format to be defined
+ static RamFS* mount(u32int maxSize, DirectoryNode* mountpoint); //Creates an empty RAM file system
+ static RamFS* mount(u8int* ptr, u32int maxSize, DirectoryNode* mountpoint, bool writable = true); //Creates a RAM file system from data loaded in memory. format to be defined
bool setName(FSNode* node, String name);
bool setPermissions(FSNode* node, u32int permissions);