Dunno if anyone's ever wanted/done this before, but the attached patch
adds a fallback boot option to FILO, so that if the first kernel fails,
the second one gets booted, if that fails it drops to the usual command
line. I'm using it on Magden's system to try to boot from USB before
going to the hard drive, but I imagine it could be used for CD-ROM, etc,
just as easily. The fallback boot is entirely optional, if not defined
it's just ignored. Also, this won't break Peter's filo speedup patch,
except the changes to the default config file (which I'll fix and send
another patch, if need be). It needs a little more prettying up and some
comments if it were to get committed, but if people don't want it I
won't bother.

-Corey
Index: defconfig
===================================================================
--- defconfig	(.../svn://openbios.org/filo/trunk/filo-0.5/defconfig)	(revision 34)
+++ defconfig	(.../defconfig)	(working copy)
@@ -14,7 +14,8 @@
 MENULST_TIMEOUT = 0
 
 # Image filename for automatic boot and optional command line parameter
-AUTOBOOT_FILE = "hda1:/vmlinuz root=/dev/hda1 console=tty0 console=ttyS0,115200"
+NORMAL_AUTOBOOT_FILE = "uda1:/vmlinuz root=/dev/sda1 console=tty0 console=ttyS0,115200"
+FALLBACK_AUTOBOOT_FILE = "hda1:/vmlinuz root=/dev/hda1 console=tty0 console=ttyS0,115200"
 #AUTOBOOT_FILE = "[EMAIL PROTECTED]"
 #AUTOBOOT_FILE = "[EMAIL PROTECTED]"
 #AUTOBOOT_FILE = "uda1:/vmlinuz.elf"
 
Index: main/filo.c
===================================================================
--- main/filo.c	(.../svn://openbios.org/filo/trunk/filo-0.5/main/filo.c)	(revision 34)
+++ main/filo.c	(.../main/filo.c)	(working copy)
@@ -9,7 +9,7 @@
 #define ENTER '\r'
 #define ESCAPE '\x1b'
 
-#ifndef AUTOBOOT_FILE
+#ifndef NORMAL_AUTOBOOT_FILE
 #define autoboot() ((void) 0) /* nop */
 #endif
 
@@ -66,7 +66,7 @@
 
 #else // ! USE_GRUB
 
-#ifdef AUTOBOOT_FILE
+#ifdef NORMAL_AUTOBOOT_FILE
 #if AUTOBOOT_DELAY
 static inline int autoboot_delay(void)
 {
@@ -76,6 +76,7 @@
     
     key = 0;
 
+
     printf("Press <Enter> for default boot, or <Esc> for boot prompt... ");
     for (sec = AUTOBOOT_DELAY; sec>0 && key==0; sec--) {
 	printf("%d", sec);
@@ -103,19 +104,24 @@
 }
 #endif /* AUTOBOOT_DELAY */
 
-static void autoboot(void)
+static void autoboot_normal(void)
 {
     /* If Escape key is pressed already, skip autoboot */
-    if (havechar() && getchar()==ESCAPE)
-	return;
-
     if (autoboot_delay()==0) {
-	printf("boot: %s\n", AUTOBOOT_FILE);
-	boot(AUTOBOOT_FILE);
+	printf("boot: %s\n", NORMAL_AUTOBOOT_FILE);
+	boot(NORMAL_AUTOBOOT_FILE);
     }
 }
-#endif /* AUTOBOOT_FILE */
 
+static void autoboot_fallback(void)
+{
+    printf("fallback boot: %s\n", NORMAL_AUTOBOOT_FILE);
+    boot(FALLBACK_AUTOBOOT_FILE);
+}
+
+#endif /* NORMAL_AUTOBOOT_FILE */
+
+
 /* The main routine */
 int main(void)
 {
@@ -123,15 +129,23 @@
 
     /* Initialize */
     init();
-    
-    /* Try default image */
-    autoboot();
+    if (!havechar() || getchar()!=ESCAPE)
+    {
+        /* Try default image */
+        autoboot_normal();
 
+        /* Try the fallback */
+#ifdef FALLBACK_AUTOBOOT_FILE
+        autoboot_fallback();
+#endif
+    }
+
     /* The above didn't work, ask user */
     while (havechar())
 	getchar();
-#ifdef AUTOBOOT_FILE
-    strncpy(line, AUTOBOOT_FILE, sizeof(line)-1);
+
+#ifdef NORMAL_AUTOBOOT_FILE
+    strncpy(line, NORMAL_AUTOBOOT_FILE, sizeof(line)-1);
     line[sizeof(line)-1] = '\0';
 #else
     line[0] = '\0';
-- 
linuxbios mailing list
linuxbios@linuxbios.org
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to