[2442] 2009-07-24 Vladimir Serbinenko <[email protected]>

Vladimir Serbinenko <[email protected]> Fri, 24 Jul 2009 20:41:32 +0000
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2442
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2442
Author:   phcoder
Date:     2009-07-24 20:41:31 +0000 (Fri, 24 Jul 2009)
Log Message:
-----------
2009-07-24  Vladimir Serbinenko  <[email protected]>

	* util/i386/pc/grub-setup.c (setup): Fix bug when
	installing on partionless disk.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/util/i386/pc/grub-setup.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-07-24 01:43:10 UTC (rev 2441)
+++ trunk/grub2/ChangeLog	2009-07-24 20:41:31 UTC (rev 2442)
@@ -1,3 +1,8 @@
+2009-07-24  Vladimir Serbinenko  <[email protected]>
+
+	* util/i386/pc/grub-setup.c (setup): Fix bug when
+	installing on partionless disk.
+
 2009-07-23  Pavel Roskin  <[email protected]>
 
 	* commands/xnu_uuid.c (transform): Use GRUB_CPU_WORDS_BIGENDIAN

Modified: trunk/grub2/util/i386/pc/grub-setup.c
===================================================================
--- trunk/grub2/util/i386/pc/grub-setup.c	2009-07-24 01:43:10 UTC (rev 2441)
+++ trunk/grub2/util/i386/pc/grub-setup.c	2009-07-24 20:41:31 UTC (rev 2442)
@@ -329,10 +329,18 @@
       dest_partmap = p->partmap->name;
       return 1;
     }
+  dest_partmap = 0;
   grub_partition_iterate (dest_dev->disk, identify_partmap);
 
+  if (! dest_partmap)
+    {
+      grub_util_warn ("Attempting to install GRUB to a partitionless disk.  This is a BAD idea.");
+      goto unable_to_embed;
+    }
+
   grub_partition_iterate (dest_dev->disk, (strcmp (dest_partmap, "pc_partition_map") ?
 					   find_usable_region_gpt : find_usable_region_msdos));
+
   if (embed_region.end == embed_region.start)
     {
       if (! strcmp (dest_partmap, "pc_partition_map"))