mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-31 06:28:22 +00:00
kernel: mount root using commandline arguments
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include <kernel/nvme.h>
|
#include <kernel/nvme.h>
|
||||||
#include <kernel/block.h>
|
#include <kernel/block.h>
|
||||||
#include <kernel/ext2.h>
|
#include <kernel/ext2.h>
|
||||||
|
#include <kernel/cmdline.h>
|
||||||
|
|
||||||
static cpu_t bsp_cpu;
|
static cpu_t bsp_cpu;
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ void kernel_entry() {
|
|||||||
arch_mmu_init();
|
arch_mmu_init();
|
||||||
vmm_init();
|
vmm_init();
|
||||||
alloc_init();
|
alloc_init();
|
||||||
|
cmdline_parse();
|
||||||
arch_acpi_init();
|
arch_acpi_init();
|
||||||
arch_apic_init();
|
arch_apic_init();
|
||||||
cpu_initstate();
|
cpu_initstate();
|
||||||
@@ -58,16 +60,6 @@ void kernel_entry() {
|
|||||||
devfs_init();
|
devfs_init();
|
||||||
pipefs_init();
|
pipefs_init();
|
||||||
ext2_init();
|
ext2_init();
|
||||||
printf("mounting tmpfs on /\n");
|
|
||||||
__assert(vfs_mount(NULL, vfsroot, "/", "tmpfs", NULL) == 0);
|
|
||||||
initrd_unpack();
|
|
||||||
|
|
||||||
vattr_t attr = {0};
|
|
||||||
attr.mode = 0644;
|
|
||||||
__assert(vfs_create(vfsroot, "/dev", &attr, V_TYPE_DIR, NULL) == 0);
|
|
||||||
|
|
||||||
printf("mounting devfs on /dev\n");
|
|
||||||
__assert(vfs_mount(NULL, vfsroot, "/dev", "devfs", NULL) == 0);
|
|
||||||
|
|
||||||
block_init();
|
block_init();
|
||||||
pseudodevices_init();
|
pseudodevices_init();
|
||||||
@@ -76,10 +68,30 @@ void kernel_entry() {
|
|||||||
arch_ps2_init();
|
arch_ps2_init();
|
||||||
fb_init();
|
fb_init();
|
||||||
nvme_init();
|
nvme_init();
|
||||||
|
|
||||||
console_init();
|
console_init();
|
||||||
logging_sethook(console_putc);
|
logging_sethook(console_putc);
|
||||||
|
|
||||||
|
char *root = cmdline_get("root");
|
||||||
|
char *rootfs = cmdline_get("rootfs");
|
||||||
|
|
||||||
|
printf("mounting %s (%s) on /\n", root == NULL ? "none" : root, rootfs);
|
||||||
|
|
||||||
|
vnode_t *backing;
|
||||||
|
if (root) {
|
||||||
|
__assert(devfs_getbyname(root, &backing) == 0);
|
||||||
|
} else {
|
||||||
|
backing = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
__assert(vfs_mount(backing, vfsroot, "/", rootfs, NULL) == 0);
|
||||||
|
|
||||||
|
if (backing) {
|
||||||
|
VOP_RELEASE(backing);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdline_get("initrd"))
|
||||||
|
initrd_unpack();
|
||||||
|
|
||||||
sched_runinit();
|
sched_runinit();
|
||||||
sched_threadexit();
|
sched_threadexit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1679,8 +1679,6 @@ static int ext2_mount(vfs_t **vfs, vnode_t *mountpoint, vnode_t *backing, void *
|
|||||||
*vfs = &fs->vfs;
|
*vfs = &fs->vfs;
|
||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
ASSERT_UNCLEAN(fs, fs->blocksize == 123546667);
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (err)
|
if (err)
|
||||||
free(fs);
|
free(fs);
|
||||||
|
|||||||
Reference in New Issue
Block a user