From daa6c2450fa0646619698f0dc01b0456b2541317 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Fri, 18 May 2012 15:15:57 +0200 Subject: Added process arguments when loaded as modules. --- src/kernel/core/kmain.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/kernel/core') diff --git a/src/kernel/core/kmain.cpp b/src/kernel/core/kmain.cpp index 58a3c48..96c4050 100644 --- a/src/kernel/core/kmain.cpp +++ b/src/kernel/core/kmain.cpp @@ -80,7 +80,25 @@ extern "C" void kmain(multiboot_info_t* mbd, int32_t magic) { 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); + + char *args[16] = { cmd, 0 }; + int a = 1; + for (char* c = cmd; c != 0; c++) { + if (*c == ' ') { + *c = 0; + args[a] = c + 1; + a++; + if (a == 15) { + args[a] = 0; + break; + } + } else if (*c == 0) { + args[a] = 0; + break; + } + } + + process *pr = elf_exec((uint8_t*)mods[i].mod_start, PL_USER, args); // todo add args if (pr == 0) { *ke_vt << "Error loading\n"; } else { -- cgit v1.2.3