Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VoRvO-0005uU-Gm for mharc-grub-devel@gnu.org; Thu, 05 Dec 2013 00:56:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoRvG-0005rT-8J for grub-devel@gnu.org; Thu, 05 Dec 2013 00:56:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoRvB-00013W-IT for grub-devel@gnu.org; Thu, 05 Dec 2013 00:56:26 -0500 Received: from mail-bk0-x235.google.com ([2a00:1450:4008:c01::235]:41457) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoRvB-00013L-6H for grub-devel@gnu.org; Thu, 05 Dec 2013 00:56:21 -0500 Received: by mail-bk0-f53.google.com with SMTP id na10so6904486bkb.40 for ; Wed, 04 Dec 2013 21:56:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:content-type:in-reply-to:message-id:date:to :content-transfer-encoding:mime-version; bh=glPWAFvmJBaZMouvMJfJ2ShaBpULzWJFd7kUFgKrd+8=; b=xT6VSK6XqMS3xy5DCCSPXJjrrZ4lcp+Jt/2OFbHYz8Axjbg0Nh7EskL7SoHHDA4dZa UMMfDlLx0NtRKsBA/Wq3hWjarwVhhBtFz5kMQyrmQpQ5cBax4sRBEi7GSwgO08WLcZJL FCf/4AB9zbW1XOjtvra7+Qv9K4WA3CR+rUtjLrMeyRtNTJX6WvuhXU5kCAMbeCjveetr DCL6RmSa9I0R6ntaS0dPX4SRVgJ1l1RT7szOZ1wFxipMOhscLDnz7CdMz6YmCWeWQp1w JFfONi10MfJFDB7mtEqegzRZLvOkT+3idfak6tIrZDSW26KjEjij+KutcQJIrXvMBa+P PPTA== X-Received: by 10.204.114.12 with SMTP id c12mr110022bkq.61.1386222979573; Wed, 04 Dec 2013 21:56:19 -0800 (PST) Received: from [10.142.150.118] ([46.189.28.207]) by mx.google.com with ESMTPSA id sx5sm11717887bkb.0.2013.12.04.21.56.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Dec 2013 21:56:18 -0800 (PST) Subject: Re: [PATCH] Fix grub-install with OS device name References: <20131204213904.GK16147@riva.ucam.org> <20131204221530.GA4445@riva.ucam.org> From: arvidjaar@gmail.com Content-Type: text/plain; charset=koi8-r X-Mailer: iPhone Mail (11B511) In-Reply-To: <20131204221530.GA4445@riva.ucam.org> Message-Id: Date: Thu, 5 Dec 2013 06:56:18 +0100 To: The development of GNU GRUB Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4008:c01::235 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: Thu, 05 Dec 2013 05:56:31 -0000 =EF=D4=D0=D2=C1=D7=CC=C5=CE=CF =D3 iPhone > 04 =C4=C5=CB. 2013 =C7., =D7 23:15, Colin Watson =CE= =C1=D0=C9=D3=C1=CC(=C1): >=20 >> On Wed, Dec 04, 2013 at 01:54:42PM -0800, Jonathan McCune wrote: >> Tested successfully on i386-pc in a QEMU VM. >=20 > Thanks. I made a slight mistake, though, and broke the case of > "grub-install '(hd0)'", which is what Andrey had been trying to fix in > the first place. Here's a better version which I've tested to handle > both OS and GRUB device forms successfully. >=20 Ouch. It becomes messier and messier ... :) Why not simply drop resolution o= f device in grub-install? Let's do it in one place.=20 > diff --git a/ChangeLog b/ChangeLog > index 8fba56c..c8072b5 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,16 @@ > +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 Vladimir Serbinenko >=20 > * grub-core/boot/sparc64/ieee1275/boot.S [CDBOOT]: Move scratchpad > 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); >=20 > 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_driv= e); > =20 > /* 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_driv= e); > =20 > /* 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); >=20 > /* Free resources. */ > diff --git a/util/setup.c b/util/setup.c > index c1de3d2..7bf125d 100644 > --- a/util/setup.c > +++ b/util/setup.c > @@ -247,7 +247,7 @@ identify_partmap (grub_disk_t disk __attribute__ ((unu= sed)), > 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; > @@ -271,6 +271,7 @@ SETUP (const char *dir, > bl.last_length =3D 0; >=20 > { > + /* Perhaps the user specified a parenthesised GRUB drive name. */ > size_t len =3D strlen (dev); >=20 > if (len > 2 && dev[0] =3D=3D '(' && dev[len - 1] =3D=3D ')') > @@ -283,12 +284,18 @@ SETUP (const char *dir, >=20 > if (! dest) > { > - /* Possibly, the user specified an OS device file. */ > - dest =3D 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); > + if (dev_is_drive) > + dest =3D xstrdup (dev); > + else > + { > + /* Possibly, the user specified an OS device file. */ > + grub_util_pull_device (dev); > + dest =3D 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); > + } > } >=20 >=20 > --=20 > 1.8.4.4 >=20 >=20 > --=20 > Colin Watson [cjwatson@ubuntu.com] >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel