MKHYBRID(8) | System Manager's Manual | MKHYBRID(8) |
mkhybrid - create an hybrid ISO9660/JOLIET/HFS filesystem with optional Rock Ridge attributes.
mkhybrid [ -a ] [ -abstract FILE ] [ -biblio FILE ] [ -b boot_image ] [ -c boot_catalog ] [ -copyright FILE ] [ -A application_id ] [ -f ] [ -d ] [ -D ] [ -hide glob ] [ -hide-list file ] [ -hide-joliet glob ] [ -hide-joliet-list file ] [ -J ] [ -l ] [ -L ] [ -log-file log_file ] [ -no-split-symlink-components ] [ -no-split-symlink-fields ] [ -path-list file ] [ -p preparer ] [ -print-size ] [ -P publisher ] [ -quiet ] [ -r ] [ -R ] [ -sysid ID ] [ -T | -table-name TABLE_NAME ] [ -v ] [ -V volid ] [ -volset ID ] [ -volset-size # ] [ -volset-seqno # ] [ -x path ] [ -z ] [ -m glob ] [ -hfs | -apple ] [ -map mapping_file ] [ -magic magic_file ] [ -no-mac-files ] [ -probe ] [ -no-desktop ] [ -mac-name ] [ -boot-hfs-file driver_file [ -part ] [ -auto AutoStart_file ] [ -cluster-size size ] [ -hide-hfs glob ] [ -hide-hfs-list file ] [ -hfs-volid hfs_volid ] [ -hfs-bless folder_name ] [ --cap ] [ --netatalk ] [ --double ] [ --ethershare ] [ --ushare ] [ --exchange ] [ --sgi ] [ --xinet ] [ --macbin ] [ --single ] -o filename pathspec [pathspec]
mkhybrid is effectively a pre-mastering program to generate an HFS/ISO9660/JOLIET hybrid filesystem. It is based on mkisofs(1) and will generate a pure ISO9660 filesystem unless the HFS hybrid command line options are given.
mkhybrid can generate a true (or shared) HFS hybrid filesystem. The same files are seen as HFS files when accessed from a Macintosh and as ISO9660 files when accessed from other machines. HFS stands for Hierarchical File System and is the native file system used on Macintosh computers.
As an alternative, mkhybrid can generate the Apple Entensions to ISO9660 for each file. These extensions provide each file with CREATOR, TYPE and certain Finder Flags when accessed from a Macintosh. See the MACINTOSH FILE FORMATS section below.
mkhybrid takes a snapshot of a given directory tree, and generates a binary image which will correspond to an ISO9660 or HFS filesystem when written to a block device.
mkhybrid is also capable of generating the System Use Sharing Protocol records specified by the Rock Ridge Interchange Protocol. This is used to further describe the files in the iso9660 filesystem to a unix host, and provides information such as longer filenames, uid/gid, posix permissions, and block and character devices.
Each file written to the iso9660 filesystem must have a filename in the 8.3 format (8 characters, period, 3 characters, all upper case), even if Rock Ridge is in use. This filename is used on systems that are not able to make use of the Rock Ridge extensions (such as MS-DOS), and each filename in each directory must be different from the other filenames in the same directory. mkhybrid generally tries to form correct names by forcing the unix filename to upper case and truncating as required, but often times this yields unsatisfactory results when there are cases where the truncated names are not all unique. mkhybrid assigns weightings to each filename, and if two names that are otherwise the same are found the name with the lower priority is renamed to have a 3 digit number as an extension (where the number is guaranteed to be unique). An example of this would be the files foo.bar and foo.bar.~1~ - the file foo.bar.~1~ would be written as FOO.000;1 and the file foo.bar would be written as FOO.BAR;1
When used with the HFS options, mkhybrid will attempt to recognise files stored in a number of Apple/Unix file formats and will copy the data and resource forks as well as any relevant finder information. See the MACINTOSH FILE FORMATS section below for more about formats mkhybrid supports.
Note that mkhybrid is not designed to communicate with the writer directly. Most writers have proprietary command sets which vary from one manufacturer to another, and you need a specialized tool to actually burn the disk. The cdwrite utility is one such tool that runs under Linux and performs this task. The latest version of cdwrite is capable of communicating with Phillips/IMS/Kodak, HP and Yamaha drives. Most writers come with some version of DOS software that allows a direct image copy of an iso9660 image to the writer. The current version of cdwrite is available from ftp://sunsite.unc.edu/utils/disk-management/cdwrite-2.0.tar.gz Note that cdwrite has not been actively maintained in recent times.
The cdrecord utility is another utility capable of burning an actual disc. The latest version of cdrecord is available from ftp://ftp.fokus.gmd.de/pub/unix/cdrecord Cdrecord is under constant development.
Also you should know that most cd writers are very particular about timing. Once you start to burn a disc, you cannot let their buffer empty before you are done, or you will end up with a corrupt disc. Thus it is critical that you be able to maintain an uninterrupted data stream to the writer for the entire time that the disc is being written.
pathspec is the path of the directory tree to be copied into the iso9660 filesystem. Multiple paths can be specified, and mkhybrid will merge the files found in all of the specified path components to form the cdrom image.
It is possible to graft the paths at points other than the root directory, and it is possible to graft files or directories onto the cdrom image with names different than what they have in the source filesystem. This is easiest to illustrate with a couple of examples. Let's start by assuming that a local file ../old.lis exists, and you wish to include it in the cdrom image.
foo/bar/=../old.lis
will include the file old.lis in the cdrom image at /foo/bar/old.lis, while
foo/bar/xxx=../old.lis
will include the file old.lis in the cdrom image at /foo/bar/xxx. The same sort of syntax can be used with directories as well. mkhybrid will create any directories required such that the graft points exist on the cdrom image - the directories do not need to appear in one of the paths. Any directories that are created on the fly like this will have permissions 0555 and appear to be owned by the person running mkhybrid. If you wish other permissions or owners of the intermediate directories, the easiest solution is to create real directories in the path such that mkhybrid doesn't have to invent them.
mkhybrid will also run on Win9X/NT4 machines when compiled with Cygnus' cygwin (available from http://sourceware.cygnus.com/cygwin/). Therefore most references in this man page to Unix can be replaced with Win32.
mkhybrid -o rom -m '*.o' -m core -m foobar
would exclude all files ending in ".o", called "core" or "foobar" to be copied to CDROM. Note that if you had a directory called "foobar" it too (and of course all its descendants) would be excluded.
NOTE: The -m and -x option description should both be updated, they are wrong. Both now work identical and use filename globbing. A file is exluded if either the last component matches or the whole path matches.
mkhybrid -o cd -x /local/dir1 -x /local/dir2 /local
NOTE: The -m and -x option description should both be updated, they are wrong. Both now work identical and use filename globbing. A file is exluded if either the last component matches or the whole path matches.
mkhybrid -o rom -hfs -hide-hfs '*.o' -hide-hfs foobar
would exclude all files ending in ".o" or called "foobar" from the HFS volume. Note that if you had a directory called "foobar" it too (and of course all its descendants) would be excluded. The glob can also be a path name relative to the source directories given on the command line. Example:
mkhybrid -o rom -hfs -hide-hfs src/html src
would exclude just the file or directory called "html" from the "src" directory. Any other file or directory called "html" in the tree will not be excluded. Should be used with the -hide and/or -hide-joliet options.
A Macintosh file has two properties associated with it which define which application created the file, the CREATOR and what data the file contains, the TYPE. Both are (exactly) 4 letter strings. Usually this allows a Macintosh user to double-click on a file and launch the correct application etc. The CREATOR and TYPE of a particular file can be found by using something like ResEdit (or similar) on a Macintosh.
The CREATOR and TYPE information is stored in all the various Apple/Unix encoded files. For other files it is possible to base the CREATOR and TYPE on the filename's extension using a mapping file (the -map option) and/or using the magic number (usually a signature in the first few bytes) of a file (the -magic option). If both these options are given, then their order on the command line is important. If the -map option is given first, then a filename extension match is attempted before a magic number match. However, if the -magic option is given first, then a magic number match is attempted before a filename extension match.
If a mapping or magic file is not used, or no match is found then the default CREATOR and TYPE for all regular files can be set by using entries in the .mkisofsrc file, otherwise the default CREATOR and TYPE are 'unix' and 'TEXT'.
The format of the mapping file is the same afpfile format as used by aufs. This file has five columns for the extension, file translation, CREATOR, TYPE and Comment. Lines starting with the '#' character are comment lines and are ignored. An example file would be like:
# Example filename mapping file | ||||
# | ||||
# EXTN | XLate | CREATOR | TYPE | Comment |
.tif | Raw | '8BIM' | 'TIFF' | "Photoshop TIFF image" |
.hqx | Ascii | 'BnHq' | 'TEXT' | "BinHex file" |
.doc | Raw | 'MSWD' | 'WDBN' | "Word file" |
.mov | Raw | 'TVOD' | 'MooV' | "QuickTime Movie" |
* | Ascii | 'ttxt' | 'TEXT' | "Text file" |
Where:
The format of the magic file is almost identical to the magic(4) file used by the Linux file(1) command - the routines for reading and decoding the magic file are based on the Linux file(1) command.
This file has four tab separated columns for the byte offset, type, test and message. Lines starting with the '#' character are comment lines and are ignored. An example file would be like:
# Example magic file | |||
# | |||
# off | type | test | message |
0 | string | GIF8 | 8BIM GIFf GIF image |
0 | beshort | 0xffd8 | 8BIM JPEG image data |
0 | string | SIT! | SIT! SIT! StuffIt Archive |
0 | string | \037\235 | LZIV ZIVU standard unix compress |
0 | string | \037\213 | GNUz ZIVU gzip compressed data |
0 | string | %! | ASPS TEXT Postscript |
0 | string | \004%! | ASPS TEXT PC Postscript with a ^D to start |
4 | string | moov | txtt MooV QuickTime movie file (moov) |
4 | string | mdat | txtt MooV QuickTime movie file (mdat) |
The format of the file is described in the magic(4) man page. The only difference here is that for each entry in the magic file, the message for the initial offset must be 4 characters for the CREATOR followed by 4 characters for the TYPE - white space is optional between them. Any other characters on this line are ignored. Continuation lines (starting with a '>') are also ignored i.e. only the initial offset lines are used.
Using the -magic option may significantly increase processing time as each file has to opened and read to find it's magic number.
In summary, for all files, the default CREATOR is 'unix' and the default TYPE is 'TEXT'. These can be changed by using entries in the .mkisofsrc file.
If the a file is in one of the known Apple/Unix formats (and the format has been selected), then the CREATOR and TYPE are taken from the values stored in the Apple/Unix file.
Other files can have their CREATOR and TYPE set from their file name extension (the -map option), or their magic number (the -magic option). If the default match is used in the mapping file, then these values override the default CREATOR and TYPE.
A full CREATOR/TYPE database can be found at http://www.angelfire.com/il/szekely/index.html
Macintosh files have two parts called the Data and Resource fork. Either may be empty. Unix (and many other OSs) can only cope with files having one part (or fork). To add to this, Macintosh files have a number of attributes associated with them - probably the most important are the TYPE and CREATOR. Again Unix has no concept of these types of attributes.
e.g. a Macintosh file may be a JPEG image where the image is stored in the Data fork and a desktop thumbnail stored in the Resource fork. It is usually the information in the data fork that is useful across platforms.
Therefore to store a Macintosh file on a Unix filesystem, a way has to be found to cope with the two forks and the extra attributes (which are referred to as the finder info). Unfortunately, it seems that every software package that stores Macintosh files on Unix has chosen a completely different storage method.
The Apple/Unix formats that mkhybrid (partially) supports are:
mkhybrid will attempt to set the CREATOR, TYPE, date and possibly other flags from the finder info. Additionally, if it exists, the Macintosh filename is set from the finder info, otherwise the Macintosh name is based on the Unix filename - see the MACINTOSH FILE NAMES section below.
When using the -apple option, the TYPE and CREATOR are stored in the optional System Use or SUSP field in the ISO9660 Directory Record - in much the same way as the Rock Ridge attributes are. In fact to make life easy, the Apple extensions are added at the beginning of the existing Rock Ridge attributes (i.e. to get the Apple extensions you get the Rock Ridge extensions as well).
The Apple extensions require the resource fork to be stored as an ISO9660 associated file. This is just like any normal file stored in the ISO9660 filesystem except that the associated file flag is set in the Directory Record (bit 2). This file has the same name as the data fork (the file seen by non-Apple machines). Associated files are normally ignored by other OSs
When using the -hfs option, the TYPE and CREATOR plus other finder info, are stored in a separate HFS directory, not visible on the ISO9660 volume. The HFS directory references the same data and resource fork files described above.
In most cases, it is better to use the -hfs option instead of the -apple option, as the latter imposes the limited ISO9660 characters allowed in filenames. However, the Apple extensions do give the advantage that the files are packed on the disk more efficiently and it may be possible to fit more files on a CD - important when the total size of the source files is approaching 650MB.
Where possible, the HFS filename that is stored with an Apple/Unix file is used for the HFS part of the CD. However, not all the Apple/Unix encodings store the HFS filename with the finderinfo. In these cases, the Unix filename is used - with escaped special characters. Special characters include '/' and characters with codes over 127.
Aufs escapes these characters by using ":" followed by the character code as two hex digits. Netatalk and EtherShare have a similar scheme, but uses "%" instead of a ":".
If mkhybrid can't find an HFS filename, then it uses the Unix name, with any %xx or :xx characters (xx == two hex digits) converted to a single character code. If "xx" are not hex digits ([0-9a-fA-F]), then they are left alone - although any remaining ":" is converted to "%" as colon is the HFS directory separator. Care must be taken, as an ordinary Unix file with %xx or :xx will also be converted. e.g.
This:2fFile | converted to This/File |
This:File | converted to This%File |
This:t7File | converted to This%t7File |
Although HFS filenames appear to support upper and lower case letters, the filesystem is case insensitive. i.e. the filenames "aBc" and "AbC" are the same. If a file is found in a directory with the same HFS name, then mkhybrid will attempt, where possible, to make a unique name by adding '_' characters to one of the filenames.
If an HFS filename exists for a file, then mkhybrid can use this name as the starting point for the ISO9660, Joliet and Rock Ridge filenames using the -mac-name option. Normal Unix files without an HFS name will still use their Unix name. e.g.
If a MacBinary (or PC Exchange) file is stored as someimage.gif.bin on the Unix filesystem, but contains a HFS file called someimage.gif, then this is the name that would appear on the HFS part of the CD. However, as mkhybrid uses the Unix name as the starting point for the other names, then the ISO9660 name generated will probably be SOMEIMAG.BIN and the Joliet/Rock Ridge would be someimage.gif.bin. Although the actual data (in this case) is a GIF image. This option will use the HFS filename as the starting point and the ISO9660 name will probably be SOMEIMAG.GIF and the Joliet/Rock Ridge would be someimage.gif.
Using the -mac-name option will not currently work with the -T option - the Unix name will be used in the TRANS.TBL file, not the Macintosh name.
The existing mkisofs code will filter out any illegal characters for the ISO9660 and Joliet filenames, but as mkisofs expects to be dealing directly with Unix names, it leaves the Rock Ridge names as is. But as '/' is a legal HFS filename character, the -mac-name option coverts '/' to a '_' in a Rock Ridge filenames.
If the Apple extensions are used, then only the ISO9660 filenames will appear on the Macintosh. However, as the Macintosh ISO9660 drivers can use Level 2 filenames, then you can use the -l option without problems on a Macintosh - still take care over the names, for example this.file.name will be converted to THIS.FILE i.e. only have one '.', also filename abcdefgh will be seen as ABCDEFGH but abcdefghi will be seen as ABCDEFGHI. i.e. with a '.' at the end - don't know if this is a Macintosh problem or mkisofs/mkhybrid problem. All filenames will be in uppercase when viewed on a Macintosh. Of course, DOS/Win3.X machines will not be able to see Level 2 filenames...
As Macintosh filenames do use the '~' and '#' characters (especially when using PC Exchange Macintosh files), then the -a option should be given.
It may be possible to make the hybrid CD bootable on a Macintosh.
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 Macintosh bootable CD-ROM using the apple_driver utility. This file can then be used with the -boot-hfs-file option.
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 Macintosh disk, the boot block is filled with a number of required settings - unfortunately I don't know the full spec for the boot block, so I'm guessing that the following 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.
mkhybrid looks for the .mkisofsrc file, first in the current working directory, then in the user's home directory, and then in the directory in which the mkhybrid binary is stored. This file is assumed to contain a series of lines of the form "TAG=value", and in this way you can specify certain options. The case of the tag is not significant. Some fields in the volume header are not settable on the command line, but can be altered through this facility. Comments may be placed in this file, using lines which start with a hash (#) character.
mkhybrid can also be configured at compile time with defaults for many of these fields. See the file defaults.h.
mkisofs is not based on the standard mk*fs tools for unix, because we must generate a complete copy of an existing filesystem on a disk in the iso9660 filesystem. The name mkisofs is probably a bit of a misnomer, since it not only creates the filesystem, but it also populates it as well.
Eric Youngdale <ericy@gnu.ai.mit.edu> or <eric@andante.jic.com> wrote both the Linux isofs9660 filesystem and the mkisofs utility, and is currently maintaining them. The copyright for the mkisofs utility is held by Yggdrasil Computing, Incorporated.
mkhybrid is based on mkisofs and works in exactly the same way as mkisofs without the HFS options. The change in name is to signify that it does something extra. If you do not need the HFS options, then you should really be using mkisofs.
HFS hybrid code Copyright (C) James Pearson 1997, 1998, 1999
libhfs code Copyright (C) 1996, 1997 Robert Leslie
libfile code Copyright (C) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992,
1994, 1995.
Any files that have hard links to files not in the tree being copied to the iso9660 filesystem will have an incorrect file reference count.
There may be some other ones. Please, report them to the author.
I have had to make several assumptions on how I expect the modified libhfs routines to work, however there may be situations that either I haven't thought of, or come across when these assumptions fail. Therefore I can't guarantee that mkhybrid will work as expected (although I haven't had a major problem yet). Most of the HFS features work fine, however, some are not fully tested. These are marked as Alpha above.
Output volume size must be at least 800Kb (libhfs limit - shouldn't really be a problem).
Although HFS filenames appear to support upper and lower case letters, the filesystem is case insensitive. i.e. the filenames "aBc" and "AbC" are the same. If a file is found in a directory with the same HFS name, then mkhybrid will attempt, where possible, to make a unique name by adding '_' characters to one of the filenames.
HFS file/directory names that share the first 31 characters have _N' (N == decimal number) substituted for the last few characters to generate unique names.
Care must be taken when "grafting" Apple/Unix files or directories (see above for the method and syntax involved). It is not possible to use a new name for an Apple/Unix encoded file/directory. e.g. If a Apple/Unix encoded file called "oldname" is to added to the CD, then you can not use the command line:
mkhybrid will be unable to decode "oldname". However, you can graft Apple/Unix encoded files or directories as long as you do not atempt to give them new names as above.
The -M option has no real meaning with an HFS volume - and will probably not work.
Symbolic links (as with all other non-regular files) are not added to the HFS directory.
Hybrid volumes may be larger than pure ISO9660 volumes containing the same data.
The resulting hybrid volume can be accessed on a Unix machine by using the hfsutils routines. However, no changes should be made to the contents of the volume as it's not a "real" HFS volume.
Using the -mac-name option will not currently work with the -T option - the Unix name will be used in the TRANS.TBL file, not the Macintosh name.
Although mkhybrid does not alter the contents of a file, if a binary file has it's TYPE set as 'TEXT', it may be read incorrectly on a Macintosh. Therefore a better choice for the default TYPE may be '????'
The -mac-boot-file option may not work at all...
The -a option should be used at all times. It may well become the default in future releases.
May not work with PC Exchange v2.2 or higher files (available with MacOS 8.1). DOS media containing PC Exchange files should be mounted as type msdos (not vfat) when using Linux.
mkisofs(8), magic(5), apple_driver(8)
Some sort of gui interface.
mkisofs is available for anonymous ftp from ftp://tsx-11.mit.edu/pub/linux/packages/mkisofs and many other mirror sites.
mkhybrid is available from ftp://ftp.ge.ucl.ac.uk/pub/mkhfs and hfsutils from ftp://ftp.mars.org/pub/hfs
7 April 1999 | Version 1.12b5.1 |