Magdir/gnu \
Magdir/grace \
Magdir/gringotts \
+Magdir/hdf \
Magdir/hitachi-sh \
Magdir/hp \
Magdir/ibm370 \
Magdir/sniffer \
Magdir/softquad \
Magdir/spectrum \
+Magdir/sql \
Magdir/sun \
Magdir/sysex \
Magdir/teapot \
Magdir/gnu \
Magdir/grace \
Magdir/gringotts \
+Magdir/hdf \
Magdir/hitachi-sh \
Magdir/hp \
Magdir/ibm370 \
Magdir/sniffer \
Magdir/softquad \
Magdir/spectrum \
+Magdir/sql \
Magdir/sun \
Magdir/sysex \
Magdir/teapot \
** README for file(1) Command **
-@(#) $Id: README,v 1.28 2003/02/08 18:35:36 christos Exp $
+@(#) $Id: README,v 1.29 2003/02/27 20:47:46 christos Exp $
This is Release 3.x of Ian Darwin's (copyright but distributable)
file(1) command. This version is the standard "file" command for Linux,
From: Kees Zeelenberg
-An MS-Windows (Win32) port of File-3.40 is available from
+An MS-Windows (Win32) port of File-3.41 is available from
http://gnuwin32.sourceforge.net/
File is an implementation of the Unix File(1) command.
It knows the 'magic number' of several thousands of file types.
PACKAGE=file
-VERSION=3.39
+VERSION=3.41
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
dnl Process this file with autoconf to produce a configure script.
AC_INIT(file.c)
-AM_INIT_AUTOMAKE(file, 3.39)
+AM_INIT_AUTOMAKE(file, 3.41)
AM_CONFIG_HEADER(config.h)
AC_MSG_CHECKING(for builtin ELF support)
.TH FILE __CSECTION__ "Copyright but distributable"
-.\" $Id: file.man,v 1.43 2003/02/08 18:33:53 christos Exp $
+.\" $Id: file.man,v 1.44 2003/02/27 20:47:46 christos Exp $
.SH NAME
file
\- determine file type
.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.
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
-filetype output from a pipe.
+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
Don't pad output to align filenames nicely.
$ 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}
+$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10} # Linux
/dev/hda: x86 boot sector
/dev/hda1: Linux/i386 ext2 filesystem
/dev/hda2: x86 boot sector
/dev/hda9: empty
/dev/hda10: empty
+$ file -s /dev/rwd0e # BSD
+/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
+
$ file -i file.c file /dev/{wd0a,hda}
file.c: text/x-c
file: application/x-executable, dynamically linked (uses shared libs),
.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
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
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
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.
on
.B ftp.astron.com
in the directory
-.I /pub/file/file-X.YY.tar.gz
+.I /pub/file/file-X.YZ.tar.gz
This manual page documents the format of the magic file as
used by the
.BR file (__CSECTION__)
-command, version __VERSION__. The
+command, version __VERSION__.
+The
.BR file
command identifies the type of a file using,
among other tests,
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.
.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.
.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
-numeric, this value
+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).
.IP
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,
-it is assumed to be
+to specify that any value will match.
+If the character is omitted, it is assumed to be
.BR = .
.IP
Numeric values are specified in C form; e.g.
.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
-contains a
+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]
.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
-line at level
+are performed, and the messages printed if the tests succeed.
+The next line at level
.I n
terminates this.
If the first character following the last
.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
-depending on the
+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
-if one is not specified is long.
+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
.\" the changes I posted to the S5R2 version.
.\"
.\" Modified for Ian Darwin's version of the file command.
-.\" @(#)$Id: magic.man,v 1.20 2003/02/08 18:33:53 christos Exp $
+.\" @(#)$Id: magic.man,v 1.21 2003/02/27 20:47:46 christos Exp $
>>18 leshort 53 Motorola M68HC12,
>>18 leshort 62 AMD x86-64,
>>18 leshort 75 Digital VAX,
+>>18 leshort 97 NatSemi 32k,
>>18 leshort 0x9026 Alpha (unofficial),
>>20 lelong 0 invalid version
>>20 lelong 1 version 1
>>18 beshort 53 Motorola M68HC12,
>>18 beshort 73 Cray NV1,
>>18 beshort 75 Digital VAX,
+>>18 beshort 97 NatSemi 32k,
>>18 beshort 0x9026 Alpha (unofficial),
>>20 belong 0 invalid version
>>20 belong 1 version 1
>8320 lelong 1 SPACE optimization
9564 belong 0x00011954 Unix Fast File system (big-endian),
+>7168 long 0x4c41424c Apple UFS Volume
+>>7186 string x named %s,
+>>7176 belong x volume label version %d,
+>>7180 bedate x created on %s,
>8404 string x last mounted on %s,
#>9504 bedate x last checked at %s,
>8224 bedate x last written at %s,
--- /dev/null
+
+#------------------------------------------------------------------------------
+# Hierarchical Data Format, used to facilitate scientific data exchange
+# specifications at http://hdf.ncsa.uiuc.edu/
+
+0 belong 0x0e031301 Hierarchical Data Format (version 4) data
+0 string \211HDF\r\n\032 Hierarchical Data Format (version 5) data
# HSI is Handmade Software's proprietary JPEG encoding scheme
0 string hsi1 JPEG image data, HSI proprietary
+
+# From: David Santinoli <david@santinoli.com>
+0 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000 image data
0 string Seg StuffIt Deluxe Segment (data)
>2 string x : %s
+# Newer StuffIt archives (grant@netbsd.org)
+0 string StuffIt StuffIt Archive
+>162 string >0 : %s
+
# Macintosh Applications and Installation binaries (franklsm@tuns.ca)
0 string APPL Macintosh Application (data)
>2 string x \b: %s
--- /dev/null
+
+#------------------------------------------------------------------------------
+# sql: file(1) magic for SQL files
+#
+# From: "Marty Leisner" <mleisner@eng.mc.xerox.com>
+# Recognize some MySQL files.
+#
+0 beshort 0xfe01 MySQL table definition file
+>2 byte x Version %d
+0 belong&0xffffff00 0xfefe0300 MySQL MISAM index file
+>3 byte x Version %d
+0 belong&0xffffff00 0xfefe0700 MySQL MISAM compressed data file
+>3 byte x Version %d
+0 belong&0xffffff00 0xfefe0500 MySQL ISAM index file
+>3 byte x Version %d
+0 belong&0xffffff00 0xfefe0600 MySQL ISAM compressed data file
+>3 byte x Version %d
+0 string \376bin MySQL replication log
# Microsoft WAVE format (*.wav)
# [GRR 950115: probably all of the shorts and longs should be leshort/lelong]
# Microsoft RIFF
-0 string RIFF audio/unknown
+0 string RIFF
# - WAVE format
->8 string WAVE audio/x-wav
+>8 string WAVE audio/x-wav
>8 string AVI video/x-msvideo
#
0 belong 0x2e7261fd application/x-realaudio
# MNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
0 string \x8aMNG video/x-mng
+
+#------------------------------------------------------------------------------
+# Hierarchical Data Format, used to facilitate scientific data exchange
+# specifications at http://hdf.ncsa.uiuc.edu/
+0 belong 0x0e031301 Hierarchical Data Format (version 4) data
+0 string \211HDF\r\n\032 Hierarchical Data Format (version 5) data
# Makefile for file(1) cmd.
# Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
-# @(#)$Id: Makefile.std,v 1.16 2003/02/08 18:35:36 christos Exp $
+# @(#)$Id: Makefile.std,v 1.17 2003/02/27 20:47:45 christos Exp $
#
# This software is not subject to any license of the American Telephone
# and Telegraph Company or of the Regents of the University of California.
#
# 4. This notice may not be removed or altered.
#
-VERSION = 3.40
+VERSION = 3.41
SHELL = /bin/sh
#MAGIC = /etc/magic
MAGIC = /usr/local/etc/magic
#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.49 2002/07/03 19:00:41 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.50 2003/02/27 20:47:46 christos Exp $")
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
}
maxmagic = MAXMAGIS;
- *magicp = (struct magic *) calloc(sizeof(struct magic), maxmagic);
+ *magicp = (struct magic *) calloc(maxmagic, sizeof(struct magic));
if (*magicp == NULL) {
(void) fprintf(stderr, "%s: Out of memory (%s).\n", progname,
strerror(errno));
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: file.c,v 1.68 2003/02/08 18:33:53 christos Exp $")
+FILE_RCSID("@(#)$Id: file.c,v 1.69 2003/02/27 20:47:46 christos Exp $")
#endif /* lint */
if ((fd = open(inname, O_RDONLY)) < 0) {
/* We can't open it, but we were able to stat it. */
- if (sb.st_mode & 0002) ckfputs("writeable, ", stdout);
+ if (sb.st_mode & 0002) ckfputs("writable, ", stdout);
if (sb.st_mode & 0111) ckfputs("executable, ", stdout);
ckfprintf(stdout, "can't read `%s' (%s).\n",
inname, strerror(errno));