xref: /freebsd/contrib/file/doc/magic.man (revision 0a36787e4c1fa0cf77dcf83be0867178476e372b)
1.\" $File: magic.man,v 1.98 2020/05/09 18:55:23 christos Exp $
2.Dd May 9, 2020
3.Dt MAGIC __FSECTION__
4.Os
5.\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
6.Sh NAME
7.Nm magic
8.Nd file command's magic pattern file
9.Sh DESCRIPTION
10This manual page documents the format of magic files as
11used by the
12.Xr file __CSECTION__
13command, version __VERSION__.
14The
15.Xr file __CSECTION__
16command identifies the type of a file using,
17among other tests,
18a test for whether the file contains certain
19.Dq "magic patterns" .
20The database of these
21.Dq "magic patterns"
22is usually located in a binary file in
23.Pa __MAGIC__.mgc
24or a directory of source text magic pattern fragment files in
25.Pa __MAGIC__ .
26The database specifies what patterns are to be tested for, what message or
27MIME type to print if a particular pattern is found,
28and additional information to extract from the file.
29.Pp
30The format of the source fragment files that are used to build this database
31is as follows:
32Each line of a fragment file specifies a test to be performed.
33A test compares the data starting at a particular offset
34in the file with a byte value, a string or a numeric value.
35If the test succeeds, a message is printed.
36The line consists of the following fields:
37.Bl -tag -width ".Dv message"
38.It Dv offset
39A number specifying the offset (in bytes) into the file of the data
40which is to be tested.
41This offset can be a negative number if it is:
42.Bl -bullet  -compact
43.It
44The first direct offset of the magic entry (at continuation level 0),
45in which case it is interpreted an offset from end end of the file
46going backwards.
47This works only when a file descriptor to the file is available and it
48is a regular file.
49.It
50A continuation offset relative to the end of the last up-level field
51.Dv ( \*[Am] ) .
52.El
53.It Dv type
54The type of the data to be tested.
55The possible values are:
56.Bl -tag -width ".Dv lestring16"
57.It Dv byte
58A one-byte value.
59.It Dv short
60A two-byte value in this machine's native byte order.
61.It Dv long
62A four-byte value in this machine's native byte order.
63.It Dv quad
64An eight-byte value in this machine's native byte order.
65.It Dv float
66A 32-bit single precision IEEE floating point number in this machine's native byte order.
67.It Dv double
68A 64-bit double precision IEEE floating point number in this machine's native byte order.
69.It Dv string
70A string of bytes.
71The string type specification can be optionally followed
72by /[WwcCtbT]*.
73The
74.Dq W
75flag compacts whitespace in the target, which must
76contain at least one whitespace character.
77If the magic has
78.Dv n
79consecutive blanks, the target needs at least
80.Dv n
81consecutive blanks to match.
82The
83.Dq w
84flag treats every blank in the magic as an optional blank.
85The
86.Dq c
87flag specifies case insensitive matching: lower case
88characters in the magic match both lower and upper case characters in the
89target, whereas upper case characters in the magic only match upper case
90characters in the target.
91The
92.Dq C
93flag specifies case insensitive matching: upper case
94characters in the magic match both lower and upper case characters in the
95target, whereas lower case characters in the magic only match upper case
96characters in the target.
97To do a complete case insensitive match, specify both
98.Dq c
99and
100.Dq C .
101The
102.Dq t
103flag forces the test to be done for text files, while the
104.Dq b
105flag forces the test to be done for binary files.
106The
107.Dq T
108flag causes the string to be trimmed, i.e. leading and trailing whitespace
109is deleted before the string is printed.
110.It Dv pstring
111A Pascal-style string where the first byte/short/int is interpreted as the
112unsigned length.
113The length defaults to byte and can be specified as a modifier.
114The following modifiers are supported:
115.Bl -tag -compact -width B
116.It B
117A byte length (default).
118.It H
119A 2 byte big endian length.
120.It h
121A 2 byte little endian length.
122.It L
123A 4 byte big endian length.
124.It l
125A 4 byte little endian length.
126.It J
127The length includes itself in its count.
128.El
129The string is not NUL terminated.
130.Dq J
131is used rather than the more
132valuable
133.Dq I
134because this type of length is a feature of the JPEG
135format.
136.It Dv date
137A four-byte value interpreted as a UNIX date.
138.It Dv qdate
139An eight-byte value interpreted as a UNIX date.
140.It Dv ldate
141A four-byte value interpreted as a UNIX-style date, but interpreted as
142local time rather than UTC.
143.It Dv qldate
144An eight-byte value interpreted as a UNIX-style date, but interpreted as
145local time rather than UTC.
146.It Dv qwdate
147An eight-byte value interpreted as a Windows-style date.
148.It Dv beid3
149A 32-bit ID3 length in big-endian byte order.
150.It Dv beshort
151A two-byte value in big-endian byte order.
152.It Dv belong
153A four-byte value in big-endian byte order.
154.It Dv bequad
155An eight-byte value in big-endian byte order.
156.It Dv befloat
157A 32-bit single precision IEEE floating point number in big-endian byte order.
158.It Dv bedouble
159A 64-bit double precision IEEE floating point number in big-endian byte order.
160.It Dv bedate
161A four-byte value in big-endian byte order,
162interpreted as a Unix date.
163.It Dv beqdate
164An eight-byte value in big-endian byte order,
165interpreted as a Unix date.
166.It Dv beldate
167A four-byte value in big-endian byte order,
168interpreted as a UNIX-style date, but interpreted as local time rather
169than UTC.
170.It Dv beqldate
171An eight-byte value in big-endian byte order,
172interpreted as a UNIX-style date, but interpreted as local time rather
173than UTC.
174.It Dv beqwdate
175An eight-byte value in big-endian byte order,
176interpreted as a Windows-style date.
177.It Dv bestring16
178A two-byte unicode (UCS16) string in big-endian byte order.
179.It Dv leid3
180A 32-bit ID3 length in little-endian byte order.
181.It Dv leshort
182A two-byte value in little-endian byte order.
183.It Dv lelong
184A four-byte value in little-endian byte order.
185.It Dv lequad
186An eight-byte value in little-endian byte order.
187.It Dv lefloat
188A 32-bit single precision IEEE floating point number in little-endian byte order.
189.It Dv ledouble
190A 64-bit double precision IEEE floating point number in little-endian byte order.
191.It Dv ledate
192A four-byte value in little-endian byte order,
193interpreted as a UNIX date.
194.It Dv leqdate
195An eight-byte value in little-endian byte order,
196interpreted as a UNIX date.
197.It Dv leldate
198A four-byte value in little-endian byte order,
199interpreted as a UNIX-style date, but interpreted as local time rather
200than UTC.
201.It Dv leqldate
202An eight-byte value in little-endian byte order,
203interpreted as a UNIX-style date, but interpreted as local time rather
204than UTC.
205.It Dv leqwdate
206An eight-byte value in little-endian byte order,
207interpreted as a Windows-style date.
208.It Dv lestring16
209A two-byte unicode (UCS16) string in little-endian byte order.
210.It Dv melong
211A four-byte value in middle-endian (PDP-11) byte order.
212.It Dv medate
213A four-byte value in middle-endian (PDP-11) byte order,
214interpreted as a UNIX date.
215.It Dv meldate
216A four-byte value in middle-endian (PDP-11) byte order,
217interpreted as a UNIX-style date, but interpreted as local time rather
218than UTC.
219.It Dv indirect
220Starting at the given offset, consult the magic database again.
221The offset of the
222.Dv indirect
223magic is by default absolute in the file, but one can specify
224.Dv /r
225to indicate that the offset is relative from the beginning of the entry.
226.It Dv name
227Define a
228.Dq named
229magic instance that can be called from another
230.Dv use
231magic entry, like a subroutine call.
232Named instance direct magic offsets are relative to the offset of the
233previous matched entry, but indirect offsets are relative to the beginning
234of the file as usual.
235Named magic entries always match.
236.It Dv use
237Recursively call the named magic starting from the current offset.
238If the name of the referenced begins with a
239.Dv ^
240then the endianness of the magic is switched; if the magic mentioned
241.Dv leshort
242for example,
243it is treated as
244.Dv beshort
245and vice versa.
246This is useful to avoid duplicating the rules for different endianness.
247.It Dv regex
248A regular expression match in extended POSIX regular expression syntax
249(like egrep).
250Regular expressions can take exponential time to process, and their
251performance is hard to predict, so their use is discouraged.
252When used in production environments, their performance
253should be carefully checked.
254The size of the string to search should also be limited by specifying
255.Dv /<length> ,
256to avoid performance issues scanning long files.
257The type specification can also be optionally followed by
258.Dv /[c][s][l] .
259The
260.Dq c
261flag makes the match case insensitive, while the
262.Dq s
263flag update the offset to the start offset of the match, rather than the end.
264The
265.Dq l
266modifier, changes the limit of length to mean number of lines instead of a
267byte count.
268Lines are delimited by the platforms native line delimiter.
269When a line count is specified, an implicit byte count also computed assuming
270each line is 80 characters long.
271If neither a byte or line count is specified, the search is limited automatically
272to 8KiB.
273.Dv ^
274and
275.Dv $
276match the beginning and end of individual lines, respectively,
277not beginning and end of file.
278.It Dv search
279A literal string search starting at the given offset.
280The same modifier flags can be used as for string patterns.
281The search expression must contain the range in the form
282.Dv /number,
283that is the number of positions at which the match will be
284attempted, starting from the start offset.
285This is suitable for
286searching larger binary expressions with variable offsets, using
287.Dv \e
288escapes for special characters.
289The order of modifier and number is not relevant.
290.It Dv default
291This is intended to be used with the test
292.Em x
293(which is always true) and it has no type.
294It matches when no other test at that continuation level has matched before.
295Clearing that matched tests for a continuation level, can be done using the
296.Dv clear
297test.
298.It Dv clear
299This test is always true and clears the match flag for that continuation level.
300It is intended to be used with the
301.Dv default
302test.
303.It Dv der
304Parse the file as a DER Certificate file.
305The test field is used as a der type that needs to be matched.
306The DER types are:
307.Dv eoc ,
308.Dv bool ,
309.Dv int ,
310.Dv bit_str ,
311.Dv octet_str ,
312.Dv null ,
313.Dv obj_id ,
314.Dv obj_desc ,
315.Dv ext ,
316.Dv real ,
317.Dv enum ,
318.Dv embed ,
319.Dv utf8_str ,
320.Dv rel_oid ,
321.Dv time ,
322.Dv res2 ,
323.Dv seq ,
324.Dv set ,
325.Dv num_str ,
326.Dv prt_str ,
327.Dv t61_str ,
328.Dv vid_str ,
329.Dv ia5_str ,
330.Dv utc_time ,
331.Dv gen_time ,
332.Dv gr_str ,
333.Dv vis_str ,
334.Dv gen_str ,
335.Dv univ_str ,
336.Dv char_str ,
337.Dv bmp_str ,
338.Dv date ,
339.Dv tod ,
340.Dv datetime ,
341.Dv duration ,
342.Dv oid-iri ,
343.Dv rel-oid-iri .
344These types can be followed by an optional numeric size, which indicates
345the field width in bytes.
346.It Dv guid
347A Globally Unique Identifier, parsed and printed as
348XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
349It's format is a string.
350.It Dv offset
351This is a quad value indicating the current offset of the file.
352It can be used to determine the size of the file or the magic buffer.
353For example the magic entries:
354.Bd -literal -offset indent
355-0	offset	x	this file is %lld bytes
356-0	offset	<=100	must be more than 100 \e
357    bytes and is only %lld
358.Ed
359.El
360.Pp
361For compatibility with the Single
362.Ux
363Standard, the type specifiers
364.Dv dC
365and
366.Dv d1
367are equivalent to
368.Dv byte ,
369the type specifiers
370.Dv uC
371and
372.Dv u1
373are equivalent to
374.Dv ubyte ,
375the type specifiers
376.Dv dS
377and
378.Dv d2
379are equivalent to
380.Dv short ,
381the type specifiers
382.Dv uS
383and
384.Dv u2
385are equivalent to
386.Dv ushort ,
387the type specifiers
388.Dv dI ,
389.Dv dL ,
390and
391.Dv d4
392are equivalent to
393.Dv long ,
394the type specifiers
395.Dv uI ,
396.Dv uL ,
397and
398.Dv u4
399are equivalent to
400.Dv ulong ,
401the type specifier
402.Dv d8
403is equivalent to
404.Dv quad ,
405the type specifier
406.Dv u8
407is equivalent to
408.Dv uquad ,
409and the type specifier
410.Dv s
411is equivalent to
412.Dv string .
413In addition, the type specifier
414.Dv dQ
415is equivalent to
416.Dv quad
417and the type specifier
418.Dv uQ
419is equivalent to
420.Dv uquad .
421.Pp
422Each top-level magic pattern (see below for an explanation of levels)
423is classified as text or binary according to the types used.
424Types
425.Dq regex
426and
427.Dq search
428are classified as text tests, unless non-printable characters are used
429in the pattern.
430All other tests are classified as binary.
431A top-level
432pattern is considered to be a test text when all its patterns are text
433patterns; otherwise, it is considered to be a binary pattern.
434When
435matching a file, binary patterns are tried first; if no match is
436found, and the file looks like text, then its encoding is determined
437and the text patterns are tried.
438.Pp
439The numeric types may optionally be followed by
440.Dv \*[Am]
441and a numeric value,
442to specify that the value is to be AND'ed with the
443numeric value before any comparisons are done.
444Prepending a
445.Dv u
446to the type indicates that ordered comparisons should be unsigned.
447.It Dv test
448The value to be compared with the value from the file.
449If the type is
450numeric, this value
451is specified in C form; if it is a string, it is specified as a C string
452with the usual escapes permitted (e.g. \en for new-line).
453.Pp
454Numeric values
455may be preceded by a character indicating the operation to be performed.
456It may be
457.Dv = ,
458to specify that the value from the file must equal the specified value,
459.Dv \*[Lt] ,
460to specify that the value from the file must be less than the specified
461value,
462.Dv \*[Gt] ,
463to specify that the value from the file must be greater than the specified
464value,
465.Dv \*[Am] ,
466to specify that the value from the file must have set all of the bits
467that are set in the specified value,
468.Dv ^ ,
469to specify that the value from the file must have clear any of the bits
470that are set in the specified value, or
471.Dv ~ ,
472the value specified after is negated before tested.
473.Dv x ,
474to specify that any value will match.
475If the character is omitted, it is assumed to be
476.Dv = .
477Operators
478.Dv \*[Am] ,
479.Dv ^ ,
480and
481.Dv ~
482don't work with floats and doubles.
483The operator
484.Dv !\&
485specifies that the line matches if the test does
486.Em not
487succeed.
488.Pp
489Numeric values are specified in C form; e.g.
490.Dv 13
491is decimal,
492.Dv 013
493is octal, and
494.Dv 0x13
495is hexadecimal.
496.Pp
497Numeric operations are not performed on date types, instead the numeric
498value is interpreted as an offset.
499.Pp
500For string values, the string from the
501file must match the specified string.
502The operators
503.Dv = ,
504.Dv \*[Lt]
505and
506.Dv \*[Gt]
507(but not
508.Dv \*[Am] )
509can be applied to strings.
510The length used for matching is that of the string argument
511in the magic file.
512This means that a line can match any non-empty string (usually used to
513then print the string), with
514.Em \*[Gt]\e0
515(because all non-empty strings are greater than the empty string).
516.Pp
517Dates are treated as numerical values in the respective internal
518representation.
519.Pp
520The special test
521.Em x
522always evaluates to true.
523.It Dv message
524The message to be printed if the comparison succeeds.
525If the string contains a
526.Xr printf 3
527format specification, the value from the file (with any specified masking
528performed) is printed using the message as the format string.
529If the string begins with
530.Dq \eb ,
531the message printed is the remainder of the string with no whitespace
532added before it: multiple matches are normally separated by a single
533space.
534.El
535.Pp
536An APPLE 4+4 character APPLE creator and type can be specified as:
537.Bd -literal -offset indent
538!:apple	CREATYPE
539.Ed
540.Pp
541A MIME type is given on a separate line, which must be the next
542non-blank or comment line after the magic line that identifies the
543file type, and has the following format:
544.Bd -literal -offset indent
545!:mime	MIMETYPE
546.Ed
547.Pp
548i.e. the literal string
549.Dq !:mime
550followed by the MIME type.
551.Pp
552An optional strength can be supplied on a separate line which refers to
553the current magic description using the following format:
554.Bd -literal -offset indent
555!:strength OP VALUE
556.Ed
557.Pp
558The operand
559.Dv OP
560can be:
561.Dv + ,
562.Dv - ,
563.Dv * ,
564or
565.Dv /
566and
567.Dv VALUE
568is a constant between 0 and 255.
569This constant is applied using the specified operand
570to the currently computed default magic strength.
571.Pp
572Some file formats contain additional information which is to be printed
573along with the file type or need additional tests to determine the true
574file type.
575These additional tests are introduced by one or more
576.Em \*[Gt]
577characters preceding the offset.
578The number of
579.Em \*[Gt]
580on the line indicates the level of the test; a line with no
581.Em \*[Gt]
582at the beginning is considered to be at level 0.
583Tests are arranged in a tree-like hierarchy:
584if the test on a line at level
585.Em n
586succeeds, all following tests at level
587.Em n+1
588are performed, and the messages printed if the tests succeed, until a line
589with level
590.Em n
591(or less) appears.
592For more complex files, one can use empty messages to get just the
593"if/then" effect, in the following way:
594.Bd -literal -offset indent
5950      string   MZ
596\*[Gt]0x18  leshort  \*[Lt]0x40   MS-DOS executable
597\*[Gt]0x18  leshort  \*[Gt]0x3f   extended PC executable (e.g., MS Windows)
598.Ed
599.Pp
600Offsets do not need to be constant, but can also be read from the file
601being examined.
602If the first character following the last
603.Em \*[Gt]
604is a
605.Em \&(
606then the string after the parenthesis is interpreted as an indirect offset.
607That means that the number after the parenthesis is used as an offset in
608the file.
609The value at that offset is read, and is used again as an offset
610in the file.
611Indirect offsets are of the form:
612.Em (( x [[.,][bBcCeEfFgGhHiIlmsSqQ]][+\-][ y ]) .
613The value of
614.Em x
615is used as an offset in the file.
616A byte, id3 length, short or long is read at that offset depending on the
617.Em [bBcCeEfFgGhHiIlmsSqQ]
618type specifier.
619The value is treated as signed if
620.Dq ,
621is specified or unsigned if
622.Dq .
623is specified.
624The capitalized types interpret the number as a big endian
625value, whereas the small letter versions interpret the number as a little
626endian value;
627the
628.Em m
629type interprets the number as a middle endian (PDP-11) value.
630To that number the value of
631.Em y
632is added and the result is used as an offset in the file.
633The default type if one is not specified is long.
634The following types are recognized:
635.Bl -column -offset indent "Type" "Half/Short" "Little" "Size"
636.It Sy Type	Sy Mnemonic	Sy Endian	Sy Size
637.It bcBc	Byte/Char	N/A	1
638.It efg	Double	Little	8
639.It EFG	Double	Big	8
640.It hs	Half/Short	Little	2
641.It HS	Half/Short	Big	2
642.It i	ID3	Little	4
643.It I	ID3	Big	4
644.It m	Middle	Middle	4
645.It q	Quad	Little	8
646.It Q	Quad	Big	8
647.El
648.Pp
649That way variable length structures can be examined:
650.Bd -literal -offset indent
651# MS Windows executables are also valid MS-DOS executables
6520           string  MZ
653\*[Gt]0x18       leshort \*[Lt]0x40   MZ executable (MS-DOS)
654# skip the whole block below if it is not an extended executable
655\*[Gt]0x18       leshort \*[Gt]0x3f
656\*[Gt]\*[Gt](0x3c.l)  string  PE\e0\e0  PE executable (MS-Windows)
657\*[Gt]\*[Gt](0x3c.l)  string  LX\e0\e0  LX executable (OS/2)
658.Ed
659.Pp
660This strategy of examining has a drawback: you must make sure that you
661eventually print something, or users may get empty output (such as when
662there is neither PE\e0\e0 nor LE\e0\e0 in the above example).
663.Pp
664If this indirect offset cannot be used directly, simple calculations are
665possible: appending
666.Em [+-*/%\*[Am]|^]number
667inside parentheses allows one to modify
668the value read from the file before it is used as an offset:
669.Bd -literal -offset indent
670# MS Windows executables are also valid MS-DOS executables
6710           string  MZ
672# sometimes, the value at 0x18 is less that 0x40 but there's still an
673# extended executable, simply appended to the file
674\*[Gt]0x18       leshort \*[Lt]0x40
675\*[Gt]\*[Gt](4.s*512) leshort 0x014c  COFF executable (MS-DOS, DJGPP)
676\*[Gt]\*[Gt](4.s*512) leshort !0x014c MZ executable (MS-DOS)
677.Ed
678.Pp
679Sometimes you do not know the exact offset as this depends on the length or
680position (when indirection was used before) of preceding fields.
681You can specify an offset relative to the end of the last up-level
682field using
683.Sq \*[Am]
684as a prefix to the offset:
685.Bd -literal -offset indent
6860           string  MZ
687\*[Gt]0x18       leshort \*[Gt]0x3f
688\*[Gt]\*[Gt](0x3c.l)  string  PE\e0\e0    PE executable (MS-Windows)
689# immediately following the PE signature is the CPU type
690\*[Gt]\*[Gt]\*[Gt]\*[Am]0       leshort 0x14c     for Intel 80386
691\*[Gt]\*[Gt]\*[Gt]\*[Am]0       leshort 0x184     for DEC Alpha
692.Ed
693.Pp
694Indirect and relative offsets can be combined:
695.Bd -literal -offset indent
6960             string  MZ
697\*[Gt]0x18         leshort \*[Lt]0x40
698\*[Gt]\*[Gt](4.s*512)   leshort !0x014c MZ executable (MS-DOS)
699# if it's not COFF, go back 512 bytes and add the offset taken
700# from byte 2/3, which is yet another way of finding the start
701# of the extended executable
702\*[Gt]\*[Gt]\*[Gt]\*[Am](2.s-514) string  LE      LE executable (MS Windows VxD driver)
703.Ed
704.Pp
705Or the other way around:
706.Bd -literal -offset indent
7070                 string  MZ
708\*[Gt]0x18             leshort \*[Gt]0x3f
709\*[Gt]\*[Gt](0x3c.l)        string  LE\e0\e0  LE executable (MS-Windows)
710# at offset 0x80 (-4, since relative offsets start at the end
711# of the up-level match) inside the LE header, we find the absolute
712# offset to the code area, where we look for a specific signature
713\*[Gt]\*[Gt]\*[Gt](\*[Am]0x7c.l+0x26) string  UPX     \eb, UPX compressed
714.Ed
715.Pp
716Or even both!
717.Bd -literal -offset indent
7180                string  MZ
719\*[Gt]0x18            leshort \*[Gt]0x3f
720\*[Gt]\*[Gt](0x3c.l)       string  LE\e0\e0 LE executable (MS-Windows)
721# at offset 0x58 inside the LE header, we find the relative offset
722# to a data area where we look for a specific signature
723\*[Gt]\*[Gt]\*[Gt]\*[Am](\*[Am]0x54.l-3)  string  UNACE  \eb, ACE self-extracting archive
724.Ed
725.Pp
726If you have to deal with offset/length pairs in your file, even the
727second value in a parenthesized expression can be taken from the file itself,
728using another set of parentheses.
729Note that this additional indirect offset is always relative to the
730start of the main indirect offset.
731.Bd -literal -offset indent
7320                 string       MZ
733\*[Gt]0x18             leshort      \*[Gt]0x3f
734\*[Gt]\*[Gt](0x3c.l)        string       PE\e0\e0 PE executable (MS-Windows)
735# search for the PE section called ".idata"...
736\*[Gt]\*[Gt]\*[Gt]\*[Am]0xf4          search/0x140 .idata
737# ...and go to the end of it, calculated from start+length;
738# these are located 14 and 10 bytes after the section name
739\*[Gt]\*[Gt]\*[Gt]\*[Gt](\*[Am]0xe.l+(-4)) string       PK\e3\e4 \eb, ZIP self-extracting archive
740.Ed
741.Pp
742If you have a list of known values at a particular continuation level,
743and you want to provide a switch-like default case:
744.Bd -literal -offset indent
745# clear that continuation level match
746\*[Gt]18	clear
747\*[Gt]18	lelong	1	one
748\*[Gt]18	lelong	2	two
749\*[Gt]18	default	x
750# print default match
751\*[Gt]\*[Gt]18	lelong	x	unmatched 0x%x
752.Ed
753.Sh SEE ALSO
754.Xr file __CSECTION__
755\- the command that reads this file.
756.Sh BUGS
757The formats
758.Dv long ,
759.Dv belong ,
760.Dv lelong ,
761.Dv melong ,
762.Dv short ,
763.Dv beshort ,
764and
765.Dv leshort
766do not depend on the length of the C data types
767.Dv short
768and
769.Dv long
770on the platform, even though the Single
771.Ux
772Specification implies that they do.  However, as OS X Mountain Lion has
773passed the Single
774.Ux
775Specification validation suite, and supplies a version of
776.Xr file __CSECTION__
777in which they do not depend on the sizes of the C data types and that is
778built for a 64-bit environment in which
779.Dv long
780is 8 bytes rather than 4 bytes, presumably the validation suite does not
781test whether, for example
782.Dv long
783refers to an item with the same size as the C data type
784.Dv long .
785There should probably be
786.Dv type
787names
788.Dv int8 ,
789.Dv uint8 ,
790.Dv int16 ,
791.Dv uint16 ,
792.Dv int32 ,
793.Dv uint32 ,
794.Dv int64 ,
795and
796.Dv uint64 ,
797and specified-byte-order variants of them,
798to make it clearer that those types have specified widths.
799.\"
800.\" From: guy@sun.uucp (Guy Harris)
801.\" Newsgroups: net.bugs.usg
802.\" Subject: /etc/magic's format isn't well documented
803.\" Message-ID: <2752@sun.uucp>
804.\" Date: 3 Sep 85 08:19:07 GMT
805.\" Organization: Sun Microsystems, Inc.
806.\" Lines: 136
807.\"
808.\" Here's a manual page for the format accepted by the "file" made by adding
809.\" the changes I posted to the S5R2 version.
810.\"
811.\" Modified for Ian Darwin's version of the file command.
812