Read bootorder file into memory.
authorGleb Natapov <gleb@redhat.com>
Thu, 23 Dec 2010 09:29:38 +0000 (11:29 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Fri, 24 Dec 2010 15:49:27 +0000 (10:49 -0500)
Read bootorder file, parse it and put it into array for easy
consumption.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
src/boot.c
src/boot.h

index 9c94439605a54579ecaec8e5de8d5b2c1b2136fd..9c370237301dd422508dbe864bfe57f57ba9197c 100644 (file)
@@ -67,6 +67,51 @@ boot_setup(void)
         if (!(inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1))
             IPL.checkfloppysig = 1;
     }
+
+    u32 file = romfile_find("bootorder");
+    if (!file)
+        return;
+
+    int filesize = romfile_size(file);
+    dprintf(3, "bootorder file found (len %d)\n", filesize);
+
+    if (filesize == 0)
+        return;
+
+    char *f = malloc_tmphigh(filesize);
+
+    if (!f) {
+        warn_noalloc();
+        return;
+    }
+
+    romfile_copy(file, f, filesize);
+    int i;
+    IPL.fw_bootorder_count = 1;
+    while(f[i]) {
+        if (f[i] == '\n')
+            IPL.fw_bootorder_count++;
+        i++;
+    }
+    IPL.fw_bootorder = malloc_tmphigh(IPL.fw_bootorder_count*sizeof(char*));
+    if (!IPL.fw_bootorder) {
+        warn_noalloc();
+        free(f);
+        return;
+    }
+
+    dprintf(3, "boot order:\n");
+    i = 0;
+    do {
+        IPL.fw_bootorder[i] = f;
+        f = strchr(f, '\n');
+        if (f) {
+            *f = '\0';
+            f++;
+            dprintf(3, "%d: %s\n", i, IPL.fw_bootorder[i]);
+            i++;
+        }
+    } while(f);
 }
 
 // Add a BEV vector for a given pnp compatible option rom.
index f751d719dd277dac1601adca18407bb361f46cd9..778aebd88d8fdc83d9a0b4ba36e2b6f3f29a5730 100644 (file)
@@ -20,6 +20,8 @@ struct ipl_s {
     int bevcount, bcvcount;
     u32 bootorder;
     int checkfloppysig;
+    char **fw_bootorder;
+    int fw_bootorder_count;
 };
 
 #define IPL_TYPE_FLOPPY      0x01