+2013-11-29 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * util/grub-setup.c (main): Move parsing of (hdX) syntax to ...
+ * util/setup.c (SETUP): ... here. Fixes regression: grub-install
+ failed to install on (hdX).
+ * util/grub-setup.c (get_device_name): Remove, not needed after
+ above change.
+
2013-11-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/hostfs.c (is_dir): Remove variable length arrays.
NULL, help_filter, NULL
};
-static char *
-get_device_name (char *dev)
-{
- size_t len = strlen (dev);
-
- if (dev[0] != '(' || dev[len - 1] != ')')
- return 0;
-
- dev[len - 1] = '\0';
- return dev + 1;
-}
-
int
main (int argc, char *argv[])
{
- char *root_dev = NULL;
- char *dest_dev = NULL;
struct arguments arguments;
grub_util_host_init (&argc, &argv);
grub_mdraid1x_init ();
grub_lvm_init ();
- dest_dev = get_device_name (arguments.device);
- if (! dest_dev)
- {
- /* Possibly, the user specified an OS device file. */
- dest_dev = grub_util_get_grub_dev (arguments.device);
- if (! dest_dev)
- {
- char *program = xstrdup(program_name);
- fprintf (stderr, _("Invalid device `%s'.\n"), arguments.device);
- argp_help (&argp, stderr, ARGP_HELP_STD_USAGE, program);
- free(program);
- exit(1);
- }
- grub_util_info ("transformed OS device `%s' into GRUB device `%s'",
- arguments.device, dest_dev);
- }
- else
- {
- /* For simplicity. */
- dest_dev = xstrdup (dest_dev);
- grub_util_info ("Using `%s' as GRUB device", dest_dev);
- }
-
/* Do the real work. */
GRUB_SETUP_FUNC (arguments.dir ? : DEFAULT_DIRECTORY,
arguments.boot_file ? : DEFAULT_BOOT_FILE,
arguments.core_file ? : DEFAULT_CORE_FILE,
- dest_dev, arguments.force,
+ arguments.device, arguments.force,
arguments.fs_probe, arguments.allow_floppy);
/* Free resources. */
free (arguments.dir);
free (arguments.dev_map);
free (arguments.device);
- free (root_dev);
- free (dest_dev);
return 0;
}
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;
#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);
dest_dev = grub_device_open (dest);
if (! dest_dev)
grub_util_error ("%s", grub_errmsg);
+ free (dest);
core_dev = dest_dev;