From dd60fe4d37eb5473dcf789f3a7f2afba92282efa Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 24 Oct 2020 11:30:06 +0330 Subject: [PATCH] Kernel: Optionally take some arguments to pass to the init program This makes it possible to start _everything_ under UserspaceEmulator, by setting `init_args` to `--report-to-debug,/bin/SystemServer` and `init` to `/bin/UserspaceEmulator`. With the UE patches before this, we get to spawn WindowServer, and crash because of FLD_RM32 (nothing tested past that) in graphical mode. But we get a working shell in text mode :^) (and DHCPClient fails when setting whatever settings it has received) --- Kernel/init.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 7a6751a32a..70f2e4ac25 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -358,7 +358,10 @@ void init_stage2() tty0->set_graphical(!text_mode); RefPtr thread; auto userspace_init = kernel_command_line().lookup("init").value_or("/bin/SystemServer"); - Process::create_user_process(thread, userspace_init, (uid_t)0, (gid_t)0, ProcessID(0), error, {}, {}, tty0); + auto init_args = kernel_command_line().lookup("init_args").value_or("").split(','); + if (!init_args.is_empty()) + init_args.prepend(userspace_init); + Process::create_user_process(thread, userspace_init, (uid_t)0, (gid_t)0, ProcessID(0), error, move(init_args), {}, tty0); if (error != 0) { klog() << "init_stage2: error spawning SystemServer: " << error; Processor::halt();