diff options
Diffstat (limited to 'src/kernel/core')
-rw-r--r-- | src/kernel/core/kmain.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/kernel/core/kmain.cpp b/src/kernel/core/kmain.cpp index 9ec06df..58a3c48 100644 --- a/src/kernel/core/kmain.cpp +++ b/src/kernel/core/kmain.cpp @@ -8,6 +8,7 @@ #include <mem/mem.h> #include <vfs/node.h> +#include <vfs/initrd.h> #include <task/idt.h> #include <task/timer.h> @@ -76,16 +77,30 @@ extern "C" void kmain(multiboot_info_t* mbd, int32_t magic) { // Load modules *ke_vt << "Loading modules :\n"; for (unsigned i = 0; i < mbd->mods_count; i++) { - *ke_vt << " * " << (char*)mods[i].string; + char* cmd = (char*)mods[i].string; + *ke_vt << " * " << cmd << " \t"; if (elf_check((uint8_t*)mods[i].mod_start) == 0) { process *pr = elf_exec((uint8_t*)mods[i].mod_start, PL_USER); if (pr == 0) { - *ke_vt << " : Error loading\n"; + *ke_vt << "Error loading\n"; } else { - *ke_vt << " : OK, pid=" << (int)pr->pid << "\n"; + *ke_vt << "OK, pid=" << (int)pr->pid << "\n"; + } + } else if (initrd_check((uint8_t*)mods[i].mod_start) == 0) { + vdir* fs = new vdir(root); + int e = initrd_load((uint8_t*)mods[i].mod_start, fs); + if (e == 0) { + char* name = cmd; + for (char* i = name; *i != 0; i++) { + if (*i == '/' || *i == ' ') name = i + 1; + } + root->add_child(name, fs); + *ke_vt << "OK, initrd as /" << name << "/\n"; + } else { + *ke_vt << "initrd but error " << e << "\n"; } } else { - *ke_vt << " : Invalid ELF file\n"; + *ke_vt << "Invalid file, neither ELF nor initrd.\n"; } } |