diff options
author | Alexis211 <alexis211@gmail.com> | 2009-11-29 17:06:47 +0100 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-11-29 17:06:47 +0100 |
commit | 32ffa508b6ee9c9b36e3a054d218ee90caea4c8b (patch) | |
tree | 4136164e7fb52005d57782c9ae70da89eca85807 /Source/Kernel/VFS | |
parent | 2be9def10e048b3245bb14e9fb57324c11c527d6 (diff) | |
download | Melon-32ffa508b6ee9c9b36e3a054d218ee90caea4c8b.tar.gz Melon-32ffa508b6ee9c9b36e3a054d218ee90caea4c8b.zip |
make qemu-hdd now works great
Diffstat (limited to 'Source/Kernel/VFS')
-rw-r--r-- | Source/Kernel/VFS/FileSystem.proto.h | 8 | ||||
-rw-r--r-- | Source/Kernel/VFS/VFS.ns.cpp | 26 |
2 files changed, 27 insertions, 7 deletions
diff --git a/Source/Kernel/VFS/FileSystem.proto.h b/Source/Kernel/VFS/FileSystem.proto.h index 9216219..172c82c 100644 --- a/Source/Kernel/VFS/FileSystem.proto.h +++ b/Source/Kernel/VFS/FileSystem.proto.h @@ -14,6 +14,8 @@ namespace VFS { //This abstract class describes a filesystem class FileSystem { friend bool VFS::unmount(FileSystem*); + private: + String m_identifier; protected: virtual ~FileSystem(); @@ -26,8 +28,6 @@ class FileSystem { bool isWritable() { return m_isWritable; } DirectoryNode* getRootNode() { return m_rootNode; } - virtual String getDevDescription() = 0; - //Must be implemented by the filesystem virtual bool setName(FSNode* node, String name) = 0; virtual bool setPermissions(FSNode* node, u32int permissions) = 0; @@ -43,6 +43,10 @@ class FileSystem { virtual FileNode* createFile(DirectoryNode* parent, String name) = 0; virtual DirectoryNode* createDirectory(DirectoryNode* parent, String name) = 0; virtual bool remove(DirectoryNode* parent, FSNode* node) = 0; + + virtual Partition* getPart() = 0; + void setIdentifier(String s) { m_identifier = s; } + String getIdentifier() { return m_identifier; } }; #endif diff --git a/Source/Kernel/VFS/VFS.ns.cpp b/Source/Kernel/VFS/VFS.ns.cpp index 3b59c5a..cf68653 100644 --- a/Source/Kernel/VFS/VFS.ns.cpp +++ b/Source/Kernel/VFS/VFS.ns.cpp @@ -75,15 +75,23 @@ bool mount(String str, VirtualTerminal* vt, multiboot_info_t *mbd) { *vt << "Invalid module number for filesystem to mount on " << fs[0] << "\n"; return false; } - RamFS::mount((u8int*)mods[fs[2].toInt()].mod_start, 1024 * 1024, root); - return true; + FileSystem* wat = RamFS::mount((u8int*)mods[fs[2].toInt()].mod_start, 1024 * 1024, root); + if (wat != NULL) { + wat->setIdentifier(str); + return true; + } + return false; } else { *vt << "Cannot mount kernel modules outside of kernel command line.\n"; return false; } } else { - RamFS::mount(1024 * 1024, root); - return true; + FileSystem* wat = RamFS::mount(1024 * 1024, root); + if (wat != NULL) { + wat->setIdentifier(str); + return true; + } + return false; } } else { if (fs.size() < 4) { @@ -94,9 +102,17 @@ bool mount(String str, VirtualTerminal* vt, multiboot_info_t *mbd) { if (fs.size() < 6) fs.push("ro"); //By default, mount file systems read-only BlockDevice* d = Part::dev(fs[1], fs[2].toInt()); Partition* p = Part::part(d, fs[3].toInt()); + for (u32int i = 0; i < filesystems.size(); i++) { + if (filesystems[i]->getPart() == p) { + *vt << "Cannot mount " << str << " : partition already mounted.\n"; + return false; + } + } for (u32int i = 0; fileSystems[i].cb != 0; i++) { if (fs[4] == fileSystems[i].name or fs[4] == "") { - if (fileSystems[i].cb(p, root, (fs[5] == "rw")) != NULL) { + FileSystem* mounted = fileSystems[i].cb(p, root, (fs[5] == "rw")); + if (mounted != NULL) { + mounted->setIdentifier(str); return true; } else if (fs[4] != "") { *vt << "Could not mount filesystem on " << fs[0] << "\n"; |