head	1.1;
access;
symbols
	netbsd-11-0-RC7:1.1
	netbsd-11-0-RC6:1.1
	netbsd-11-0-RC5:1.1
	netbsd-11-0-RC4:1.1
	netbsd-11-0-RC3:1.1
	netbsd-11-0-RC2:1.1
	netbsd-11-0-RC1:1.1
	perseant-exfatfs-base-20250801:1.1
	netbsd-11:1.1.0.6
	netbsd-11-base:1.1
	netbsd-10-1-RELEASE:1.1.4.2
	netbsd-10:1.1.0.4
	perseant-exfatfs-base-20240630:1.1
	perseant-exfatfs:1.1.0.2
	perseant-exfatfs-base:1.1;
locks; strict;
comment	@# @;


1.1
date	2024.05.31.19.49.02;	author tsutsui;	state Exp;
branches
	1.1.4.1;
next	;
commitid	woSxzLLKKep5KbcF;

1.1.4.1
date	2024.05.31.19.49.02;	author martin;	state dead;
branches;
next	1.1.4.2;
commitid	ukIKIblTxA6ajqgF;

1.1.4.2
date	2024.07.03.18.38.53;	author martin;	state Exp;
branches;
next	;
commitid	ukIKIblTxA6ajqgF;


desc
@@


1.1
log
@Import mkhybrid from OpenBSD 7.3 to create ISO9660/HFS hybrid ISO images.

- files in libfile except proto.h prepared by OpenBSD are not imported
  due to non-standard license
  (newer BSD Licensed versions will be imported later)
- unnecessary files for tools build are not imported
- RCSId strings are trimmed to avoid unintended substitutions

Proposed on tech-toolchain@@:
 https://mail-index.netbsd.org/tech-toolchain/2024/05/25/msg004355.html
@
text
@Making HFS bootable CDs

It *may* be possible to make the hybrid CD bootable on a Mac. As I do not
have easy access to a CD-R (nor a Mac) at the moment, I have not actually
created and written a bootable hybrid to CD - however, I *think* it will work!

A bootable HFS CD requires an Apple CD-ROM (or compatible) driver, a bootable
HFS partition and the necessary System, Finder, etc. files.

A driver can be obtained from any other Mac bootable CD-ROM using the
"apple_driver" utility (to make, type "make apple_driver"). This file can
then be used with the -boot-hfs-file option. See below for usage.

The HFS partition (i.e. the hybrid disk in our case) must contain a
suitable System Folder, again from another CD-ROM or disk.

For a partition to be bootable, it must have it's "boot block" set. The boot
block is in the first two blocks of a partition. For a non-bootable partition
the boot block is full of zeros. Normally, when a System file is copied to
partition on a Mac disk, the boot block is filled with a number of required
settings - unfortunately I don't know the full spec for the boot block ...

I'm guessing that this will work OK ...

Therefore, the utility "apple_driver" also extracts the boot block from the
first HFS partition it finds on the given CD-ROM and this is used for the
HFS partition created by mkhybrid.

To extract the driver and boot block:

apple_driver CDROM_device > HFS_driver_file

where CDROM_device is the device name used by the CD-ROM (e.g. /dev/cdrom)

The format of the HFS driver file is:

	HFS CD Label Block                              512 bytes
	Driver Partition Map (for 2048 byte blocks)     512 bytes
	Driver Partition Map (for 512 byte blocks)      512 bytes
	Empty                                           512 bytes
	Driver Partition                                N x 2048 bytes
	HFS Partition Boot Block                        1024 bytes

The Perl script "hdisk.pl" can be used to give a listing of what's on
a Mac CD. hdisk.pl is part of hfsutils.

A hybrid CD is made using the option "-boot-hfs-file" e.g.

mkhybrid -boot-hfs-file HFS_driver_file -o hfs.raw src_files/

The -boot-hfs-file implies the -hfs option.

PLEASE NOTE:

By using a driver from an Apple CD and copying Apple software to your CD,
you become liable to obey Apple Computer, Inc. Software License Agreements.

The driver code (both extracting the driver and creating partitions etc.
is based on code from "mkisofs 1.05 PLUS" by Andy Polyakov
<appro@@fy.chalmers.se> (see http://fy.chalmers.se/~appro/mkisofs_plus.html)


Any comments, bug reports/fixes to the address below

James Pearson (j.pearson@@ge.ucl.ac.uk)
18/5/98
@


1.1.4.1
log
@file README.hfs_boot was added on branch netbsd-10 on 2024-07-03 18:38:53 +0000
@
text
@d1 66
@


1.1.4.2
log
@Pull up following revision(s) (requested by tsutsui in ticket #733):

	external/gpl2/mkhybrid/dist/mkisofs.h: revision 1.6
	distrib/cdrom/Makefile: revision 1.55
	distrib/cdrom/macppc_installboot/Makefile: revision 1.12
	external/gpl2/mkhybrid/dist/getopt.c: revision 1.2
	external/gpl2/mkhybrid/dist/libfile/LEGAL.NOTICE: revision 1.1
	external/gpl2/mkhybrid/dist/write.c: revision 1.1
	distrib/cdrom/Makefile: revision 1.56
	distrib/cdrom/macppc_installboot/Makefile: revision 1.13
	distrib/cdrom/macppc_installboot/installboot.c: revision 1.6
	external/gpl2/mkhybrid/dist/getopt.c: revision 1.3
	external/gpl2/mkhybrid/dist/write.c: revision 1.2
	external/gpl2/mkhybrid/dist/libhfs_iso/data.h: revision 1.1
	distrib/cdrom/Makefile: revision 1.57
	distrib/cdrom/macppc_installboot/Makefile: revision 1.14
	distrib/cdrom/macppc_installboot/installboot.c: revision 1.7
	tools/Makefile: revision 1.221
	tools/Makefile: revision 1.222
	external/gpl2/mkhybrid/dist/libhfs_iso/file.h: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/README: revision 1.1
	distrib/macppc/Makefile: revision 1.18
	external/gpl2/mkhybrid/dist/TODO: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/block.h: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/record.c: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/hfs.c: revision 1.1
	external/gpl2/mkhybrid/dist/match.c: revision 1.1
	external/gpl2/mkhybrid/dist/libfile/softmagic.c: revision 1.1
	external/gpl2/mkhybrid/dist/match.c: revision 1.2
	external/gpl2/mkhybrid/dist/libfile/softmagic.c: revision 1.2
	external/gpl2/mkhybrid/dist/volume.c: revision 1.1
	external/gpl2/mkhybrid/dist/volume.c: revision 1.2
	external/gpl2/mkhybrid/dist/libhfs_iso/internal.h: revision 1.1
	external/gpl2/mkhybrid/dist/getopt1.c: revision 1.1
	external/gpl2/mkhybrid/dist/getopt1.c: revision 1.2
	external/gpl2/mkhybrid/dist/getopt1.c: revision 1.3
	external/gpl2/mkhybrid/dist/README.mkisofs: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/hybrid.h: revision 1.1
	tools/mkhybrid/Makefile: revision 1.1
	external/gpl2/mkhybrid/dist/README.hfs_magic: revision 1.1
	external/gpl2/mkhybrid/dist/apple.h: revision 1.1
	external/gpl2/mkhybrid/dist/include/prototyp.h: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/volume.h: revision 1.1
	external/gpl2/mkhybrid/dist/apple.h: revision 1.2
	external/gpl2/mkhybrid/dist/mkisofs.c: revision 1.1
	external/gpl2/mkhybrid/dist/desktop.c: revision 1.1
	external/gpl2/mkhybrid/dist/mkisofs.c: revision 1.2
	external/gpl2/mkhybrid/dist/desktop.c: revision 1.2
	external/gpl2/mkhybrid/dist/mkisofs.c: revision 1.3
	external/gpl2/mkhybrid/dist/mkisofs.c: revision 1.4
	external/gpl2/mkhybrid/dist/libfile/file.h: revision 1.1
	external/gpl2/mkhybrid/dist/mkisofs.c: revision 1.5
	external/gpl2/mkhybrid/dist/libfile/file.h: revision 1.2
	external/gpl2/mkhybrid/dist/mkisofs.c: revision 1.6
	external/gpl2/mkhybrid/dist/libfile/file.h: revision 1.3
	external/gpl2/mkhybrid/dist/mkisofs.c: revision 1.7
	external/gpl2/mkhybrid/dist/getopt.h: revision 1.1
	distrib/cdrom/macppc_installboot/installboot.h: revision 1.5
	etc/etc.mac68k/Makefile.inc: revision 1.25
	external/gpl2/mkhybrid/dist/getopt.h: revision 1.2
	external/gpl2/mkhybrid/dist/write.h: revision 1.1
	etc/etc.mac68k/Makefile.inc: revision 1.26
	external/gpl2/mkhybrid/dist/rock.c: revision 1.1
	external/gpl2/mkhybrid/dist/hash.c: revision 1.1
	external/gpl2/mkhybrid/dist/hash.c: revision 1.2
	external/gpl2/mkhybrid/dist/libhfs_iso/record.h: revision 1.1
	external/gpl2/mkhybrid/dist/README.hfs_boot: revision 1.1
	external/gpl2/mkhybrid/dist/README: revision 1.1
	external/gpl2/mkhybrid/dist/README.win32: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/hfs.h: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/hfs.h: revision 1.2
	external/gpl2/mkhybrid/dist/config.h.in: revision 1.1
	external/gpl2/mkhybrid/dist/config.h.in: revision 1.2
	distrib/cdrom/boothfs.uue: revision 1.2
	external/gpl2/mkhybrid/dist/config.h.in: revision 1.3
	external/gpl2/mkhybrid/dist/volume.h: revision 1.1
	external/gpl2/mkhybrid/dist/volume.h: revision 1.2
	external/gpl2/mkhybrid/dist/ChangeLog: revision 1.1
	external/gpl2/mkhybrid/dist/libfile/apprentice.c: revision 1.1
	external/gpl2/mkhybrid/dist/libfile/apprentice.c: revision 1.2
	external/gpl2/mkhybrid/dist/mapping: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/btree.h: revision 1.1
	external/gpl2/mkhybrid/bin/Makefile: revision 1.1
	external/gpl2/mkhybrid/dist/include/statdefs.h: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/Makefile: revision 1.1
	external/gpl2/mkhybrid/bin/Makefile: revision 1.2
	external/gpl2/mkhybrid/dist/magic: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/node.h: revision 1.1
	external/gpl2/mkhybrid/bin/Makefile: revision 1.3
	external/gpl2/mkhybrid/dist/acconfig.h: revision 1.1
	external/gpl2/mkhybrid/dist/eltorito.c: revision 1.1
	external/gpl2/mkhybrid/dist/libfile/patchlevel.h: revision 1.1
	share/mk/bsd.own.mk: revision 1.1375
	share/mk/bsd.own.mk: revision 1.1376
	external/gpl2/mkhybrid/dist/README.session: revision 1.1
	external/gpl2/mkhybrid/dist/libfile/lfile.c: revision 1.1
	external/gpl2/mkhybrid/dist/libfile/lfile.c: revision 1.2
	tools/macppc_installboot/Makefile: revision 1.1
	external/gpl2/mkhybrid/README.md: revision 1.1
	etc/etc.macppc/Makefile.inc: revision 1.13
	external/gpl2/mkhybrid/dist/defaults.h: revision 1.1
	external/gpl2/mkhybrid/dist/mkisofs.spec: revision 1.1
	external/gpl2/mkhybrid/dist/defaults.h: revision 1.2
	external/gpl2/mkhybrid/dist/mac_label.h: revision 1.1
	external/gpl2/mkhybrid/dist/defaults.h: revision 1.3
	external/gpl2/mkhybrid/dist/include/mconfig.h: revision 1.1
	external/gpl2/mkhybrid/dist/include/mconfig.h: revision 1.2
	external/gpl2/mkhybrid/dist/libfile/proto.h: revision 1.1
	external/gpl2/mkhybrid/dist/COPYING: revision 1.1
	external/gpl2/mkhybrid/dist/name.c: revision 1.1
	external/gpl2/mkhybrid/dist/configure.in: revision 1.1
	external/gpl2/mkhybrid/dist/configure.in: revision 1.2
	external/gpl2/mkhybrid/dist/mac_label_proto.h: revision 1.1
	external/gpl2/mkhybrid/dist/configure.in: revision 1.3
	external/gpl2/mkhybrid/dist/libhfs_iso/low.c: revision 1.1
	distrib/cdrom/macppc_mkboothfs/mkboothfs.c: revision 1.4
	external/gpl2/mkhybrid/dist/mkhybrid.8: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/btree.c: revision 1.1
	distrib/cdrom/macppc_installboot/cd9660.c: revision 1.5
	external/gpl2/mkhybrid/dist/config.h: revision 1.1
	external/gpl2/mkhybrid/dist/mkhybrid.8: revision 1.2
	distrib/cdrom/macppc_installboot/cd9660.c: revision 1.6
	external/gpl2/mkhybrid/dist/config.h: revision 1.2
	external/gpl2/mkhybrid/dist/libhfs_iso/node.c: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/data.c: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/file.c: revision 1.1
	external/gpl2/mkhybrid/dist/README.eltorito: revision 1.1
	external/gpl2/mkhybrid/dist/include/fctldefs.h: revision 1.1
	external/gpl2/mkhybrid/dist/libfile/README: revision 1.1
	external/gpl2/mkhybrid/dist/libhfs_iso/block.c: revision 1.1
	external/gpl2/mkhybrid/dist/mactypes.h: revision 1.1
	external/gpl2/mkhybrid/dist/apple_proto.h: revision 1.1
	external/gpl2/mkhybrid/dist/apple_proto.h: revision 1.2
	external/gpl2/mkhybrid/dist/multi.c: revision 1.1
	external/gpl2/mkhybrid/dist/match.h: revision 1.1
	external/gpl2/mkhybrid/dist/match.h: revision 1.2
	external/gpl2/mkhybrid/dist/mac_label.c: revision 1.1
	external/gpl2/mkhybrid/dist/Makefile.in: revision 1.1
	external/gpl2/mkhybrid/dist/mac_label.c: revision 1.2
	external/gpl2/mkhybrid/dist/libhfs_iso/lvolume.c: revision 1.1
	external/gpl2/mkhybrid/dist/Makefile.in: revision 1.2
	external/gpl2/mkhybrid/dist/configure: revision 1.1
	external/gpl2/mkhybrid/dist/configure: revision 1.2
	external/gpl2/mkhybrid/dist/install-sh: revision 1.1
	external/gpl2/mkhybrid/dist/configure: revision 1.3
	distrib/cdrom/macppc_installboot/cd9660.c: file removal
	external/gpl2/mkhybrid/dist/README.mkhybrid: revision 1.1
	external/gpl2/mkhybrid/dist/ChangeLog.mkhybrid: revision 1.1
	external/gpl2/mkhybrid/dist/iso9660.h: revision 1.1
	external/gpl2/mkhybrid/dist/joliet.c: revision 1.1
	external/gpl2/mkhybrid/dist/apple.c: revision 1.1
	external/gpl2/mkhybrid/dist/apple.c: revision 1.2
	external/gpl2/mkhybrid/dist/apple.c: revision 1.3
	etc/Makefile: revision 1.471
	external/gpl2/mkhybrid/dist/apple.c: revision 1.4
	external/gpl2/mkhybrid/dist/tree.c: revision 1.1
	etc/Makefile: revision 1.472
	external/gpl2/mkhybrid/dist/tree.c: revision 1.2
	external/gpl2/mkhybrid/dist/tree.c: revision 1.3
	external/gpl2/mkhybrid/dist/libhfs_iso/low.h: revision 1.1
	external/gpl2/mkhybrid/dist/mkisofs.h: revision 1.1
	external/gpl2/mkhybrid/dist/mkisofs.8: revision 1.1
	external/gpl2/mkhybrid/dist/mkisofs.h: revision 1.2
	external/gpl2/mkhybrid/dist/mkisofs.h: revision 1.3
	external/gpl2/mkhybrid/dist/mkisofs.h: revision 1.4
	external/gpl2/mkhybrid/dist/mkisofs.h: revision 1.5
	distrib/cdrom/Makefile: revision 1.54
	external/gpl2/mkhybrid/dist/getopt.c: revision 1.1

Add -data-change-warn to MKISOFS_ARGS for macppc as done for mac68k:
https://mail-index.netbsd.org/source-changes/2023/05/19/msg144826.html

Creating Type&Creator mappings for .bin (macbinary encoded) files,
mkisofs changes files, then turns around and complains they have been
changed.
This is a self-inflicted wound, so demote the error to a warning.
This looks to make macppccd builds with cdrtools-3.02a10.
Sync with src/usr.sbin/installboot/cd9660.c:
- include now properly updated cd9660_extern.h for function prototypes
  and remove them from local installboot.h
- use ISO_MAXNAMLEN rather than (BSD specific and incorrect) MAXNAMLEN
- use proper names for the secondary boot file
- appease several pointer signedness warnings (not fatal on HOST tools)
Use native cd9660 blocksize to specify block numbers in cd9660.c.
This reduces diffs from src/usr.sbin/installboot/cd9660.c.
Also explicitly call cd9660_match() to get fstype->blocksize properly.
Pull sharable src/usr.sbin/installboot/cd9660.c.
Import mkhybrid from OpenBSD 7.3 to create ISO9660/HFS hybrid ISO images.
- files in libfile except proto.h prepared by OpenBSD are not imported
  due to non-standard license
  (newer BSD Licensed versions will be imported later)
- unnecessary files for tools build are not imported
- RCSId strings are trimmed to avoid unintended substitutions
Proposed on tech-toolchain@@:
https://mail-index.netbsd.org/tech-toolchain/2024/05/25/msg004355.html

Import BSD licensed libfile for mkhybrid builds from cdrtools-3.01.
- unnecessary files for tools build are not imported
- file.c is renamed to lfile.c to avoid conflict with libhfs_iso
- RCSId strings are trimmed
Remove dependencies on non-existent exclude.h.
Pull changes from mkisofs-1.12.1 to avoid statvfs(2).
Make newer BSD Licensed libfile sources build as tools.
Update mkhybrid Makefile for NetBSD's tools builds.
Suppress implicit declaration warnings.
Appease discard-const warnings.
Remove duplicated SYSTEM_ID_DEFAULT definitions.
Don't redefine SYSTEM_ID_DEFAULT if it's specified in CPPFLAGS.
Remove ancient rlimit hacks for NetBSD disabled in cdrtools-2.01.
Always use local getopt.h as cdrtools-2.01 did.
Tweak and regen configure using autoconf-2.13 to use pkgsrc tools.
Check <stdlib.h> and <flock.h> in configure and regen config.h.
Use HAVE_CONFIG_H to include <stdlib.h> and <string.h> in getopt sources.
Appease more warnings and remove unused getopt functions.
Pull options -hide-joliet-trans-tbl and -hide-rr-moved from mkisofs-1.13.
Pull -graft-points option from mkisofs-1.13 and cdrtools-2.01.
Also remove #ifdef APPLE_HYB for NON-HFS changes to reduce diffs.
Tweak OPTION_* definitions to reduce diffs from mkisofs-1.13.
Pull malloc related fixes from cdrtools-2.01.
This seems to fix SIGSEGV during free(3) in write.c:write_one_file().
Build mkhybrid as a build tool.
Build mac68k and macppc iso images using tools/mkhybrid.
Drop -data-change-warn from MKISOFS_FLAGS.
It's available only on cdrtools-3.x and later.
Use tools/mkhybrid as MKISOFS for mac68k and future macppc.
Note about current status.
Also pull man page description of options pulled from mkisofs-1.13.
Don't print progress if -quiet is specfied as cdrtools-2.01 and later.
Exclude debug.tgz and xdebug.tgz from mac68k ISO to save ~320MB.
Drop -T (for non-Rock Ridge capable systems) from ${MKISOFS_FLAGS}.
Even old mac68k and macppc don't require it, and somehow TRANS.TBL
files are shown on NetBSD when the ISO images created with both -T
and and -hide-joliet-trans-tbl are mounted by mount_cd9660(8).
Note this also happens with mkisofs(8) from cdrtools-3.02,
but I have not investigated if it's expected behavior.
Build src/distrib/cdrom/macppc_installboot in src/tools as a tool.
Also use the tools version ${TOOLS_MACPPC_INSTALLBOOT} to create
bootable ISO9660/HFS hybrid installcd image for macppc.
Make sure NetBSD_BootBlock partition has 32KB to avoid extra padding.
It looks at least OpenFirmware 2.x fails to load the primary bootloader
in the NetBSD_BootBlock partition if the partition size is too small,
probably because OpenFirmware read() function implicitly uses 32KB blocks.
Build macppc iso with TOOL_MKHYBRID via "iso-image" target in src/etc.
No need to check and redefine C89 strerror(3) and strtoul(3).
Fixes build error on MacOS 10.4 with Xcode 2.5.
@
text
@a0 66
Making HFS bootable CDs

It *may* be possible to make the hybrid CD bootable on a Mac. As I do not
have easy access to a CD-R (nor a Mac) at the moment, I have not actually
created and written a bootable hybrid to CD - however, I *think* it will work!

A bootable HFS CD requires an Apple CD-ROM (or compatible) driver, a bootable
HFS partition and the necessary System, Finder, etc. files.

A driver can be obtained from any other Mac bootable CD-ROM using the
"apple_driver" utility (to make, type "make apple_driver"). This file can
then be used with the -boot-hfs-file option. See below for usage.

The HFS partition (i.e. the hybrid disk in our case) must contain a
suitable System Folder, again from another CD-ROM or disk.

For a partition to be bootable, it must have it's "boot block" set. The boot
block is in the first two blocks of a partition. For a non-bootable partition
the boot block is full of zeros. Normally, when a System file is copied to
partition on a Mac disk, the boot block is filled with a number of required
settings - unfortunately I don't know the full spec for the boot block ...

I'm guessing that this will work OK ...

Therefore, the utility "apple_driver" also extracts the boot block from the
first HFS partition it finds on the given CD-ROM and this is used for the
HFS partition created by mkhybrid.

To extract the driver and boot block:

apple_driver CDROM_device > HFS_driver_file

where CDROM_device is the device name used by the CD-ROM (e.g. /dev/cdrom)

The format of the HFS driver file is:

	HFS CD Label Block                              512 bytes
	Driver Partition Map (for 2048 byte blocks)     512 bytes
	Driver Partition Map (for 512 byte blocks)      512 bytes
	Empty                                           512 bytes
	Driver Partition                                N x 2048 bytes
	HFS Partition Boot Block                        1024 bytes

The Perl script "hdisk.pl" can be used to give a listing of what's on
a Mac CD. hdisk.pl is part of hfsutils.

A hybrid CD is made using the option "-boot-hfs-file" e.g.

mkhybrid -boot-hfs-file HFS_driver_file -o hfs.raw src_files/

The -boot-hfs-file implies the -hfs option.

PLEASE NOTE:

By using a driver from an Apple CD and copying Apple software to your CD,
you become liable to obey Apple Computer, Inc. Software License Agreements.

The driver code (both extracting the driver and creating partitions etc.
is based on code from "mkisofs 1.05 PLUS" by Andy Polyakov
<appro@@fy.chalmers.se> (see http://fy.chalmers.se/~appro/mkisofs_plus.html)


Any comments, bug reports/fixes to the address below

James Pearson (j.pearson@@ge.ucl.ac.uk)
18/5/98
@


