bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Multiple initrd files.


From: Dave Cinege
Subject: [PATCH] Multiple initrd files.
Date: Sun, 28 Jan 2001 01:19:14 -0500

The patch represents the 'final solution' to a 5 year old problem I've been
dealing with, with embedded Linux systems; that being keeping the binaries and
configuration in seperate archives. A fellow developer will be forth coming
with a similar patch for syslinux.

The patch works by loading several initrd files in series by specing:
        initrd /file1,/file2

It is meant to be used with my initrd-dynamic kernel patch, that dynamically
creates a filesystem on a ramdisk and then populates it 
with the (now multiple) tar.gz in the initrd memory area.

It will also work with standard initrd image files that have been split
into several parts. Unfortunatly since all files must be speced on the
same initrd entry it's not possible to use this patch to load
multiple initrd files from a removable disk. (IE no way to pause
inbetween floppy changes), though multiple devices
        initrd (fd0)/file1,(fd1)/file2,(hd0,1)/file3
will work fine.

Okuji,
What do you think about this? To implement this the 'right way' (allowing
continuous loading accross multiple entries) would require recoding
load_initrd() entirly. However being able to span an initrd
image across several disks and loading them at boot it very advantagous
for Linux OS install.

If you are willing to give your nod that it wil be merged into the official
version, I will go ahead and do it.

Dave

-- 
"Nobody will ever be safe until the last cop is dead."
                NH Rep. Tom Alciere - (My new Hero)
--- boot.c.orig Sat Jan 27 00:17:21 2001
+++ boot.c      Sat Jan 27 03:25:58 2001
@@ -613,19 +613,53 @@
 int
 load_initrd (char *initrd)
 {
-  int len;
+  int len = 0, lent = 0;
   unsigned long moveto;
   struct linux_kernel_header *lh;
-  
-  if (! grub_open (initrd))
-    return 0;
+  char *p1 = initrd;
+  char *p2 = initrd;
+  char *buf = (char *)cur_addr;
+  int pck;
+
+  //Support loading multiple files seperated by commas
+  while (*p2 != 0) {   
 
-  len = grub_read ((char *) cur_addr, -1);
-  if (! len)
-    {
-      grub_close ();
+    pck = 0;
+    while (*p1 != 0) { // Parse until end of string
+      if (*p1 == ',') {        // Found a ','
+       *p1++ = 0;      // = 0, then hop past
+        pck = 1;       // Say we did it
+       break;          // Exit loop
+      }
+      p1++;            // Next char
+    }
+    
+    printf ("      %s", p2);
+    
+    if (grub_open(p2) == 0) {
+      printf ("...FAILED to open!\n");
       return 0;
     }
+    
+    lent = 0;
+    lent = grub_read (buf, -1);
+    if (lent == 0) {
+      printf ("...FAILED to read!\n");
+      return 0;
+    }
+    
+    printf (", %d bytes\n", lent);
+    
+    buf += lent;       // Jump *buf to end of last read.
+    len += lent;       // Sum up total bytes read
+    p2 = p1;           // Hop p2 to p1 (past comma or at 0)
+
+    if (pck == 1) {   // We 0'ed a ','
+      *--p1 = ',';     // Hop back replace it
+      p1++;            // Hop forward where we belong
+    }
+    
+  }
 
   moveto = ((mbi.mem_upper + 0x400) * 0x400 - len) & 0xfffff000;
   if (moveto + len >= LINUX_INITRD_MAX_ADDRESS)
@@ -636,7 +670,7 @@
   moveto -= 0x1000;
   memmove ((void *) RAW_ADDR (moveto), (void *) cur_addr, len);
 
-  printf ("   [Linux-initrd @ 0x%x, 0x%x bytes]\n", moveto, len);
+  printf ("   [Linux-initrd @ 0x%x, 0x%x (%d) bytes]\n", moveto, len, len );
 
   /* FIXME: Should check if the kernel supports INITRD.  */
   lh = (struct linux_kernel_header *) LINUX_SETUP;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]