Allow esoteric boot configs
This commit is contained in:
parent
153571098d
commit
9901f15d70
@ -209,7 +209,11 @@ int kmain(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp) {
|
||||
map_vfs_directory("/dev");
|
||||
|
||||
if (args_present("root")) {
|
||||
vfs_mount_type("ext2", args_value("root"), "/");
|
||||
char * root_type = "ext2";
|
||||
if (args_present("root_type")) {
|
||||
root_type = args_value("root_type");
|
||||
}
|
||||
vfs_mount_type(root_type, args_value("root"), "/");
|
||||
}
|
||||
|
||||
if (args_present("start")) {
|
||||
@ -223,14 +227,17 @@ int kmain(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp) {
|
||||
}
|
||||
|
||||
if (!fs_root) {
|
||||
debug_print(CRITICAL, "No root filesystem is mounted. Skipping init.");
|
||||
map_vfs_directory("/");
|
||||
switch_task(0);
|
||||
}
|
||||
|
||||
char * boot_app = "/bin/init";
|
||||
if (args_present("init")) {
|
||||
boot_app = args_value("init");
|
||||
}
|
||||
|
||||
/* Prepare to run /bin/init */
|
||||
char * argv[] = {
|
||||
"/bin/init",
|
||||
boot_app,
|
||||
boot_arg,
|
||||
NULL
|
||||
};
|
||||
@ -240,6 +247,9 @@ int kmain(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp) {
|
||||
}
|
||||
system(argv[0], argc, argv); /* Run init */
|
||||
|
||||
debug_print(CRITICAL, "init failed");
|
||||
switch_task(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -44,21 +44,28 @@ void (* symbol_find(const char * name))(void) {
|
||||
int module_quickcheck(void * blob) {
|
||||
|
||||
Elf32_Header * target = (Elf32_Header *)blob;
|
||||
char * head = (char *)blob;
|
||||
|
||||
if (target->e_ident[0] != ELFMAG0 ||
|
||||
target->e_ident[1] != ELFMAG1 ||
|
||||
target->e_ident[2] != ELFMAG2 ||
|
||||
target->e_ident[3] != ELFMAG3) {
|
||||
|
||||
char * head = (char *)blob;
|
||||
if (head[0] == 'P' && head[1] == 'A' && head[2] == 'C' && head[3] == 'K') {
|
||||
return 2;
|
||||
}
|
||||
goto _maybe_pack;
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (target->e_type != ET_REL) {
|
||||
goto _maybe_pack;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
_maybe_pack:
|
||||
if (head[0] == 'P' && head[1] == 'A' && head[2] == 'C' && head[3] == 'K') {
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void * module_load_direct(void * blob, size_t length) {
|
||||
|
Loading…
Reference in New Issue
Block a user