diff options
author | Alexis211 <alexis211@gmail.com> | 2009-11-15 13:17:58 +0100 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-11-15 13:17:58 +0100 |
commit | 21bfca4ad4b84768f05eb4fa2bc0ad7a76b6c536 (patch) | |
tree | 7e68b92e80aadec75b5263bd9058c8336d29b77b /Source/Kernel/Shell | |
parent | e48f1166ae7402f973ea4aab8e53c7612459048c (diff) | |
download | Melon-21bfca4ad4b84768f05eb4fa2bc0ad7a76b6c536.tar.gz Melon-21bfca4ad4b84768f05eb4fa2bc0ad7a76b6c536.zip |
Mount points seem to work, mostly owing to dark magic.
Diffstat (limited to 'Source/Kernel/Shell')
-rw-r--r-- | Source/Kernel/Shell/KernelShell.class.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Source/Kernel/Shell/KernelShell.class.cpp b/Source/Kernel/Shell/KernelShell.class.cpp index d62d822..8f71b9f 100644 --- a/Source/Kernel/Shell/KernelShell.class.cpp +++ b/Source/Kernel/Shell/KernelShell.class.cpp @@ -4,6 +4,7 @@ #include <SimpleList.class.h> #include <MemoryManager/PhysMem.ns.h> #include <VFS/VFS.ns.h> +#include <FileSystems/RamFS/RamFS.class.h> #include <TaskManager/Task.ns.h> u32int KernelShell::m_instances = 0; @@ -92,6 +93,52 @@ u32int KernelShell::run() { } else if (tokens[0] == "exit") { if (tokens.size() == 1) return 0; return tokens[1].toInt(); + } else if (tokens[0] == "mount") { + if (tokens.size() == 1) { + for (u32int i = 0; i < VFS::filesystems.size(); i++) { + *m_vt << VFS::path(VFS::filesystems[i]->getRootNode()) << "\n"; + } + } else if (tokens.size() == 3) { + if (tokens[1] == "ramfs") { + FSNode* n = VFS::find(tokens[2], m_cwd); + if (n == 0) { + *m_vt << "No such directory.\n"; + } else if (n->type() != NT_DIRECTORY) { + *m_vt << "Not a directory.\n"; + } else { + if (RamFS::mount(100000, (DirectoryNode*)n) != 0) { + *m_vt << "Ok...\n"; + } else { + *m_vt << "Error !\n"; + } + } + } else { + *m_vt << "Not supported yet.\n"; + } + } else { + *m_vt << "Usage: mount [<device> <mountpoint>\n"; + } + } else if (tokens[0] == "unmount") { + if (tokens.size() == 2) { + FSNode* n = VFS::find(tokens[1], m_cwd); + bool ok = false; + if (n == 0) { + ok = false; + } else { + String p = VFS::path(n); + for (u32int i = 0; i < VFS::filesystems.size(); i++) { + if (VFS::path(VFS::filesystems[i]->getRootNode()) == p) { + VFS::unmount(VFS::filesystems[i]); + ok = true; + break; + } + } + } + if (ok) *m_vt << "Ok, filesystem unmounted.\n"; + else *m_vt << "Error.\n"; + } else { + *m_vt << "Usage: unmount <mountpoint>\n"; + } } else if (tokens[0] != "" or tokens.size() != 1) { u32int i = 0; bool found = false; |