merge local changes
This commit is contained in:
parent
b517ab4402
commit
2e90e27c3b
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: file.1,v 1.1.1.1 2003/02/23 23:08:28 pooka Exp $
|
||||
.\" $NetBSD: file.1,v 1.2 2003/02/23 23:42:50 pooka Exp $
|
||||
.\"
|
||||
.TH FILE 1 "Copyright but distributable"
|
||||
.\" Id: file.man,v 1.43 2003/02/08 18:33:53 christos Exp
|
||||
|
@ -182,10 +182,12 @@ Use the specified separator character instead of ``:''.
|
|||
.TP 8
|
||||
.B \-i
|
||||
Causes the file command to output mime type strings rather than the more
|
||||
traditional human readable ones. Thus it may say
|
||||
traditional human readable ones.
|
||||
Thus it may say
|
||||
``text/plain; charset=us-ascii''
|
||||
rather
|
||||
than ``ASCII text''. In order for this option to work, file changes the way
|
||||
than ``ASCII text''.
|
||||
In order for this option to work, file changes the way
|
||||
it handles files recognised by the command itself (such as many of the
|
||||
text file types, directories etc), and makes use of an alternative
|
||||
``magic'' file.
|
||||
|
@ -199,8 +201,10 @@ Specify an alternate list of files containing magic numbers.
|
|||
This can be a single file, or a colon-separated list of files.
|
||||
.TP 8
|
||||
.B \-n
|
||||
Force stdout to be flushed after checking each file. This is only useful if
|
||||
checking a list of files. It is intended to be used by programs that want
|
||||
Force stdout to be flushed after checking each file.
|
||||
This is only useful if
|
||||
checking a list of files.
|
||||
It is intended to be used by programs that want
|
||||
filetype output from a pipe.
|
||||
.TP 8
|
||||
.B \-N
|
||||
|
@ -279,7 +283,8 @@ in an existing magic file would have to be changed to
|
|||
\*[Gt]10 string language\e impress (imPRESS data)
|
||||
.br
|
||||
In addition, in this version, if a pattern string contains a backslash,
|
||||
it must be escaped. For example
|
||||
it must be escaped.
|
||||
For example
|
||||
.br
|
||||
0 string \ebegindata Andrew Toolkit document
|
||||
.br
|
||||
|
@ -315,36 +320,40 @@ keep the old magic file around for comparison purposes
|
|||
.IR /usr/share/misc/magic.orig ).
|
||||
.SH EXAMPLES
|
||||
.nf
|
||||
$ file file.c file /dev/{wd0a,hda}
|
||||
file.c: C program text
|
||||
file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
|
||||
dynamically linked (uses shared libs), stripped
|
||||
/dev/wd0a: block special (0/0)
|
||||
/dev/hda: block special (3/0)
|
||||
$ file -s /dev/wd0{b,d}
|
||||
/dev/wd0b: data
|
||||
/dev/wd0d: x86 boot sector
|
||||
$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
|
||||
/dev/hda: x86 boot sector
|
||||
/dev/hda1: Linux/i386 ext2 filesystem
|
||||
/dev/hda2: x86 boot sector
|
||||
/dev/hda3: x86 boot sector, extended partition table
|
||||
/dev/hda4: Linux/i386 ext2 filesystem
|
||||
/dev/hda5: Linux/i386 swap file
|
||||
/dev/hda6: Linux/i386 swap file
|
||||
/dev/hda7: Linux/i386 swap file
|
||||
/dev/hda8: Linux/i386 swap file
|
||||
/dev/hda9: empty
|
||||
/dev/hda10: empty
|
||||
|
||||
$ file -i file.c file /dev/{wd0a,hda}
|
||||
file.c: text/x-c
|
||||
file: application/x-executable, dynamically linked (uses shared libs),
|
||||
not stripped
|
||||
/dev/hda: application/x-not-regular-file
|
||||
/dev/wd0a: application/x-not-regular-file
|
||||
|
||||
$ file file.c obj/file /dev/wd0a
|
||||
file.c: ASCII C program text
|
||||
.fi
|
||||
.na
|
||||
obj/file: ELF 32-bit LSB executable,
|
||||
Intel 80386,
|
||||
version 1 (SYSV),
|
||||
for NetBSD,
|
||||
dynamically linked (uses shared libs),
|
||||
not stripped
|
||||
.br
|
||||
.nf
|
||||
/dev/wd0a: block special (0/0)
|
||||
|
||||
# file -s /dev/rwd0[abe]
|
||||
/dev/rwd0a: x86 boot sector, BSD disklabel
|
||||
/dev/rwd0b: data
|
||||
.fi
|
||||
.na
|
||||
/dev/rwd0e:
|
||||
Unix Fast File system (little-endian),
|
||||
last mounted on /usr,
|
||||
last written at Mon Feb 10 13:22:40 2003,
|
||||
clean flag 2,
|
||||
number of blocks 28754208,
|
||||
number of data blocks 27812712,
|
||||
number of cylinder groups 3566,
|
||||
block size 8192,
|
||||
fragment size 1024,
|
||||
minimum percentage of free blocks 5,
|
||||
rotational delay 0ms,
|
||||
disk rotational speed 60rps,
|
||||
TIME optimization
|
||||
.ad
|
||||
.SH HISTORY
|
||||
There has been a
|
||||
.B file
|
||||
|
@ -379,7 +388,8 @@ of non-ASCII files.
|
|||
.PP
|
||||
The list of contributors to the "Magdir" directory (source for the
|
||||
/etc/magic
|
||||
file) is too long to include here. You know who you are; thank you.
|
||||
file) is too long to include here.
|
||||
You know who you are; thank you.
|
||||
.SH LEGAL NOTICE
|
||||
Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999.
|
||||
Covered by the standard Berkeley Software Distribution copyright; see the file
|
||||
|
@ -394,7 +404,8 @@ were written by John Gilmore from his public-domain
|
|||
program, and are not covered by the above license.
|
||||
.SH BUGS
|
||||
There must be a better way to automate the construction of the Magic
|
||||
file from all the glop in Magdir. What is it?
|
||||
file from all the glop in Magdir.
|
||||
What is it?
|
||||
Better yet, the magic file should be compiled into binary (say,
|
||||
.BR ndbm (3)
|
||||
or, better yet, fixed-length
|
||||
|
@ -441,7 +452,8 @@ This could be done by using some keyword like `*' for the offset value.
|
|||
Another optimisation would be to sort
|
||||
the magic file so that we can just run down all the
|
||||
tests for the first byte, first word, first long, etc, once we
|
||||
have fetched it. Complain about conflicts in the magic file entries.
|
||||
have fetched it.
|
||||
Complain about conflicts in the magic file entries.
|
||||
Make a rule that the magic entries sort based on file offset rather
|
||||
than position within the magic file?
|
||||
.PP
|
||||
|
@ -449,7 +461,8 @@ The program should provide a way to give an estimate
|
|||
of ``how good'' a guess is.
|
||||
We end up removing guesses (e.g. ``From '' as first 5 chars of file) because
|
||||
they are not as good as other guesses (e.g. ``Newsgroups:'' versus
|
||||
``Return-Path:''). Still, if the others don't pan out, it should be
|
||||
``Return-Path:'').
|
||||
Still, if the others don't pan out, it should be
|
||||
possible to use the first guess.
|
||||
.PP
|
||||
This program is slower than some vendors' file commands.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: magic.5,v 1.1.1.1 2003/02/23 23:08:28 pooka Exp $
|
||||
.\" $NetBSD: magic.5,v 1.2 2003/02/23 23:42:50 pooka Exp $
|
||||
.\"
|
||||
.TH MAGIC 5 "Public Domain"
|
||||
.\" install as magic.4 on USG, magic.5 on V7 or Berkeley systems.
|
||||
|
@ -8,7 +8,8 @@ magic \- file command's magic number file
|
|||
This manual page documents the format of the magic file as
|
||||
used by the
|
||||
.BR file (1)
|
||||
command, version 3.40. The
|
||||
command, version 3.40.
|
||||
The
|
||||
.BR file
|
||||
command identifies the type of a file using,
|
||||
among other tests,
|
||||
|
@ -23,13 +24,15 @@ and additional information to extract from the file.
|
|||
Each line of the file specifies a test to be performed.
|
||||
A test compares the data starting at a particular offset
|
||||
in the file with a 1-byte, 2-byte, or 4-byte numeric value or
|
||||
a string. If the test succeeds, a message is printed.
|
||||
a string.
|
||||
If the test succeeds, a message is printed.
|
||||
The line consists of the following fields:
|
||||
.IP offset \w'message'u+2n
|
||||
A number specifying the offset, in bytes, into the file of the data
|
||||
which is to be tested.
|
||||
.IP type
|
||||
The type of the data to be tested. The possible values are:
|
||||
The type of the data to be tested.
|
||||
The possible values are:
|
||||
.RS
|
||||
.IP byte \w'message'u+2n
|
||||
A one-byte value.
|
||||
|
@ -38,11 +41,16 @@ A two-byte value (on most systems) in this machine's native byte order.
|
|||
.IP long
|
||||
A four-byte value (on most systems) in this machine's native byte order.
|
||||
.IP string
|
||||
A string of bytes. The string type specification can be optionally followed
|
||||
by /[Bbc]*. The ``B'' flag compacts whitespace in the target, which must
|
||||
contain at least one whitespace character. If the magic has "n" consecutive
|
||||
blanks, the target needs at least "n" consecutive blanks to match. The ``b''
|
||||
flag treats every blank in the target as an optional blank. Finally the ``c''
|
||||
A string of bytes.
|
||||
The string type specification can be optionally followed
|
||||
by /[Bbc]*.
|
||||
The ``B'' flag compacts whitespace in the target, which must
|
||||
contain at least one whitespace character.
|
||||
If the magic has "n" consecutive
|
||||
blanks, the target needs at least "n" consecutive blanks to match.
|
||||
The ``b''
|
||||
flag treats every blank in the target as an optional blank.
|
||||
Finally the ``c''
|
||||
flag, specifies case insensitive matching: lowercase characters in the magic
|
||||
match both lower and upper case characters in the targer, whereas upper case
|
||||
characters in the magic, only much uppercase characters in the target.
|
||||
|
@ -75,11 +83,13 @@ The numeric types may optionally be followed by
|
|||
.B \*[Am]
|
||||
and a numeric value,
|
||||
to specify that the value is to be AND'ed with the
|
||||
numeric value before any comparisons are done. Prepending a
|
||||
numeric value before any comparisons are done.
|
||||
Prepending a
|
||||
.B u
|
||||
to the type indicates that ordered comparisons should be unsigned.
|
||||
.IP test
|
||||
The value to be compared with the value from the file. If the type is
|
||||
The value to be compared with the value from the file.
|
||||
If the type is
|
||||
numeric, this value
|
||||
is specified in C form; if it is a string, it is specified as a C string
|
||||
with the usual escapes permitted (e.g. \en for new-line).
|
||||
|
@ -102,7 +112,8 @@ that are set in the specified value,
|
|||
to specify that the value from the file must have clear any of the bits
|
||||
that are set in the specified value, or
|
||||
.BR x ,
|
||||
to specify that any value will match. If the character is omitted,
|
||||
to specify that any value will match.
|
||||
If the character is omitted,
|
||||
it is assumed to be
|
||||
.BR = .
|
||||
.IP
|
||||
|
@ -125,21 +136,25 @@ and
|
|||
.BR \*[Am] )
|
||||
can be applied to strings.
|
||||
The length used for matching is that of the string argument
|
||||
in the magic file. This means that a line can match any string, and
|
||||
in the magic file.
|
||||
This means that a line can match any string, and
|
||||
then presumably print that string, by doing
|
||||
.B \*[Gt]\e0
|
||||
(because all strings are greater than the null string).
|
||||
.IP message
|
||||
The message to be printed if the comparison succeeds. If the string
|
||||
The message to be printed if the comparison succeeds.
|
||||
If the string
|
||||
contains a
|
||||
.BR printf (3)
|
||||
format specification, the value from the file (with any specified masking
|
||||
performed) is printed using the message as the format string.
|
||||
.PP
|
||||
Some file formats contain additional information which is to be printed
|
||||
along with the file type. A line which begins with the character
|
||||
along with the file type.
|
||||
A line which begins with the character
|
||||
.B \*[Gt]
|
||||
indicates additional tests and messages to be printed. The number of
|
||||
indicates additional tests and messages to be printed.
|
||||
The number of
|
||||
.B \*[Gt]
|
||||
on the line indicates the level of the test; a line with no
|
||||
.B \*[Gt]
|
||||
|
@ -153,7 +168,8 @@ If the test on a line at level
|
|||
.I n
|
||||
succeeds, the tests specified in all the subsequent lines at level
|
||||
.IB n \(pl1
|
||||
are performed, and the messages printed if the tests succeed. The next
|
||||
are performed, and the messages printed if the tests succeed.
|
||||
The next
|
||||
line at level
|
||||
.I n
|
||||
terminates this.
|
||||
|
@ -163,27 +179,35 @@ is a
|
|||
.B (
|
||||
then the string after the parenthesis is interpreted as an indirect offset.
|
||||
That means that the number after the parenthesis is used as an offset in
|
||||
the file. The value at that offset is read, and is used again as an offset
|
||||
in the file. Indirect offsets are of the form:
|
||||
the file.
|
||||
The value at that offset is read, and is used again as an offset
|
||||
in the file.
|
||||
Indirect offsets are of the form:
|
||||
.BI (( x [.[bslBSL]][+-][ y ]).
|
||||
The value of
|
||||
.I x
|
||||
is used as an offset in the file. A byte, short or long is read at that offset
|
||||
is used as an offset in the file.
|
||||
A byte, short or long is read at that offset
|
||||
depending on the
|
||||
.B [bslBSL]
|
||||
type specifier. The capitalized types interpret the number as a big endian
|
||||
type specifier.
|
||||
The capitalized types interpret the number as a big endian
|
||||
value, whereas the small letter versions interpret the number as a little
|
||||
endian value. To that number the value of
|
||||
endian value.
|
||||
To that number the value of
|
||||
.I y
|
||||
is added and the result is used as an offset in the file. The default type
|
||||
is added and the result is used as an offset in the file.
|
||||
The default type
|
||||
if one is not specified is long.
|
||||
.PP
|
||||
Sometimes you do not know the exact offset as this depends on the length of
|
||||
preceding fields. You can specify an offset relative to the end of the
|
||||
preceding fields.
|
||||
You can specify an offset relative to the end of the
|
||||
last uplevel field (of course this may only be done for sublevel tests, i.e.
|
||||
test beginning with
|
||||
.B \*[Gt]
|
||||
). Such a relative offset is specified using
|
||||
).
|
||||
Such a relative offset is specified using
|
||||
.B \*[Am]
|
||||
as a prefix to the offset.
|
||||
.SH BUGS
|
||||
|
|
Loading…
Reference in New Issue