netinit: accept URL as argument; add boot option

This commit is contained in:
K. Lange 2018-12-03 10:21:29 +09:00
parent b8f0485e3c
commit 4fa1645ff0
2 changed files with 17 additions and 6 deletions

View File

@ -41,6 +41,7 @@ EFI_HANDLE ImageHandleIn;
#define DEFAULT_VID_CMDLINE "vid=auto,1440,900 "
#define DEFAULT_PRESET_VID_CMDLINE "vid=preset "
#define DEFAULT_NETINIT_CMDLINE "init=/dev/ram0 "
#define NETINIT_REMOTE_URL "args=http://toaruos.org/ramdisk-1.9.3.img "
#define MIGRATE_CMDLINE "migrate "
#define DEBUG_LOG_CMDLINE "logtoserial=warning "
#define DEBUG_SERIAL_CMDLINE "kdebug "
@ -167,9 +168,13 @@ int kmain() {
"Start a kernel debug shell on the first",
"serial port.");
BOOT_OPTION(_netinit, 0, "Netinit",
BOOT_OPTION(_netinit, 0, "Netinit (QEMU local)",
"Downloads a userspace filesystem from a local",
"HTTP server and extracts it at boot.");
BOOT_OPTION(_netinitr, 0, "Netinit (toaruos.org)",
"Downloads a userspace filesystem from a remote",
"server and extracts it at boot.");
"HTTP server and extracts it at boot.");
#ifdef EFI_PLATFORM
BOOT_OPTION(_efilargest, 0, "Prefer largest mode.",
@ -193,9 +198,12 @@ int kmain() {
show_menu();
/* Build our command line. */
if (_netinit) {
if (_netinit || _netinitr) {
strcat(cmdline, DEFAULT_NETINIT_CMDLINE);
ramdisk_path = "NETINIT.";
if (_netinitr) {
strcat(cmdline, NETINIT_REMOTE_URL);
}
} else {
strcat(cmdline, DEFAULT_ROOT_CMDLINE);

View File

@ -25,7 +25,7 @@
#include <getopt.h>
#include <syscall.h>
#define NETBOOT_URL "http://10.0.2.1:8080/netboot.img"
#define DEFAULT_URL "http://10.0.2.1:8080/netboot.img"
#include <pthread.h>
#include <kernel/video.h>
@ -534,7 +534,11 @@ int main(int argc, char * argv[]) {
struct http_req my_req;
/* TODO: Extract URL from kcmdline */
parse_url(NETBOOT_URL, &my_req);
if (argc < 2) {
parse_url(DEFAULT_URL, &my_req);
} else {
parse_url(argv[1], &my_req);
}
char file[100];
sprintf(file, "/dev/net/%s:%d", my_req.domain, my_req.port);
@ -707,7 +711,6 @@ int main(int argc, char * argv[]) {
TRACE("Executing init...\n");
char * const _argv[] = {
"/bin/init",
argv[1],
NULL,
};
execve("/bin/init",_argv,NULL);