All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix chainloding + Chainloading into logical partitions
@ 2008-06-30  2:28 Lucas Gadani
  2008-06-30 19:56 ` Fulvio Scapin
  2008-07-06 18:41 ` Robert Millan
  0 siblings, 2 replies; 12+ messages in thread
From: Lucas Gadani @ 2008-06-30  2:28 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 975 bytes --]

Hello,

This is my first patch for GRUB, and I haven't found any coding
styles/formatting, nor developer documentation, so, if there's
something wrong, please, forgive me and point me to the right
direction.

Current implementation of the chainloading code does not work, cause
it reads the partition table from the first sector of the root device,
and the root device does not contain partition information. I've
changed the way partition table are loaded, keeping a copy of the
partition entry in grub_partition_t structs data field, and just
loading this information in the correct address when chainloading.
I've also changed the logical partitions start address to point to the
actual disk sector, instead of pointing to the sector relative to the
beginning of the extended partition, so we can now boot into logical
partitions (for example, syslinux doesn't boot if the partition table
doesn't map to the correct disk sector).

Any comments are appreciated.

-- 
Lucas

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: chainloader.patch --]
[-- Type: text/x-diff; name=chainloader.patch, Size: 1891 bytes --]

diff -ru grub2.org/include/grub/pc_partition.h grub2/include/grub/pc_partition.h
--- grub2.org/include/grub/pc_partition.h	2007-07-21 20:32:22.000000000 -0300
+++ grub2/include/grub/pc_partition.h	2008-06-29 22:13:38.000000000 -0300
@@ -182,6 +182,9 @@
 
   /* The offset of the extended partition.  */
   unsigned long ext_offset;
+
+  /* Partition entry. */
+  struct grub_pc_partition_entry e;
 };
 
 static inline int
diff -ru grub2.org/loader/i386/pc/chainloader.c grub2/loader/i386/pc/chainloader.c
--- grub2.org/loader/i386/pc/chainloader.c	2007-09-03 17:10:19.000000000 -0300
+++ grub2/loader/i386/pc/chainloader.c	2008-06-29 22:50:50.000000000 -0300
@@ -31,6 +31,7 @@
 #include <grub/machine/memory.h>
 #include <grub/rescue.h>
 #include <grub/dl.h>
+#include <grub/pc_partition.h>
 
 static grub_dl_t my_mod;
 static int boot_drive;
@@ -103,10 +104,11 @@
 
 	  if (p)
 	    {
-	      grub_disk_read (disk, p->offset, 446, 64,
-			      (char *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR);
-	      part_addr = (void *) (GRUB_MEMORY_MACHINE_PART_TABLE_ADDR
-				    + (p->index << 4));
+	      struct grub_pc_partition *pcdata = p->data;
+	      grub_memcpy((void *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR,
+			  (void *) &pcdata->e,
+			  sizeof(struct grub_pc_partition_entry));
+	      part_addr = (void *) (GRUB_MEMORY_MACHINE_PART_TABLE_ADDR);
 	    }
 	}
 
diff -ru grub2.org/partmap/pc.c grub2/partmap/pc.c
--- grub2.org/partmap/pc.c	2007-07-21 20:32:30.000000000 -0300
+++ grub2/partmap/pc.c	2008-06-29 22:55:50.000000000 -0300
@@ -135,6 +135,8 @@
 	  pcdata.bsd_part = -1;
 	  pcdata.dos_type = e->type;
 	  pcdata.bsd_type = -1;
+	  grub_memcpy(&pcdata.e, e, sizeof(struct grub_pc_partition_entry));
+	  pcdata.e.start = grub_cpu_to_le32(p.offset + grub_le_to_cpu32 (e->start));
 
 	  grub_dprintf ("partition",
 			"partition %d: flag 0x%x, type 0x%x, start 0x%llx, len 0x%llx\n",

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-07-24 15:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <d013d84b0907221500h690d263g4cd1b9949c53c4b8@mail.gmail.com>
2009-07-22 22:11 ` [PATCH] Fix chainloding + Chainloading into logical partitions Jean-Pierre Flori
2009-07-22 22:18   ` Vladimir 'phcoder' Serbinenko
2009-07-23  0:04     ` Pavel Roskin
2009-07-23  7:59       ` Vladimir 'phcoder' Serbinenko
2009-07-24 15:04       ` Gregg C Levine
2009-07-23 12:05   ` Jean-Pierre Flori
2008-06-30  2:28 Lucas Gadani
2008-06-30 19:56 ` Fulvio Scapin
2008-07-06 18:41 ` Robert Millan
2008-07-06 20:47   ` Lucas Gadani
2008-07-10 14:08     ` Lucas Gadani
2008-07-10 15:28       ` Bean

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.