From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1XuSXm-0005YM-NL for mharc-grub-devel@gnu.org; Fri, 28 Nov 2014 15:53:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuSXf-0005L6-Gm for grub-devel@gnu.org; Fri, 28 Nov 2014 15:53:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XuSXa-0004Vj-Nw for grub-devel@gnu.org; Fri, 28 Nov 2014 15:53:27 -0500 Received: from mail-wg0-x231.google.com ([2a00:1450:400c:c00::231]:34009) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuSXa-0004Us-E9 for grub-devel@gnu.org; Fri, 28 Nov 2014 15:53:22 -0500 Received: by mail-wg0-f49.google.com with SMTP id n12so1412042wgh.8 for ; Fri, 28 Nov 2014 12:53:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=2uFZ7MY8TPs7vce9QwaXSjXsofWC34nAU2DrZ0ElSj8=; b=Rt15dUYtlTBQa36CjTyNR+UnqLLxQTw8kOt9+A2zL+ToE4GH3X6JMDIJsdmD32Mp7f /0AwleHfJdFlQ7yjR/1AgeL2NCoTgJnZaLc8WnBjsy5ty/Csf4bV1EVJFq6fjJ6EjOp/ Ax8LbPnp7mkewEALNJgat49gqPiu9/qSw4V2Zzsy4e7ZTtCb8h/OD0cPc8YohEsbGnzp A/LpXp8XUZxRIaGQQQpK5LRRCI6k/pihQp4nRssHnvUnz9fJwy7x74bZEooiUoFqc7V+ SBXdMbCn2OfsQnDPwi/8WU6r3fqurvkWTtIRFwfi1ypulfRTYvI9oxf15WjeyuUbifXB mgHA== X-Received: by 10.180.198.209 with SMTP id je17mr49270750wic.17.1417208001789; Fri, 28 Nov 2014 12:53:21 -0800 (PST) Received: from [10.222.38.128] ([212.213.198.101]) by mx.google.com with ESMTPSA id he3sm16486468wjc.15.2014.11.28.12.53.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Nov 2014 12:53:20 -0800 (PST) Message-ID: <5478CFCF.9010601@gmail.com> Date: Fri, 28 Nov 2014 21:41:03 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 MIME-Version: 1.0 To: The development of GNU GRUB , Thomas Schmitt Subject: Re: About the CLI of both grub-mkrescue versions References: <26976546057851911994@scdbackup.webframe.org> <1495546211684188288@scdbackup.webframe.org> In-Reply-To: <1495546211684188288@scdbackup.webframe.org> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="f0ggcI5BJIn2oGlpOkgmMKXpjMoIDmMhw" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::231 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, 28 Nov 2014 20:53:32 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --f0ggcI5BJIn2oGlpOkgmMKXpjMoIDmMhw Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01.10.2014 10:25, Thomas Schmitt wrote: > Hi, >=20 > to substantiate my proposal of renaming young grub-mkrescue.c to > grub-mkiso.c and to add a built-in emulation of grub-mkrescue(.in), > here the necessary code which i tested standalone with valgrind. >=20 > The decision which parser to use would be made in main(): >=20 I think that old parser is better. The only reason the change happened is that it's a bug that sneaked in during migration to C. It should be fixed. > -------------------------------------------------------------- >=20 > char *cpt; > ... > /* Get leaf name of argv[0] */ > for (cpt =3D argv[0] + strlen (argv[0]) - 1; cpt >=3D argv[0]; cpt--)= > if (*cpt =3D=3D '/') > break; > cpt++; > if (strcmp (cpt, "grub-mkrescue") =3D=3D 0) > { > arg_parser_mkrescue (argc, argv); > } > else > { > argp_parse (&argp, argc, argv, 0, 0, 0); > } >=20 > -------------------------------------------------------------- >=20 > The help text is derived from grub-mkrescue.in of GRUB 2.00. >=20 > -------------------------------------------------------------- >=20 > static void > printc (char *line) > { > printf ("%s\n", line); > } >=20 > static void > print_mkrescue_help (char *prog_name) > { > printf ("%s %s %s\n", _("Usage:"), prog_name, _("[OPTION] SOURCE...")= ); > printc (_("Make GRUB CD-ROM, disk, pendrive and floppy bootable image= =2E")); > printc (_("-h, --help")); > printc (_(" print this message and exit")); > printc (_("-v, --version")); > printc (_(" print the version information and exit")); > printc (_("-o, --output=3DFILE")); > printc (_(" save output in FILE [required]")); > printc (_("--rom-directory=3DDIR")); > printc (_(" save ROM images in DIR [optional]")); > printc (_("--xorriso=3DFILE")); > printc (_(" use FILE as xorriso [optional]")); > printc (_("Not supported any more are:")); > printc (_(" --modules , --grub-mkimage , --override-directory"= )); > printc (_("Other arguments get forwarded to xorriso -as mkisofs")); > printc (_("emulation.")); > printc (""); > printf ("%s %s\n", prog_name, _("generates a bootable rescue image"))= ; > printc (_("with specified source files, source directories, or mkisof= s")); > printc (_("options listed by the output of `xorriso -as mkisofs -help= '")); > printc (""); > printc (_("Note: Do not use option \"--\" unless you want to submit")= ); > printc (_(" native xorriso commands instead of file paths or"));= > printc (_(" mkisofs options. See man xorrisofs and man xorriso."= )); > printc (""); > printc (_("Report bugs to .")); > printc (_("Mail xorriso support requests to ."))= ; > printc (""); > printc (_("This is program grub-mkiso emulating the option")); > printc (_("interpretation of legacy program grub-mkrescue.")); > printc (_("grub-mkiso in its native mode has more advanced options.")= ); > printc (_("But that mode demands to separate grub-mkiso options")); > printc (_("and xorriso options by a double dash \"--\", which xorriso= ")); > printc (_("will not get to see.")); > } >=20 > -------------------------------------------------------------- >=20 > The parser function implements the promised options and collects > the xorriso -as mkisofs options into the same char pointer array > as does the existing parser in the C program. > In particular it sets the values of these variables: >=20 > static char *rom_directory; > static int xorriso_tail_argc; > static int xorriso_tail_arg_alloc; > static char **xorriso_tail_argv; > static char *output_image; > static char *xorriso; >=20 > -------------------------------------------------------------- >=20 > static void > arg_parser_mkrescue (int argc, char *argv[]) > { > int i; >=20 > for (i =3D 1; i < argc; i++) > { > if (strcmp (argv[i], "-h") =3D=3D 0 || strcmp (argv[i], "--help")= =3D=3D 0) > { > print_mkrescue_help (argv[0]); > exit (0); > } > else if (strcmp (argv[i], "-v") =3D=3D 0 > || strcmp (argv[i], "--version") =3D=3D 0) > { > printf ("%s %s %s\n", argv[0], PACKAGE_NAME, PACKAGE_VERSION)= ; > exit (0); > } > else if (strcmp (argv[i], "--modules") =3D=3D 0) > { > grub_util_error (_("Option --modules is not supported any mor= e")); > } > else if (strncmp (argv[i], "--modules=3D", 10) =3D=3D 0) > { > grub_util_error (_("Option --modules=3D is not supported any = more")); > } > else if (strcmp (argv[i], "-o") =3D=3D 0 > || strcmp (argv[i], "--output") =3D=3D 0) > { > if (i =3D=3D argc - 1) > grub_util_error (_("option requires an argument -- `%s'"), > argv[i]); > i++; > free (output_image); > output_image =3D xstrdup (argv[i]); > } > else if (strncmp (argv[i], "--output=3D", 9) =3D=3D 0) > { > free (output_image); > output_image =3D xstrdup (argv[i] + 9); > } > else if (strcmp (argv[i], "--rom-directory") =3D=3D 0) > { > if (i =3D=3D argc - 1) > grub_util_error (_("option requires an argument -- `%s'"), > argv[i]); > i++; > free (rom_directory); > rom_directory =3D xstrdup (argv[i]); > } > else if (strncmp (argv[i], "--rom-directory=3D", 16) =3D=3D 0) > { > free (rom_directory); > rom_directory =3D xstrdup (argv[i] + 16); > } > else if (strcmp (argv[i], "--override-directory") =3D=3D 0) > { > grub_util_error( > _("Option --override-directory is not supported any = more")); > } > else if (strncmp (argv[i], "--override-directory=3D", 21) =3D=3D = 0) > { > grub_util_error( > _("Option --override-directory=3D is not supported an= y more")); > } > else if (strcmp (argv[i], "--xorriso") =3D=3D 0) > { > if (i =3D=3D argc - 1) > grub_util_error (_("option requires an argument -- `%s'"), > argv[i]); > i++; > free (xorriso); > xorriso =3D xstrdup (argv[i]); > } > else if (strncmp (argv[i], "--xorriso=3D", 10) =3D=3D 0) > { > free (xorriso); > xorriso =3D xstrdup (argv[i] + 10); > } > else > { > if (xorriso_tail_arg_alloc <=3D xorriso_tail_argc) > { > xorriso_tail_arg_alloc =3D 2 * (4 + xorriso_tail_argc); > xorriso_tail_argv =3D xrealloc (xorriso_tail_argv, > sizeof (xorriso_tail_argv[0]) > * xorriso_tail_arg_alloc); > } > xorriso_tail_argv[xorriso_tail_argc++] =3D xstrdup (argv[i]);= > } > } > } >=20 > -------------------------------------------------------------- >=20 > There remains the incompatibility that i could not find > equivalents of the following grub-mkrescue.in features: >=20 > --modules=3DMODULES > pre-load specified modules MODULES > --grub-mkimage=3DFILE > use FILE as grub-mkimage > --override-directory > "Intentionally undocumented" >=20 > -------------------------------------------------------------- >=20 > The valgrind test was made with a mock-up of grub-mkiso.c > consisting of some copied util/grub-*.c functions and a main() > which prints the content of the variables after parsing. >=20 > ln -s grub-mkiso grub-mkrescue > valgrind ./grub-mkrescue -o output.iso -J --rom-directory=3D./ROMDIR = -P YET_ANOTHER_OS.ORG --md5 --emul-toc ./my_os_payload --xorriso=3D"$HOME= "/xorriso-1.3.8/xorriso/xorriso >=20 > yielded: >=20 > output_image=3D 'output.iso' > rom_directory=3D './ROMDIR' > xorriso=3D '/home/thomas/xorriso-1.3.8/xorriso/xorriso= ' > xorriso_tail_arg_alloc=3D 8 > xorriso_tail_argc=3D 6 > xorriso_tail_argv[ 0]=3D '-J' > xorriso_tail_argv[ 1]=3D '-P' > xorriso_tail_argv[ 2]=3D 'YET_ANOTHER_OS.ORG' > xorriso_tail_argv[ 3]=3D '--md5' > xorriso_tail_argv[ 4]=3D '--emul-toc' > xorriso_tail_argv[ 5]=3D './my_os_payload' > =3D=3D9810=3D=3D=20 > =3D=3D9810=3D=3D ERROR SUMMARY: 0 errors from 0 contexts (suppressed:= 2 from 1) > ... > =3D=3D9810=3D=3D LEAK SUMMARY: > =3D=3D9810=3D=3D definitely lost: 0 bytes in 0 blocks. > =3D=3D9810=3D=3D possibly lost: 0 bytes in 0 blocks. > =3D=3D9810=3D=3D still reachable: 185 bytes in 10 blocks. > =3D=3D9810=3D=3D suppressed: 0 bytes in 0 blocks. >=20 > The memory leaks are caused by allocated storage of global > variables. >=20 >=20 > Have a nice day :) >=20 > Thomas >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >=20 --f0ggcI5BJIn2oGlpOkgmMKXpjMoIDmMhw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iF4EAREKAAYFAlR4z88ACgkQmBXlbbo5nOsaMAD/e1KPifrseYeXvGhjeG4xE+Tl jOU7JZzwGHSLmv3fFBQA/3VBhM2j8moyu5NrXyMveWSrhVfQwvL0aZHAeS1HfVh8 =mk/I -----END PGP SIGNATURE----- --f0ggcI5BJIn2oGlpOkgmMKXpjMoIDmMhw--