merge with mainline

This commit is contained in:
BVK Chaitanya 2010-07-13 00:43:28 +05:30
commit 297f0c2b6e
218 changed files with 35637 additions and 4957 deletions

View file

@ -74,12 +74,15 @@ setup (const char *dir,
grub_uint16_t core_sectors;
grub_device_t root_dev, dest_dev;
const char *dest_partmap;
int multiple_partmaps;
grub_uint8_t *boot_drive;
grub_disk_addr_t *kernel_sector;
grub_uint16_t *boot_drive_check;
struct grub_boot_blocklist *first_block, *block;
grub_int32_t *install_dos_part, *install_bsd_part;
grub_int32_t dos_part, bsd_part;
char *install_prefix;
char *prefix = NULL;
char *tmp_img;
int i;
grub_disk_addr_t first_sector;
@ -104,8 +107,8 @@ setup (const char *dir,
/* There's always an embed region, and it starts right after the MBR. */
embed_region.start = 1;
if (embed_region.end > p->start)
embed_region.end = p->start;
if (embed_region.end > grub_partition_get_start (p))
embed_region.end = grub_partition_get_start (p);
return 0;
}
@ -125,8 +128,8 @@ setup (const char *dir,
/* If there's an embed region, it is in a dedicated partition. */
if (! memcmp (&gptdata.type, &grub_gpt_partition_type_bios_boot, 16))
{
embed_region.start = p->start;
embed_region.end = p->start + p->len;
embed_region.start = grub_partition_get_start (p);
embed_region.end = grub_partition_get_start (p) + grub_partition_get_len (p);
return 1;
}
@ -211,6 +214,8 @@ setup (const char *dir,
+ GRUB_KERNEL_MACHINE_INSTALL_DOS_PART);
install_bsd_part = (grub_int32_t *) (core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_MACHINE_INSTALL_BSD_PART);
install_prefix = (char *) (core_img + GRUB_DISK_SECTOR_SIZE +
GRUB_KERNEL_MACHINE_PREFIX);
/* Open the root device and the destination device. */
root_dev = grub_device_open (root);
@ -286,6 +291,16 @@ setup (const char *dir,
dos_part = root_dev->disk->partition->number;
bsd_part = -1;
}
if (install_prefix[0] != '(')
{
char *root_part_name;
root_part_name =
grub_partition_get_name (root_dev->disk->partition);
prefix = xasprintf ("(,%s)%s", root_part_name, install_prefix);
free (root_part_name);
}
}
else
dos_part = bsd_part = -1;
@ -320,10 +335,17 @@ setup (const char *dir,
{
if (p->parent)
return 0;
dest_partmap = p->partmap->name;
return 1;
if (dest_partmap == NULL)
dest_partmap = p->partmap->name;
else if (strcmp (dest_partmap, p->partmap->name) != 0)
{
multiple_partmaps = 1;
return 1;
}
return 0;
}
dest_partmap = 0;
multiple_partmaps = 0;
grub_partition_iterate (dest_dev->disk, identify_partmap);
if (! dest_partmap)
@ -331,6 +353,11 @@ setup (const char *dir,
grub_util_warn (_("Attempting to install GRUB to a partitionless disk. This is a BAD idea."));
goto unable_to_embed;
}
if (multiple_partmaps)
{
grub_util_warn (_("Attempting to install GRUB to a disk with multiple partition labels. This is not supported yet."));
goto unable_to_embed;
}
if (strcmp (dest_partmap, "msdos") == 0)
grub_partition_iterate (dest_dev->disk, find_usable_region_msdos);
@ -339,7 +366,7 @@ setup (const char *dir,
else
grub_util_error (_("No DOS-style partitions found"));
if (embed_region.end == embed_region.start)
if (embed_region.end <= embed_region.start)
{
if (! strcmp (dest_partmap, "msdos"))
grub_util_warn (_("This msdos-style partition label has no post-MBR gap; embedding won't be possible!"));
@ -362,6 +389,8 @@ setup (const char *dir,
*install_dos_part = grub_cpu_to_le32 (dos_part);
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
if (prefix)
strcpy (install_prefix, prefix);
/* The first blocklist contains the whole sectors. */
first_block->start = grub_cpu_to_le64 (embed_region.start + 1);
@ -522,6 +551,8 @@ unable_to_embed:
*install_dos_part = grub_cpu_to_le32 (dos_part);
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
if (prefix)
strcpy (install_prefix, prefix);
/* Write the first two sectors of the core image onto the disk. */
grub_util_info ("opening the core image `%s'", core_path);
@ -541,6 +572,7 @@ unable_to_embed:
/* Sync is a Good Thing. */
sync ();
free (prefix);
free (core_path);
free (core_img);
free (boot_img);
@ -574,6 +606,8 @@ Usage: %s [OPTION]... DEVICE\n\
\n\
Set up images to boot from DEVICE.\n\
DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\
\n\
You should not normally run %s directly. Use grub-install instead.\n\
\n\
-b, --boot-image=FILE use FILE as the boot image [default=%s]\n\
-c, --core-image=FILE use FILE as the core image [default=%s]\n\
@ -588,7 +622,7 @@ DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\
\n\
Report bugs to <%s>.\n\
"),
program_name,
program_name, program_name,
DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY,
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
@ -680,7 +714,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("grub-setup (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':