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>