New partition naming style in grub-probe for Linux and NetBSD.

This commit is contained in:
Grégoire Sutre 2010-06-13 02:36:39 +02:00
parent 96e5c55634
commit fcb2d09011
3 changed files with 21 additions and 19 deletions

View file

@ -1,3 +1,9 @@
2010-06-13 Grégoire Sutre <gregoire.sutre@gmail.com>
* kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev): Use the
new partition naming style.
* util/grub-install.in: Adapt sed subtitutions in grub-probe calls.
2010-06-12 BVK Chaitanya <bvk.groups@gmail.com> 2010-06-12 BVK Chaitanya <bvk.groups@gmail.com>
Add "-o grub.iso" like cmdline options support. Add "-o grub.iso" like cmdline options support.

View file

@ -992,6 +992,11 @@ grub_util_biosdisk_fini (void)
grub_disk_dev_unregister (&grub_util_biosdisk_dev); grub_disk_dev_unregister (&grub_util_biosdisk_dev);
} }
/*
* Note: we do not use the new partition naming scheme as dos_part does not
* necessarily correspond to an msdos partition. See e.g. the FreeBSD code
* in function grub_util_biosdisk_get_grub_dev.
*/
static char * static char *
make_device_name (int drive, int dos_part, int bsd_part) make_device_name (int drive, int dos_part, int bsd_part)
{ {
@ -1400,11 +1405,9 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
For NetBSD, proceed as for Linux, except that the start sector is For NetBSD, proceed as for Linux, except that the start sector is
obtained from the disk label. */ obtained from the disk label. */
{ {
char *name; char *name, *partname;
grub_disk_t disk; grub_disk_t disk;
grub_disk_addr_t start; grub_disk_addr_t start;
int dos_part = -1;
int bsd_part = -1;
auto int find_partition (grub_disk_t dsk, auto int find_partition (grub_disk_t dsk,
const grub_partition_t partition); const grub_partition_t partition);
@ -1419,17 +1422,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
if (start == part_start) if (start == part_start)
{ {
if (partition->parent) partname = grub_partition_get_name (partition);
{
dos_part = partition->parent->number;
bsd_part = partition->number;
}
else
{
dos_part = partition->number;
bsd_part = -1;
}
return 1; return 1;
} }
@ -1465,6 +1458,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
if (! disk) if (! disk)
return 0; return 0;
partname = NULL;
grub_partition_iterate (disk, find_partition); grub_partition_iterate (disk, find_partition);
if (grub_errno != GRUB_ERR_NONE) if (grub_errno != GRUB_ERR_NONE)
{ {
@ -1472,7 +1466,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
return 0; return 0;
} }
if (dos_part < 0) if (partname == NULL)
{ {
grub_disk_close (disk); grub_disk_close (disk);
grub_error (GRUB_ERR_BAD_DEVICE, grub_error (GRUB_ERR_BAD_DEVICE,
@ -1480,7 +1474,9 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
return 0; return 0;
} }
return make_device_name (drive, dos_part, bsd_part); name = grub_xasprintf ("%s,%s", disk->name, partname);
free (partname);
return name;
} }
#elif defined(__GNU__) #elif defined(__GNU__)
@ -1525,7 +1521,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
for (p = os_dev + 5; *p; ++p) for (p = os_dev + 5; *p; ++p)
if (grub_isdigit(*p)) if (grub_isdigit(*p))
{ {
p = strchr (p, 's'); p = strchr (p, 's'); /* msdos or apple (or ... ?) partition map */
if (p) if (p)
{ {
p++; p++;

View file

@ -356,12 +356,12 @@ if [ "x${devabstraction_module}" = "x" ] ; then
else else
install_drive="`$grub_probe --target=drive --device ${install_device}`" || exit 1 install_drive="`$grub_probe --target=drive --device ${install_device}`" || exit 1
fi fi
install_drive="`echo ${install_drive} | sed -e s/,[0-9]*[a-z]*//g`" install_drive="`echo ${install_drive} | sed -e s/,[a-z0-9,]*//g`"
fi fi
grub_drive="`$grub_probe --target=drive --device ${grub_device}`" || exit 1 grub_drive="`$grub_probe --target=drive --device ${grub_device}`" || exit 1
# Strip partition number # Strip partition number
grub_drive="`echo ${grub_drive} | sed -e s/,[0-9]*[a-z]*//g`" grub_drive="`echo ${grub_drive} | sed -e s/,[a-z0-9,]*//g`"
if [ "$disk_module" = ata ] ; then if [ "$disk_module" = ata ] ; then
# generic method (used on coreboot and ata mod) # generic method (used on coreboot and ata mod)
uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`" uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"