From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YMMj3-0002He-Ov for mharc-grub-devel@gnu.org; Fri, 13 Feb 2015 15:20:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMMj0-0002HI-5S for grub-devel@gnu.org; Fri, 13 Feb 2015 15:20:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMMiw-0002fH-Iy for grub-devel@gnu.org; Fri, 13 Feb 2015 15:20:30 -0500 Received: from poivron.org ([91.194.60.101]:34572 helo=mail.poivron.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMMiw-0002ex-AI for grub-devel@gnu.org; Fri, 13 Feb 2015 15:20:26 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) with ESMTPSA id 5D0C1C10584 Date: Fri, 13 Feb 2015 21:20:23 +0100 From: Lunar To: grub-devel@gnu.org Subject: Re: [bug #44238] Add support for menu.c32 and vesamenu.c32 in lib/syslinux_parse Message-ID: <20150213202023.GF688@loar> References: <20150213-163409.sv98365.64186@savannah.gnu.org> <20150213-190108.sv89796.21318@savannah.gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0OWHXb1mYLuhj1Ox" Content-Disposition: inline In-Reply-To: <20150213-190108.sv89796.21318@savannah.gnu.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 91.194.60.101 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: Fri, 13 Feb 2015 20:20:31 -0000 --0OWHXb1mYLuhj1Ox Content-Type: multipart/mixed; boundary="yQbNiKLmgenwUfTN" Content-Disposition: inline --yQbNiKLmgenwUfTN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Andrei Borzenkov: > Follow-up Comment #1, bug #44238 (project grub): >=20 > + while (*ptr) > + { > + end =3D ptr; > + for (end =3D ptr; *end && !grub_isspace (*end); end++); > + if (*end) > + *end++ =3D '\0'; > + > + /* "~" is supposed to be current file, so let's skip it */ > + if (grub_strcmp (ptr, "~") =3D=3D 0) > + continue; >=20 > If you hit "~" you get endless loop. Thanks for spotting the mistake. > Could you post fixed version to grub-devel for easier review? Attached. --=20 Lunar --yQbNiKLmgenwUfTN Content-Type: text/x-diff; charset=us-ascii Content-Disposition: inline; filename="0001-lib-syslinux_parse-add-support-for-vesa-menu.c32.patch" Content-Transfer-Encoding: quoted-printable =46rom 9b441e5e6c602c71e522c594ca6cff72a12c078c Mon Sep 17 00:00:00 2001 =46rom: Lunar Date: Sat, 14 Feb 2015 14:14:25 +0100 Subject: [PATCH 1/2] lib/syslinux_parse: add support for (vesa)menu.c32 Fixes Savannah bug #44238. --- grub-core/lib/syslinux_parse.c | 157 ++++++++++++++++++++++++++-----------= ---- 1 file changed, 99 insertions(+), 58 deletions(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 2c874b1..b0d5f9e 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -840,6 +840,74 @@ simplify_filename (char *str) } =20 static grub_err_t +print_config (struct output_buffer *outbuf, + struct syslinux_menu *menu, + const char *filename, const char *basedir) +{ + grub_err_t err; + char *new_cwd, *new_target_cwd; + + new_cwd =3D get_read_filename (menu, basedir); + if (!new_cwd) + return grub_errno; + new_target_cwd =3D get_target_filename (menu, basedir); + if (!new_target_cwd) + return grub_errno; + + struct syslinux_menu *menuptr; + char *newname; + int depth =3D 0; + + newname =3D get_read_filename (menu, filename); + if (!newname) + return grub_errno; + simplify_filename (newname); + + print_string ("#"); + print_file (outbuf, menu, filename, NULL); + print_string (" "); + print (outbuf, newname, grub_strlen (newname)); + print_string (":\n"); + + for (menuptr =3D menu; menuptr; menuptr =3D menuptr->parent, depth++) + if (grub_strcmp (menuptr->filename, newname) =3D=3D 0 + || depth > 20) + break; + if (menuptr) + { + print_string (" syslinux_configfile -r "); + print_file (outbuf, menu, "/", NULL); + print_string (" -c "); + print_file (outbuf, menu, basedir, NULL); + print_string (" "); + print_file (outbuf, menu, filename, NULL); + print_string ("\n"); + } + else + { + err =3D config_file (outbuf, menu->root_read_directory, + menu->root_target_directory, new_cwd, new_target_= cwd, + newname, menu, menu->flavour); + if (err =3D=3D GRUB_ERR_FILE_NOT_FOUND + || err =3D=3D GRUB_ERR_BAD_FILENAME) + { + grub_errno =3D err =3D GRUB_ERR_NONE; + print_string ("# File "); + err =3D print (outbuf, newname, grub_strlen (newname)); + if (err) + return err; + print_string (" not found\n"); + } + if (err) + return err; + } + grub_free (newname); + grub_free (new_cwd); + grub_free (new_target_cwd); + return GRUB_ERR_NONE; +} + +static grub_err_t write_entry (struct output_buffer *outbuf, struct syslinux_menu *menu, struct syslinux_menuentry *curentry) @@ -1240,6 +1308,36 @@ write_entry (struct output_buffer *outbuf, break; } =20 + if (grub_strcasecmp (basename, "menu.c32") =3D=3D 0 || + grub_strcasecmp (basename, "vesamenu.c32") =3D=3D 0) + { + char *ptr; + char *end; + + ptr =3D curentry->append; + if (!ptr) + return grub_errno; + + while (*ptr) + { + end =3D ptr; + for (end =3D ptr; *end && !grub_isspace (*end); end++); + if (*end) + *end++ =3D '\0'; + + /* "~" is supposed to be current file, so let's skip it */ + if (grub_strcmp (ptr, "~") !=3D 0) + { + err =3D print_config (outbuf, menu, ptr, ""); + if (err !=3D GRUB_ERR_NONE) + break; + } + for (ptr =3D end; *ptr && grub_isspace (*ptr); ptr++); + } + err =3D GRUB_ERR_NONE; + break; + } + /* FIXME: gdb, GFXBoot, Hdt, Ifcpu, Ifplop, Kbdmap, FIXME: Linux, Lua, Meminfo, rosh, Sanbboot */ =20 @@ -1252,70 +1350,13 @@ write_entry (struct output_buffer *outbuf, } case KERNEL_CONFIG: { - char *new_cwd, *new_target_cwd; const char *ap; ap =3D curentry->append; if (!ap) ap =3D curentry->argument; if (!ap) ap =3D ""; - new_cwd =3D get_read_filename (menu, ap); - if (!new_cwd) - return grub_errno; - new_target_cwd =3D get_target_filename (menu, ap); - if (!new_target_cwd) - return grub_errno; - - struct syslinux_menu *menuptr; - char *newname; - int depth =3D 0; -=09 - newname =3D get_read_filename (menu, curentry->kernel_file); - if (!newname) - return grub_errno; - simplify_filename (newname); - - print_string ("#"); - print_file (outbuf, menu, curentry->kernel_file, NULL); - print_string (" "); - print (outbuf, newname, grub_strlen (newname)); - print_string (":\n"); - - for (menuptr =3D menu; menuptr; menuptr =3D menuptr->parent, depth++) - if (grub_strcmp (menuptr->filename, newname) =3D=3D 0 - || depth > 20) - break; - if (menuptr) - { - print_string (" syslinux_configfile -r "); - print_file (outbuf, menu, "/", NULL); - print_string (" -c "); - print_file (outbuf, menu, ap, NULL); - print_string (" "); - print_file (outbuf, menu, curentry->kernel_file, NULL); - print_string ("\n"); - } - else - { - err =3D config_file (outbuf, menu->root_read_directory, - menu->root_target_directory, new_cwd, new_target_cwd, - newname, menu, menu->flavour); - if (err =3D=3D GRUB_ERR_FILE_NOT_FOUND - || err =3D=3D GRUB_ERR_BAD_FILENAME) - { - grub_errno =3D err =3D GRUB_ERR_NONE; - print_string ("# File "); - err =3D print (outbuf, newname, grub_strlen (newname)); - if (err) - return err; - print_string (" not found\n"); - } - if (err) - return err; - } - grub_free (newname); - grub_free (new_cwd); - grub_free (new_target_cwd); + print_config (outbuf, menu, curentry->kernel_file, ap); } break; case KERNEL_NO_KERNEL: --=20 1.9.1 --yQbNiKLmgenwUfTN-- --0OWHXb1mYLuhj1Ox Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJU3lyAAAoJEEAsIlA9Nuk2t0sP/itFHdMVm+qWbX1eAM12sMEn OdinQ8aV7yMTZJSbZqDAKe4qqTsKhul5l1UpHNE2G2KnT8dZt5MoNjGZSuho+4gU IyD26xH0fsqgSEdJ5psCGS0Hh7QXbHxy99mJLND7SEH4+oR7vHxOsVarTjj+6mt6 z439Kzv76BOb9e1xUoai7CWSeqLvh98dkSEeWKPLo5DbtUZrSpAC5wPO7JAsbzlk zUHnXQQpRi3zBHeZCdwLYsIkU2OZKRxydj0mJx//04zN1xznKj9j8mfS5NNc6C33 52VXZKWeHysXlQAd1LcuVjiG8P3nLLtm4b+ADuDKy0PRrcd6K5xx1CrbrNgsFVJ9 sajX8Ri67G51ethjudR+pXqtcapAPS1tTNlDg6eY44ThS9ooB0JjKyiHIT4S2Gch bD0kNo3MoCL8WDHh8owxEEsfzU/zMY6rY2XuBiBTd2LDThSYWQeJi9uzfriQkxoR wouKKOaStfQJdX0JBhUxAhV3D9lLngpxLJgB+ORQtTtq44slx/4hzgD+3SgoKfa0 7gDKOWUa/4gEiXZI1lSNn4p0+G5eE6CQi+x1jwx6Z+afSey2JcvEbTpJA9P5ir9n klxvAf344L8FoFm8arLMBtNdtzDvG47/N6ZSLhZNwgd26Y7wz1Hcm0df/oN1HyKU qX7YgsULm209DhwrOo3V =8UAG -----END PGP SIGNATURE----- --0OWHXb1mYLuhj1Ox--