fix using grub device name as install device
Shell version of grub-install called grub-setup which resolved install device name and called main setup routine. C version of grub-install calls main setup routine directly, which leads to the error: grub2-install: info: grub-bios-setup --verbose --force --skip-fs-probe --directory='/boot/grub2/i386-pc' --device-map='/boot/grub2/device.map' '(hd2)'. grub2-install: info: reading /boot/grub2/i386-pc/boot.img. grub2-install: info: reading /boot/grub2/i386-pc/core.img. grub2-install: info: root is `(null)', dest is `(hd2)'. grub2-install: info: Opening dest. grub2-install: info: drive = -1. grub2-install: error: disk `(hd2)' not found. Move resolving of destination device name into main setup routine so it is done consistently in both cases.
This commit is contained in:
parent
eec893ae49
commit
69ca97c820
3 changed files with 34 additions and 41 deletions
26
util/setup.c
26
util/setup.c
|
@ -247,12 +247,13 @@ identify_partmap (grub_disk_t disk __attribute__ ((unused)),
|
|||
void
|
||||
SETUP (const char *dir,
|
||||
const char *boot_file, const char *core_file,
|
||||
const char *dest, int force,
|
||||
const char *dev, int force,
|
||||
int fs_probe, int allow_floppy)
|
||||
{
|
||||
char *core_path;
|
||||
char *boot_img, *core_img, *boot_path;
|
||||
char *root = 0;
|
||||
char *dest = 0;
|
||||
size_t boot_size, core_size;
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
grub_uint16_t core_sectors;
|
||||
|
@ -269,6 +270,28 @@ SETUP (const char *dir,
|
|||
#endif
|
||||
bl.last_length = 0;
|
||||
|
||||
{
|
||||
size_t len = strlen (dev);
|
||||
|
||||
if (len > 2 && dev[0] == '(' && dev[len - 1] == ')')
|
||||
{
|
||||
dest = xmalloc (len - 1);
|
||||
strncpy (dest, dev + 1, len - 2);
|
||||
dest[len - 2] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (! dest)
|
||||
{
|
||||
/* Possibly, the user specified an OS device file. */
|
||||
dest = grub_util_get_grub_dev (dev);
|
||||
if (! dest)
|
||||
grub_util_error (_("Invalid device `%s'.\n"), dev);
|
||||
grub_util_info ("transformed OS device `%s' into GRUB device `%s'",
|
||||
dev, dest);
|
||||
}
|
||||
|
||||
|
||||
/* 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);
|
||||
|
@ -303,6 +326,7 @@ SETUP (const char *dir,
|
|||
dest_dev = grub_device_open (dest);
|
||||
if (! dest_dev)
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
free (dest);
|
||||
|
||||
core_dev = dest_dev;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue