From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VoKA6-0007vG-8p for mharc-grub-devel@gnu.org; Wed, 04 Dec 2013 16:39:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoKA1-0007s3-PA for grub-devel@gnu.org; Wed, 04 Dec 2013 16:39:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoKA0-0004Pt-LB for grub-devel@gnu.org; Wed, 04 Dec 2013 16:39:09 -0500 Received: from v6.chiark.greenend.org.uk ([2001:ba8:1e3::]:37086 helo=chiark.greenend.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoKA0-0004Pl-Ck for grub-devel@gnu.org; Wed, 04 Dec 2013 16:39:08 -0500 Received: from [172.20.153.9] (helo=riva.pelham.vpn.ucam.org) by chiark.greenend.org.uk (Debian Exim 4.72 #1) with esmtps (return-path cjwatson@ubuntu.com) id 1VoK9z-0006Nf-AW for grub-devel@gnu.org; Wed, 04 Dec 2013 21:39:07 +0000 Received: from ns1.pelham.vpn.ucam.org ([172.20.153.2] helo=riva.ucam.org) by riva.pelham.vpn.ucam.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1VoK9y-0000zZ-8o for grub-devel@gnu.org; Wed, 04 Dec 2013 21:39:06 +0000 Date: Wed, 4 Dec 2013 21:39:05 +0000 From: Colin Watson To: grub-devel@gnu.org Subject: [PATCH] Fix grub-install with OS device name Message-ID: <20131204213904.GK16147@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:ba8:1e3:: X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Dec 2013 21:39:11 -0000 * util/setup.c (SETUP): Accept new dev_is_drive argument. If passed, don't map dev to a GRUB drive again. * include/grub/util/install.h (grub_util_bios_setup): Update prototype. (grub_util_sparc_setup): Likewise. * util/grub-install.c (main): Tell grub_util_bios_setup that install_drive has already been mapped to a GRUB drive. Likewise for grub_util_sparc_setup, and pass install_drive rather than install_device. * util/grub-setup.c (main): Adjust call to GRUB_SETUP_FUNC. --- ChangeLog | 13 +++++++++++++ include/grub/util/install.h | 4 ++-- util/grub-install.c | 8 +++++--- util/grub-setup.c | 2 +- util/setup.c | 39 ++++++++++++++++++++++----------------- 5 files changed, 43 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7e716f..d4a7e02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2013-12-04 Colin Watson + * util/setup.c (SETUP): Accept new dev_is_drive argument. If + passed, don't map dev to a GRUB drive again. + * include/grub/util/install.h (grub_util_bios_setup): Update + prototype. + (grub_util_sparc_setup): Likewise. + * util/grub-install.c (main): Tell grub_util_bios_setup that + install_drive has already been mapped to a GRUB drive. Likewise for + grub_util_sparc_setup, and pass install_drive rather than + install_device. + * util/grub-setup.c (main): Adjust call to GRUB_SETUP_FUNC. + +2013-12-04 Colin Watson + Copying the themes directory in grub-shell isn't parallel-test-friendly and breaks on the second test when the source directory is read-only (as in "make distcheck"). Instead, add a diff --git a/include/grub/util/install.h b/include/grub/util/install.h index 4ba00f5..d1b4567 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -180,12 +180,12 @@ grub_install_get_image_target (const char *arg); void grub_util_bios_setup (const char *dir, const char *boot_file, const char *core_file, - const char *dest, int force, + const char *dev, int dev_is_drive, int force, int fs_probe, int allow_floppy); void grub_util_sparc_setup (const char *dir, const char *boot_file, const char *core_file, - const char *dest, int force, + const char *dev, int dev_is_drive, int force, int fs_probe, int allow_floppy); char * diff --git a/util/grub-install.c b/util/grub-install.c index 2d6ef75..3bb82fc 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1436,11 +1436,12 @@ main (int argc, char *argv[]) platdir, device_map, install_device); + grub_util_info ("('%s' mapped to '%s')", install_device, install_drive); /* Now perform the installation. */ if (install_bootsector) grub_util_bios_setup (platdir, "boot.img", "core.img", - install_drive, force, + install_drive, 1, force, fs_probe, allow_floppy); break; } @@ -1461,12 +1462,13 @@ main (int argc, char *argv[]) !fs_probe ? "--skip-fs-probe" : "", platdir, device_map, - install_drive); + install_device); + grub_util_info ("('%s' mapped to '%s')", install_device, install_drive); /* Now perform the installation. */ if (install_bootsector) grub_util_sparc_setup (platdir, "boot.img", "core.img", - install_device, force, + install_drive, 1, force, fs_probe, allow_floppy); break; } diff --git a/util/grub-setup.c b/util/grub-setup.c index cc3af5d..6e8951e 100644 --- a/util/grub-setup.c +++ b/util/grub-setup.c @@ -254,7 +254,7 @@ main (int argc, char *argv[]) GRUB_SETUP_FUNC (arguments.dir ? : DEFAULT_DIRECTORY, arguments.boot_file ? : DEFAULT_BOOT_FILE, arguments.core_file ? : DEFAULT_CORE_FILE, - arguments.device, arguments.force, + arguments.device, 0, arguments.force, arguments.fs_probe, arguments.allow_floppy); /* Free resources. */ diff --git a/util/setup.c b/util/setup.c index c1de3d2..3f8866e 100644 --- a/util/setup.c +++ b/util/setup.c @@ -247,7 +247,7 @@ identify_partmap (grub_disk_t disk __attribute__ ((unused)), void SETUP (const char *dir, const char *boot_file, const char *core_file, - const char *dev, int force, + const char *dev, int dev_is_drive, int force, int fs_probe, int allow_floppy) { char *core_path; @@ -270,25 +270,30 @@ SETUP (const char *dir, #endif bl.last_length = 0; - { - size_t len = strlen (dev); + if (dev_is_drive) + dest = xstrdup (dev); + else + { + /* Perhaps the user specified a parenthesised GRUB drive name. */ + 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 (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); + { + /* Possibly, the user specified an OS device file. */ + grub_util_pull_device (dev); + 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); + } } -- 1.8.4.4