From 46715faa86bdbb8b94888c347d83c5f764eada9f Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Tue, 13 Feb 2018 22:22:52 +0000 Subject: [PATCH] start: Avoid infinite loop when BOOTDEVICE is defined When BOOTDEVICE is defined get_root_dev() was always returning the same device entering in an infinite loop with the only effect of scroll out all the previous messages. --- Kernel/start.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Kernel/start.c b/Kernel/start.c index 479e600f..c1ee2597 100644 --- a/Kernel/start.c +++ b/Kernel/start.c @@ -301,7 +301,13 @@ uint16_t get_root_dev(void) inline uint16_t get_root_dev(void) { - return BOOTDEVICE; + static uint8_t first = 1; + + if (first) { + first = 0; + return BOOTDEVICE; + } + return BAD_ROOT_DEV; } #endif @@ -370,6 +376,8 @@ void fuzix_main(void) old_argptr = argptr; /* Get a root device to try */ root_dev = get_root_dev(); + if (root_dev == BAD_ROOT_DEV) + panic(PANIC_NOROOT); /* Mount the root device */ kprintf("Mounting root fs (root_dev=%d, r%c): ", root_dev, ro ? 'o' : 'w'); if(fmount(root_dev, NULLINODE, ro) == 0) -- 2.34.1