diff options
author | Alexis211 <alexis211@gmail.com> | 2009-11-25 18:42:44 +0100 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-11-25 18:42:44 +0100 |
commit | a40fe1166ab1db972a8ca0380d603c4d90eede62 (patch) | |
tree | f92c2c02d9d78d68f7c116dff9ac508895f757af /Source/Kernel/Core | |
parent | f367fe4e5a7712bafc121ce5c228f15e90fc5c93 (diff) | |
download | Melon-a40fe1166ab1db972a8ca0380d603c4d90eede62.tar.gz Melon-a40fe1166ab1db972a8ca0380d603c4d90eede62.zip |
Re-organized file system stuff.
Diffstat (limited to 'Source/Kernel/Core')
-rw-r--r-- | Source/Kernel/Core/Log.ns.cpp | 5 | ||||
-rw-r--r-- | Source/Kernel/Core/kmain.wtf.cpp | 58 |
2 files changed, 59 insertions, 4 deletions
diff --git a/Source/Kernel/Core/Log.ns.cpp b/Source/Kernel/Core/Log.ns.cpp index 1727024..c8ccd80 100644 --- a/Source/Kernel/Core/Log.ns.cpp +++ b/Source/Kernel/Core/Log.ns.cpp @@ -1,4 +1,5 @@ #include "Log.ns.h" +#include <FileSystems/RamFS/RamFS.class.h> #include <VFS/VFS.ns.h> namespace Log { @@ -11,6 +12,10 @@ void init(u8int loglevel) { if (VFS::find("/System/Logs") == 0) VFS::createDirectory("/System/Logs"); logs[KL_PANIC] = new TextFile("/System/Logs/Panic.log", FM_APPEND); + if (!logs[KL_PANIC]->valid()) { //FS maybee not read/write, mount a ramfs + RamFS::mount(1024*1024, (DirectoryNode*)VFS::find("/System/Logs")); + logs[KL_PANIC] = new TextFile("/System/Logs/Panic.log", FM_APPEND); + } if (KL_CRITICAL <= loglevel) logs[KL_CRITICAL] = new TextFile("/System/Logs/Critical.log", FM_APPEND); if (KL_ERROR <= loglevel) logs[KL_ERROR] = new TextFile("/System/Logs/Error.log", FM_APPEND); if (KL_WARNING <= loglevel) logs[KL_WARNING] = new TextFile("/System/Logs/Warning.log", FM_APPEND); diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp index bb77eeb..1d438ed 100644 --- a/Source/Kernel/Core/kmain.wtf.cpp +++ b/Source/Kernel/Core/kmain.wtf.cpp @@ -115,6 +115,43 @@ void selectVideoMode(SimpleVT& v) { } } +bool mountFS(multiboot_info_t* mbd, String str) { + module_t *mods = (module_t*)mbd->mods_addr; + Vector<String> fs = str.split(":"); + DirectoryNode* root; + if (fs[0] == "/") { + root = NULL; + } else { + FSNode* n = VFS::find(fs[0]); + if (n == NULL) { + *kvt << "Mountpoint does not exist : " << fs[0] << "\n"; + return false; + } + if (n->type() != NT_DIRECTORY) { + *kvt << "Mountpoint is not a directory : " << fs[0] << "\n"; + return false; + } + root = (DirectoryNode*)n; + } + if (fs[1] == "ramfs") { + if (fs[2].toInt() >= mbd->mods_count) { + *kvt << "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); + } else { + if (fs.size() < 5) fs.push("fat"); + BlockDevice* d = Part::dev(fs[1], fs[2].toInt()); + Partition* p = Part::part(d, fs[3].toInt()); + if (fs[4] == "fat") { + FATFS::mount(p, root); + } else { + PANIC("Unknown filesystem type for root file system."); + } + } + return true; +} + void kmain(multiboot_info_t* mbd, u32int magic) { DEBUG("Entering kmain."); @@ -167,13 +204,17 @@ void kmain(multiboot_info_t* mbd, u32int magic) { //*************************************** PARSE COMMAND LINE Vector<String> opts = kcmdline.split(" "); - String keymap = "fr", init = "/System/Applications/PaperWork.app"; + String keymap = "builtin", init = "/System/Applications/PaperWork.app"; + String root = "ramfs:0"; + Vector<String> mount; bool enableVESA = true; for (u32int i = 0; i < opts.size(); i++) { Vector<String> opt = opts[i].split(":"); if (opt[0] == "vesa" && opt[1] != "enabled") enableVESA = false; if (opt[0] == "keymap") keymap = opt[1]; if (opt[0] == "init") init = opt[1]; + if (opt[0] == "root") root = opts[i].substr(5); + if (opt[0] == "mount") mount.push(opts[i].substr(6)); } //*************************************** DEVICE SETUP @@ -183,14 +224,23 @@ void kmain(multiboot_info_t* mbd, u32int magic) { if (enableVESA) Dev::registerDevice(new VESADisplay()); FloppyController::detect(); - //*************************************** MOUNT ROOT FILESYSTEM + //*************************************** MOUNT FILESYSTEMS - RamFS::mount((u8int*)mods[0].mod_start, 1024 * 1024, NULL); + { // mount root filesystem + if (!mountFS(mbd, String("/:") += root)) PANIC("Cannot mount root filesystem."); + } DirectoryNode* cwd; cwd = VFS::getRootNode(); Task::currProcess()->setCwd(cwd); - FATFS::mount(Part::partitions[0], (DirectoryNode*)VFS::createDirectory("/Mount")); + // mount other filesystems + for (u32int i = 0; i < mount.size(); i++) { + mountFS(mbd, mount[i]); + } + + //FATFS::mount(Part::partitions[0], (DirectoryNode*)VFS::createDirectory("/Mount")); + + //*************************************** LOAD SYSTEM STUFF if (keymap != "builtin") { if (!Kbd::loadKeymap(keymap)) *kvt << "\nWARNING : Could not load keymap " << keymap << ", using built-in keymap instead."; |