All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] util/i386/pc/grub-setup.c : now sets the config partition number
@ 2004-12-23 19:28 Vincent Pelletier
  2005-01-20 14:37 ` Marco Gerards
  0 siblings, 1 reply; 2+ messages in thread
From: Vincent Pelletier @ 2004-12-23 19:28 UTC (permalink / raw)
  To: Grub-devel

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello.
That patch makes grub-setup write the correct partition number to tell
where grub config is, and adds support for more than one partition map type.

Remaining bugs I saw and which I'm not sure how to fix:
- -under linux, uses the /boot default dir instead of /boot/grub (see line
49 and following)
- -parameters -b & -c should be described as relative path to parameter -d
(the seem to be absolute path for now, which is wrong)

2004-12-23  Vincent Pelletier  <subdino2004@yahoo.fr>

	* util/i386/pc/grub-setup.c (setup): Add local function
	`find_partition_map'.  Initialize and deinitialize the pc
	partition map support.  Check for `pc_partition_map' instead
	of `pc'.  Correctly access the partition data.

Vincent Pelletier
PS: thanks for the changelog Marco :)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFByxxTFEQoKRQyjtURAiLvAJ9d2WSLamCZN0WGTbT+w42aSjzlEQCfaAeM
HF5RmBzG13HcXSSaissVku0=
=Z6rb
-----END PGP SIGNATURE-----

[-- Attachment #2: grub-setup.diff --]
[-- Type: text/plain, Size: 3193 bytes --]

Index: grub-setup.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/i386/pc/grub-setup.c,v
retrieving revision 1.9
diff -u -p -r1.9 grub-setup.c
--- grub-setup.c	4 Dec 2004 18:45:46 -0000	1.9
+++ grub-setup.c	23 Dec 2004 14:45:03 -0000
@@ -106,15 +106,17 @@ setup (const char *prefix, const char *d
 
   auto int find_first_partition_start (const grub_partition_t p);
   
-  int find_first_partition_start (const grub_partition_t p)
+  auto int find_partition_map (const grub_partition_map_t partmap);
+  
+  int find_partition_map (const grub_partition_map_t partmap)
     {
-      struct grub_pc_partition *pcdata = p->data;
+      return (partmap->iterate (dest_dev->disk, find_first_partition_start) == GRUB_ERR_NONE );
+    }
 
-      if (! grub_pc_partition_is_empty (pcdata->dos_type)
-	  && ! grub_pc_partition_is_bsd (pcdata->dos_type)
-	  && first_start > p->start)
-	first_start = p->start;
-      
+  int find_first_partition_start (const grub_partition_t p)
+    {
+      if ( p->len && first_start > p->start )
+        first_start = p->start;
       return 0;
     }
   
@@ -159,6 +161,7 @@ setup (const char *prefix, const char *d
       current_segment += GRUB_DISK_SECTOR_SIZE >> 4;
     }
   
+  grub_pc_partition_map_init ();
   /* Read the boot image by the OS service.  */
   boot_path = grub_util_get_path (dir, boot_file);
   boot_size = grub_util_get_image_size (boot_path);
@@ -232,7 +235,7 @@ setup (const char *prefix, const char *d
      try to embed the core image into after the MBR.  */
   if (dest_dev->disk->has_partitions && ! dest_dev->disk->partition)
     {
-      grub_partition_iterate (dest_dev->disk, find_first_partition_start);
+      grub_partition_map_iterate ( find_partition_map );
 
       /* If there is enough space...  */
       if ((unsigned long) core_sectors + 1 <= first_start)
@@ -255,16 +258,19 @@ setup (const char *prefix, const char *d
 	  /* Embed information about the installed location.  */
 	  if (root_dev->disk->partition)
 	    {
-	      struct grub_pc_partition *pcdata =
-		root_dev->disk->partition->data;
 	      
-	      if (strcmp (root_dev->disk->partition->partmap->name, "pc"))
-		grub_util_error ("No PC style partitions found");
+	      if (!strcmp (root_dev->disk->partition->partmap->name, "pc_partition_map"))
+                {
 	      
-	      *install_dos_part
-		= grub_cpu_to_le32 (pcdata->dos_part);
-	      *install_bsd_part
-		= grub_cpu_to_le32 (pcdata->bsd_part);
+	          struct grub_pc_partition *pcdata =
+		    root_dev->disk->partition->data;
+	          *install_dos_part
+		    = grub_cpu_to_le32 (pcdata->dos_part);
+	          *install_bsd_part
+		    = grub_cpu_to_le32 (pcdata->bsd_part);
+                }
+              else
+	      grub_util_error ("Partition map unknown"); /* known by grub but not by grub-config */
 	    }
 	  else
 	    *install_dos_part = *install_bsd_part = grub_cpu_to_le32 (-1);
@@ -449,6 +455,7 @@ setup (const char *prefix, const char *d
   free (boot_img);
   grub_device_close (dest_dev);
   grub_device_close (root_dev);
+  grub_pc_partition_map_fini ();
 }
 
 static struct option options[] =




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

* Re: [PATCH] util/i386/pc/grub-setup.c : now sets the config partition number
  2004-12-23 19:28 [PATCH] util/i386/pc/grub-setup.c : now sets the config partition number Vincent Pelletier
@ 2005-01-20 14:37 ` Marco Gerards
  0 siblings, 0 replies; 2+ messages in thread
From: Marco Gerards @ 2005-01-20 14:37 UTC (permalink / raw)
  To: The development of GRUB 2

Vincent Pelletier <subdino2004@yahoo.fr> writes:

> 2004-12-23  Vincent Pelletier  <subdino2004@yahoo.fr>
>
> 	* util/i386/pc/grub-setup.c (setup): Add local function
> 	`find_partition_map'.  Initialize and deinitialize the pc
> 	partition map support.  Check for `pc_partition_map' instead
> 	of `pc'.  Correctly access the partition data.

This patch fixes a stupid bug I introduced.  Unless someone has a
problem with this patch, it will be committed on Wednesday.

Thanks,
Marco




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

end of thread, other threads:[~2005-01-20 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-23 19:28 [PATCH] util/i386/pc/grub-setup.c : now sets the config partition number Vincent Pelletier
2005-01-20 14:37 ` Marco Gerards

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.