utils/isohybrid.c: Introduce option --mbr and make isohybrid.c compilable standalone
commit9b32a80b97e1ad976d304c3940f50e8d66c158b8
authorThomas Schmitt <scdbackup@gmx.net>
Sun, 22 Jun 2014 20:24:22 +0000 (22 22:24 +0200)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 24 Jun 2014 02:48:59 +0000 (23 19:48 -0700)
tree82701a001d0a9e5240aa290d7f107715f3eaa7e8
parent8b7a805803bd5247a15dfcd60df8a22586b07fd0
utils/isohybrid.c: Introduce option --mbr and make isohybrid.c compilable standalone

Although isohybrid.c is supposed to be a companion of the local SYSLINUX
installation, there may be situations where the file isolinux.bin and the
matching MBR template do not stem directly from such an installation.

This change adds an option --mbr, which allows to load an MBR template
file. This may be an isohdp[fp]x*.bin MBR template from the local SYSLINUX
installation, or the first 512 bytes of the isohybrid-capable ISO image
from which isolinux.bin and the other ISOLINUX files are taken.

If macro ISOHYBRID_C_STANDALONE is defined, then the hardcoded MBR templates
are not accessible and isohdpfx.o is not needed at compile time. In this
case, option --mbr becomes mandatory.
I used this for testing my changes with Fedora-Live-Desktop-x86_64-20-1.iso.

isohybrid.c is then compilable without further components of ISOLINUX by:

  cc -DISOHYBRID_C_STANDALONE -Wall -o isohybrid isohybrid.c -luuid

Test run:

  cp Fedora-Live-Desktop-x86_64-20-1.iso \
     Fedora-Live-Desktop-x86_64-20-1-rehybrid.iso

  valgrind ./isohybrid --uefi --mac \
           --mbr Fedora-Live-Desktop-x86_64-20-1.mbr \
           Fedora-Live-Desktop-x86_64-20-1-rehybrid.iso

yields:

  ==13828== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 1)
  ...
  ==13828== LEAK SUMMARY:
  ==13828==    definitely lost: 2,048 bytes in 1 blocks.

(Not that valgrind would have detected the memcpy() abuse of patch 001.
 But at least i seem to have not introduced more obvious sins.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
utils/isohybrid.c