1*f0d9efc0Sbeck 2*f0d9efc0SbeckFind file types by using a modified "magic" file 3*f0d9efc0Sbeck 4*f0d9efc0SbeckBased on file v3.22 by Ian F. Darwin (see libfile/LEGAL.NOTICE and 5*f0d9efc0Sbecklibfile/README.dist - File v3.22 can be found at many archive sites) 6*f0d9efc0Sbeck 7*f0d9efc0SbeckFor each entry in the magic file, the "message" for the initial offset MUST 8*f0d9efc0Sbeckbe 4 characters for the CREATOR and 4 characters for the TYPE - white space is 9*f0d9efc0Sbeckoptional between them. Any other characters on this line are ignored. 10*f0d9efc0SbeckContinuation lines (starting with a '>') are also ignored i.e. only the initial 11*f0d9efc0Sbeckoffset lines are used. 12*f0d9efc0Sbeck 13*f0d9efc0Sbecke.g magic entry for a GIF file: 14*f0d9efc0Sbeck 15*f0d9efc0Sbeck# off type test message 16*f0d9efc0Sbeck# 17*f0d9efc0Sbeck# GIF image 18*f0d9efc0Sbeck0 string GIF8 8BIM GIFf 19*f0d9efc0Sbeck>4 string 7a \b, version 8%s, 20*f0d9efc0Sbeck>4 string 9a \b, version 8%s, 21*f0d9efc0Sbeck>6 leshort >0 %hd x 22*f0d9efc0Sbeck>8 leshort >0 %hd, 23*f0d9efc0Sbeck#>10 byte &0x80 color mapped, 24*f0d9efc0Sbeck#>10 byte&0x07 =0x00 2 colors 25*f0d9efc0Sbeck#>10 byte&0x07 =0x01 4 colors 26*f0d9efc0Sbeck#>10 byte&0x07 =0x02 8 colors 27*f0d9efc0Sbeck#>10 byte&0x07 =0x03 16 colors 28*f0d9efc0Sbeck#>10 byte&0x07 =0x04 32 colors 29*f0d9efc0Sbeck#>10 byte&0x07 =0x05 64 colors 30*f0d9efc0Sbeck#>10 byte&0x07 =0x06 128 colors 31*f0d9efc0Sbeck#>10 byte&0x07 =0x07 256 colors 32*f0d9efc0Sbeck 33*f0d9efc0SbeckJust the "8BIM" "GIFf" will be used whatever the type of GIF file it is. 34*f0d9efc0SbeckThe continuation lines are used by the "file" command, but ignored by 35*f0d9efc0Sbeckmkhybrid. They could be left out completely. 36*f0d9efc0Sbeck 37*f0d9efc0SbeckThe complete format of the magic file is given in the magic man page (magic.5). 38*f0d9efc0Sbeck 39*f0d9efc0SbeckSee the file "magic" for other examples 40*f0d9efc0Sbeck 41*f0d9efc0SbeckUse with the -magic magic_file option, where magic_file is a file 42*f0d9efc0Sbeckdescribed above. 43*f0d9efc0Sbeck 44*f0d9efc0SbeckThe magic file can be used with the mapping file (option -map) - the order 45*f0d9efc0Sbeckthese options appear on the command line is important. mkhybrid will try to 46*f0d9efc0Sbeckdetect if the file is one of the Unix/Mac files (e.g. a CAP or Netatalk 47*f0d9efc0Sbeckfile) first. If that fails, it will then use the magic and/or mapping 48*f0d9efc0Sbeckfile e.g: 49*f0d9efc0Sbeck 50*f0d9efc0Sbeckmkhybrid -o output.raw -map mapping -magic magic src_dir 51*f0d9efc0Sbeck 52*f0d9efc0SbeckThe above will check filename extensions first, if that fails to set the 53*f0d9efc0SbeckCREATOR/TYPE, the magic file will be used. To check the magic file 54*f0d9efc0Sbeckbefore the filename extensions, use: 55*f0d9efc0Sbeck 56*f0d9efc0Sbeckmkhybrid -o output.raw -magic magic -map mapping src_dir 57*f0d9efc0Sbeck 58*f0d9efc0Sbeck 59*f0d9efc0SbeckUsing just a magic file - filename extensions will not be checked e.g: 60*f0d9efc0Sbeck 61*f0d9efc0Sbeckmkhybrid -o output.raw -magic magic src_dir 62*f0d9efc0Sbeck 63*f0d9efc0SbeckFor the magic method to work, each file must be opened and read twice 64*f0d9efc0Sbeck(once to find it's CREATOR/TYPE, and a second time to actually copy the 65*f0d9efc0Sbeckfile to the CD image). Therefore the -magic option may significantly 66*f0d9efc0Sbeckincrease processing time. 67*f0d9efc0Sbeck 68*f0d9efc0SbeckIf a file's CREATOR/TYPE is not set via the magic and mapping matches, 69*f0d9efc0Sbeckthen the file is given the default CREATOR/TYPE. 70