2009-05-13 Robert Millan <rmh.grub@aybabtu.com>
* util/i386/pc/grub-setup.c (setup): Restructure code flow to make it easier to understand / work with.
This commit is contained in:
parent
0ab3a9a46d
commit
15fbf4c442
2 changed files with 28 additions and 22 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2009-05-13 Robert Millan <rmh.grub@aybabtu.com>
|
||||||
|
|
||||||
|
* util/i386/pc/grub-setup.c (setup): Restructure code flow to make
|
||||||
|
it easier to understand / work with.
|
||||||
|
|
||||||
2009-05-13 Pavel Roskin <proski@gnu.org>
|
2009-05-13 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* loader/i386/pc/multiboot2.c: Add necessary includes for
|
* loader/i386/pc/multiboot2.c: Add necessary includes for
|
||||||
|
|
|
@ -310,17 +310,19 @@ setup (const char *dir,
|
||||||
dos_part, bsd_part);
|
dos_part, bsd_part);
|
||||||
|
|
||||||
if (! dest_dev->disk->has_partitions)
|
if (! dest_dev->disk->has_partitions)
|
||||||
|
{
|
||||||
grub_util_warn ("Attempting to install GRUB to a partitionless disk. This is a BAD idea.");
|
grub_util_warn ("Attempting to install GRUB to a partitionless disk. This is a BAD idea.");
|
||||||
|
goto unable_to_embed;
|
||||||
|
}
|
||||||
|
|
||||||
if (dest_dev->disk->partition)
|
if (dest_dev->disk->partition)
|
||||||
grub_util_warn ("Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea.");
|
|
||||||
|
|
||||||
/* If the destination device can have partitions and it is the MBR,
|
|
||||||
try to embed the core image into after the MBR. */
|
|
||||||
if (dest_dev->disk->has_partitions && ! dest_dev->disk->partition)
|
|
||||||
{
|
{
|
||||||
|
grub_util_warn ("Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea.");
|
||||||
|
goto unable_to_embed;
|
||||||
|
}
|
||||||
|
|
||||||
/* Unlike root_dev, with dest_dev we're interested in the partition map even
|
/* Unlike root_dev, with dest_dev we're interested in the partition map even
|
||||||
if dest_dev itself is a whole disk. */
|
if dest_dev itself is a whole disk. */
|
||||||
auto int NESTED_FUNC_ATTR identify_partmap (grub_disk_t disk,
|
auto int NESTED_FUNC_ATTR identify_partmap (grub_disk_t disk,
|
||||||
const grub_partition_t p);
|
const grub_partition_t p);
|
||||||
int NESTED_FUNC_ATTR identify_partmap (grub_disk_t disk __attribute__ ((unused)),
|
int NESTED_FUNC_ATTR identify_partmap (grub_disk_t disk __attribute__ ((unused)),
|
||||||
|
@ -330,16 +332,22 @@ setup (const char *dir,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
grub_partition_iterate (dest_dev->disk, identify_partmap);
|
grub_partition_iterate (dest_dev->disk, identify_partmap);
|
||||||
|
|
||||||
grub_partition_iterate (dest_dev->disk, (strcmp (dest_partmap, "pc_partition_map") ?
|
grub_partition_iterate (dest_dev->disk, (strcmp (dest_partmap, "pc_partition_map") ?
|
||||||
find_usable_region_gpt : find_usable_region_msdos));
|
find_usable_region_gpt : find_usable_region_msdos));
|
||||||
|
if (embed_region.end == embed_region.start)
|
||||||
if (embed_region.end != embed_region.start)
|
{
|
||||||
embedding_area_exists = 1;
|
grub_util_warn ("Embedding area is not present at all!");
|
||||||
|
goto unable_to_embed;
|
||||||
/* If there is enough space... */
|
}
|
||||||
if ((unsigned long) core_sectors <= embed_region.end - embed_region.start)
|
|
||||||
{
|
if ((unsigned long) core_sectors > embed_region.end - embed_region.start)
|
||||||
|
{
|
||||||
|
grub_util_warn ("Embedding area is too small for core.img.");
|
||||||
|
goto unable_to_embed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
grub_util_info ("will embed the core image at sector 0x%llx", embed_region.start);
|
grub_util_info ("will embed the core image at sector 0x%llx", embed_region.start);
|
||||||
|
|
||||||
*install_dos_part = grub_cpu_to_le32 (dos_part);
|
*install_dos_part = grub_cpu_to_le32 (dos_part);
|
||||||
|
@ -374,15 +382,8 @@ setup (const char *dir,
|
||||||
grub_util_error ("%s", grub_errmsg);
|
grub_util_error ("%s", grub_errmsg);
|
||||||
|
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we reached this point, it means we were unable to embed. */
|
unable_to_embed:
|
||||||
|
|
||||||
if (embedding_area_exists)
|
|
||||||
grub_util_warn ("Embedding area is too small for core.img.");
|
|
||||||
else
|
|
||||||
grub_util_warn ("Embedding area is not present at all!");
|
|
||||||
|
|
||||||
if (must_embed)
|
if (must_embed)
|
||||||
grub_util_error ("Embedding is not possible, but this is required when "
|
grub_util_error ("Embedding is not possible, but this is required when "
|
||||||
|
|
Loading…
Reference in a new issue