Resolve corn flakes.

This commit is contained in:
christos 1999-11-01 17:39:26 +00:00
parent 39cf80bb8c
commit 7d48644528
35 changed files with 900 additions and 479 deletions

View File

@ -1,7 +1,8 @@
$NetBSD: LEGAL.NOTICE,v 1.7 1998/09/24 12:50:27 christos Exp $
$NetBSD: LEGAL.NOTICE,v 1.8 1999/11/01 17:39:26 christos Exp $
Id: LEGAL.NOTICE,v 1.11 1999/01/14 16:30:12 christos Exp
Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995.
Software written by Ian F. Darwin and others;
maintained 1994-1995 Christos Zoulas.
maintained 1994-1999 Christos Zoulas.
This software is not subject to any export provision of the United States
Department of Commerce, and may be exported to any country or planet.
@ -32,4 +33,3 @@ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.21 1999/02/16 12:32:52 he Exp $
# $NetBSD: Makefile,v 1.22 1999/11/01 17:39:26 christos Exp $
.include <bsd.own.mk>
@ -13,7 +13,7 @@ FILES= ${MFILES}
PROG= file
SRCS= file.c apprentice.c fsmagic.c softmagic.c ascmagic.c is_tar.c \
print.c compress.c readelf.c internat.c
CPPFLAGS+= -DMAGIC='"$(MAGIC)"' -DHAVE_SYS_WAIT_H -DHAVE_ST_RDEV
CPPFLAGS+= -DMAGIC='"$(MAGIC)"' -DHAVE_CONFIG_H -I${.CURDIR}
CPPFLAGS+= -DBUILTIN_ELF -DELFCORE
MAN= file.1 magic.5

View File

@ -1,4 +1,4 @@
/* $NetBSD: apprentice.c,v 1.16 1999/09/04 19:51:11 mycroft Exp $ */
/* $NetBSD: apprentice.c,v 1.17 1999/11/01 17:39:26 christos Exp $ */
/*
* apprentice - make one pass through /etc/magic, learning its secrets.
@ -39,7 +39,7 @@
#if 0
FILE_RCSID("@(#)Id: apprentice.c,v 1.28 1998/09/12 13:17:52 christos Exp ")
#else
__RCSID("$NetBSD: apprentice.c,v 1.16 1999/09/04 19:51:11 mycroft Exp $");
__RCSID("$NetBSD: apprentice.c,v 1.17 1999/11/01 17:39:26 christos Exp $");
#endif
#endif /* lint */
@ -297,7 +297,10 @@ int *ndx, check;
}
/* get type, skip it */
if (strncmp(l, "byte", NBYTE)==0) {
if (strncmp(l, "char", NBYTE)==0) { /* HP/UX compat */
m->type = BYTE;
l += NBYTE;
} else if (strncmp(l, "byte", NBYTE)==0) {
m->type = BYTE;
l += NBYTE;
} else if (strncmp(l, "short", NSHORT)==0) {
@ -352,6 +355,10 @@ int *ndx, check;
case '=':
m->reln = *l;
++l;
if (*l == '=') {
/* HP compat: ignore &= etc. */
++l;
}
break;
case '!':
if (m->type != STRING) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ascmagic.c,v 1.12 1998/09/20 15:27:15 christos Exp $ */
/* $NetBSD: ascmagic.c,v 1.13 1999/11/01 17:39:26 christos Exp $ */
/*
* ASCII magic -- file types that we know based on keywords
@ -28,13 +28,15 @@
* 4. This notice may not be removed or altered.
*/
#include "file.h"
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <ctype.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include "file.h"
#endif
#include "names.h"
#include <sys/cdefs.h>
@ -42,7 +44,7 @@
#if 0
FILE_RCSID("@(#)Id: ascmagic.c,v 1.23 1998/06/27 13:23:39 christos Exp ");
#else
__RCSID("$NetBSD: ascmagic.c,v 1.12 1998/09/20 15:27:15 christos Exp $");
__RCSID("$NetBSD: ascmagic.c,v 1.13 1999/11/01 17:39:26 christos Exp $");
#endif
#endif /* lint */

View File

@ -1,4 +1,4 @@
/* $NetBSD: compress.c,v 1.6 1998/09/20 15:27:15 christos Exp $ */
/* $NetBSD: compress.c,v 1.7 1999/11/01 17:39:26 christos Exp $ */
/*
* compress routines:
@ -7,23 +7,25 @@
* uncompress(method, old, n, newch) - uncompress old into new,
* using method, return sizeof new
*/
#include "file.h"
#ifdef __CYGWIN__
#include <errno.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#include "file.h"
#include <sys/cdefs.h>
#ifndef lint
#if 0
FILE_RCSID("@(#)Id: compress.c,v 1.12 1998/06/27 13:57:23 christos Exp ")
FILE_RCSID("@(#)Id: compress.c,v 1.14 1999/10/31 22:23:03 christos Exp ")
#else
__RCSID("$NetBSD: compress.c,v 1.6 1998/09/20 15:27:15 christos Exp $");
__RCSID("$NetBSD: compress.c,v 1.7 1999/11/01 17:39:26 christos Exp $");
#endif
#endif

View File

@ -1,14 +1,14 @@
.\" $NetBSD: file.1,v 1.14 1998/09/20 15:27:16 christos Exp $
.\" $NetBSD: file.1,v 1.15 1999/11/01 17:39:26 christos Exp $
.\"
.TH FILE 1 "Copyright but distributable"
.\" Id: file.man,v 1.31 1998/02/15 23:18:53 christos Exp
.TH FILE __CSECTION__ "Copyright but distributable"
.\" Id: file.man,v 1.33 1999/02/14 17:16:07 christos Exp
.SH NAME
file
\- determine file type
.SH SYNOPSIS
.B file
[
.B \-vbczL
.B \-bcnsvzL
]
[
.B \-f
@ -107,16 +107,6 @@ archives) and determine whether an unknown file should be
labelled as `ascii text' or `data'.
.SH OPTIONS
.TP 8
.B \-v
Print the version of the program and exit.
.TP 8
.B \-m list
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 \-z
Try to look inside compressed files.
.TP 8
.B \-b
Do not prepend filenames to output lines (brief mode).
.TP 8
@ -136,10 +126,46 @@ Either
or at least one filename argument must be present;
to test the standard input, use ``-'' as a filename argument.
.TP 8
.B \-m list
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 check a file. This is only useful if
checking a list of files. It is intended to be used by programs want
filetype output from a pipe.
.TP 8
.B \-v
Print the version of the program and exit.
.TP 8
.B \-z
Try to look inside compressed files.
.TP 8
.B \-L
option causes symlinks to be followed, as the like-named option in
.BR ls (1).
(on systems that support symbolic links).
.TP 8
.B \-s
Normally,
.B file
only attempts to read and determine the type of argument files which
.BR stat (2)
reports are ordinary files.
This prevents problems, because reading special files may have peculiar
consequences.
Specifying the
.BR \-s
option causes
.B file
to also read argument files which are block or character special files.
This is useful for determining the filesystem types of the data in raw
disk partitions, which are block special files.
This option also causes
.B file
to disregard the file size as reported by
.BR stat (2)
since on some systems it reports a zero size for raw disk partitions.
.SH FILES
.I /usr/share/misc/magic
\- default list of magic numbers
@ -208,6 +234,27 @@ command uses a magic file,
keep the old magic file around for comparison purposes
(rename it to
.IR /usr/share/misc/magic.orig ).
.SH EXAMPLES
.nf
$ file file.c file /dev/hda
file.c: C program text
file: ELF 32-bit LSB executable, Intel 80386, version 1,
dynamically linked, not stripped
/dev/hda: block special
$ 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
.fi
.SH HISTORY
There has been a
.B file
@ -253,7 +300,7 @@ the process running
.RE
.PP
Changes by Ian Darwin and various authors including
Christos Zoulas (christos@astron.com), 1990-1997.
Christos Zoulas (christos@astron.com), 1990-1999.
.SH LEGAL NOTICE
Copyright (c) Ian F. Darwin, Toronto, Canada,
1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993.

View File

@ -1,4 +1,4 @@
/* $NetBSD: file.c,v 1.14 1998/09/20 15:27:16 christos Exp $ */
/* $NetBSD: file.c,v 1.15 1999/11/01 17:39:26 christos Exp $ */
/*
* file - find type of a file or files - main program.
@ -26,7 +26,10 @@
*
* 4. This notice may not be removed or altered.
*/
#include "file.h"
#ifdef __CYGWIN__
#include <errno.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -45,38 +48,44 @@
# endif
# endif
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* for read() */
#endif
#include <netinet/in.h> /* for byte swapping */
#include "patchlevel.h"
#include "file.h"
#ifndef lint
#if 0
FILE_RCSID("@(#)Id: file.c,v 1.42 1998/09/12 13:17:52 christos Exp ")
#else
__RCSID("$NetBSD: file.c,v 1.14 1998/09/20 15:27:16 christos Exp $");
__RCSID("$NetBSD: file.c,v 1.15 1999/11/01 17:39:26 christos Exp $");
#endif
#endif /* lint */
#ifdef S_IFLNK
# define USAGE "Usage: %s [-vbczL] [-f namefile] [-m magicfiles] file...\n"
# define USAGE "Usage: %s [-bcnvzL] [-f namefile] [-m magicfiles] file...\n"
#else
# define USAGE "Usage: %s [-vbcz] [-f namefile] [-m magicfiles] file...\n"
# define USAGE "Usage: %s [-bcnvz] [-f namefile] [-m magicfiles] file...\n"
#endif
#ifndef MAGIC
# define MAGIC "/etc/magic"
#endif
#ifndef MAXPATHLEN
#define MAXPATHLEN 512
#endif
int /* Global command-line options */
debug = 0, /* debugging */
lflag = 0, /* follow Symlinks (BSD only) */
bflag = 0, /* brief output format */
zflag = 0; /* follow (uncompress) compressed files */
zflag = 0, /* follow (uncompress) compressed files */
sflag = 0, /* read block special files */
nobuffer = 0; /* Do not buffer stdout */
int /* Misc globals */
nmagic = 0; /* number of valid magic[]s */
@ -115,11 +124,13 @@ main(argc, argv)
if (!(magicfile = getenv("MAGIC")))
magicfile = MAGIC;
while ((c = getopt(argc, argv, "vbcdf:Lm:z")) != EOF)
while ((c = getopt(argc, argv, "bcdnf:m:svzL")) != EOF)
switch (c) {
case 'v':
(void) fprintf(stdout, "%s-%d.%d\n", progname,
FILE_VERSION_MAJOR, patchlevel);
(void) fprintf(stdout, "magic file from %s\n",
magicfile);
return 1;
case 'b':
++bflag;
@ -127,6 +138,9 @@ main(argc, argv)
case 'c':
++check;
break;
case 'n':
++nobuffer;
break;
case 'd':
++debug;
break;
@ -151,6 +165,9 @@ main(argc, argv)
case 'z':
zflag++;
break;
case 's':
sflag++;
break;
case '?':
default:
errflg++;
@ -222,6 +239,8 @@ char *fn;
while (fgets(buf, MAXPATHLEN, f) != NULL) {
buf[strlen(buf)-1] = '\0';
process(buf, wid);
if(nobuffer)
(void) fflush(stdout);
}
(void) fclose(f);

View File

@ -1,8 +1,8 @@
/* $NetBSD: file.h,v 1.14 1999/09/04 19:51:58 mycroft Exp $ */
/* $NetBSD: file.h,v 1.15 1999/11/01 17:39:26 christos Exp $ */
/*
* file.h - definitions for file(1) program
* @(#)Id: file.h,v 1.27 1998/06/27 13:57:23 christos Exp
* @(#)Id: file.h,v 1.29 1999/02/14 17:16:06 christos Exp
*
* Copyright (c) Ian F. Darwin, 1987.
* Written by Ian F. Darwin.
@ -31,11 +31,15 @@
#ifndef __file_h__
#define __file_h__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
typedef int int32;
typedef unsigned int uint32;
#ifndef HOWMANY
# define HOWMANY 8192 /* how much of the file to look at */
# define HOWMANY 16384 /* how much of the file to look at */
#endif
#define MAXMAGIS 2048 /* max entries in /etc/magic */
#define MAXDESC 50 /* max leng of text description */
@ -48,7 +52,7 @@ struct magic {
#define ADD 4 /* if '>&' appears, */
short cont_level; /* level of ">" */
struct {
unsigned char type; /* byte short long */
unsigned char type; /* byte short long */
int32 offset; /* offset from indirection */
} in;
int32 offset; /* offset to magic number */
@ -82,7 +86,7 @@ struct magic {
#include <stdio.h> /* Include that here, to make sure __P gets defined */
#ifndef __P
# if __STDC__ || __cplusplus
# if defined(__STDC__) || defined(__cplusplus)
# define __P(a) a
# else
# define __P(a) ()
@ -108,7 +112,7 @@ extern int zmagic __P((unsigned char *, int));
extern void ckfprintf __P((FILE *, const char *, ...));
extern uint32 signextend __P((struct magic *, unsigned int32));
extern int internatmagic __P((unsigned char *, int));
extern void tryelf __P((int, char *, int));
extern void tryelf __P((int, unsigned char *, int));
extern int errno; /* Some unixes don't define this.. */
@ -124,29 +128,20 @@ extern int nmagic; /* number of valid magic[]s */
extern int debug; /* enable debugging? */
extern int zflag; /* process compressed files? */
extern int lflag; /* follow symbolic links? */
extern int sflag; /* read/analyze block special files? */
extern int optind; /* From getopt(3) */
extern char *optarg;
#if defined(sun) || defined(__sun__) || defined (__sun)
# if defined(__svr4) || defined (__SVR4) || defined(__svr4__)
# define SOLARIS
# else
# define SUNOS
# endif
#endif
#if !defined(__STDC__) || defined(SUNOS) || defined(__convex__)
#ifndef HAVE_STRERROR
extern int sys_nerr;
extern char *sys_errlist[];
#define strerror(e) \
(((e) >= 0 && (e) < sys_nerr) ? sys_errlist[(e)] : "Unknown error")
#define strtoul(a, b, c) strtol(a, b, c)
#endif
#ifndef MAXPATHLEN
#define MAXPATHLEN 512
#ifndef HAVE_STRTOUL
#define strtoul(a, b, c) strtol(a, b, c)
#endif
#ifdef __STDC__

View File

@ -1,6 +1,6 @@
#!/usr/local/bin/perl
#!/usr/pkg/bin/perl
#
# $NetBSD: file2netbsd,v 1.2 1998/09/20 15:36:46 christos Exp $
# $NetBSD: file2netbsd,v 1.3 1999/11/01 17:39:26 christos Exp $
#
# Perl script to convert a standard distribution directory for file into
# a NetBSD source tree.
@ -18,7 +18,7 @@
# Written by Christos Zoulas July 17, 1997 for file-3.26
#
$version = "3.26";
$version = "3.28";
# definitions ...
@ -26,11 +26,10 @@ $version = "3.26";
@filef = ("LEGAL.NOTICE", "MAINT",
"PORTING", "README", "apprentice.c", "ascmagic.c",
"README", "apprentice.c", "ascmagic.c",
"compress.c", "file.c", "file.h", "fsmagic.c",
"internat.c", "is_tar.c", "names.h", "patchlevel.h",
"print.c", "readelf.c", "readelf.h", "softmagic.c", "tar.h");
#
# Utility Subroutines
#
@ -174,7 +173,7 @@ system("cat $srcdir/Header > $targetdir/usr.bin/file/Header");
system("cat $srcdir/Localstuff > $targetdir/usr.bin/file/Localstuff");
print "Populating the usr.bin/file/magdir directory.\n";
system("cp -rp $srcdir/Magdir/* $targetdir/usr.bin/file/magdir; chmod -r ug+w magdir");
system("cp -rp $srcdir/Magdir/* $targetdir/usr.bin/file/magdir; chmod -R ug+w magdir");
#
# Build makefiles
@ -257,14 +256,20 @@ __END__
%% file usr.bin/file/Makefile
%% NetBSD #
FILESDIR= /usr/share/misc
FILES= magic
MAGIC= ${FILESDIR}/${FILES}
.include <bsd.own.mk>
MFILESDIR= /usr/share/misc
MFILES= magic
MAGIC= ${MFILESDIR}/${MFILES}
.if ${MKSHARE} != "no"
FILESDIR= ${MFILESDIR}
FILES= ${MFILES}
.endif
PROG= file
SRCS= file.c apprentice.c fsmagic.c softmagic.c ascmagic.c is_tar.c \
print.c compress.c readelf.c internat.c
CPPFLAGS+= -DMAGIC='"$(MAGIC)"' -DHAVE_SYS_WAIT_H -DHAVE_ST_RDEV
CPPFLAGS+= -DMAGIC='"$(MAGIC)"' -DHAVE_CONFIG_H -I${.CURDIR}
CPPFLAGS+= -DBUILTIN_ELF -DELFCORE
MAN= file.1 magic.5
@ -277,7 +282,87 @@ MAGFILES= $(.CURDIR)/Header \
$(.CURDIR)/magdir/netbsd \
${MAGDIRF}
.if ${MKSHARE} != "no"
magic: $(MAGFILES)
cat $(MAGFILES) > $(.TARGET)
.else
magic:
.endif
.include <bsd.prog.mk>
%% file usr.bin/file/config.h
/* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if your struct stat has st_rdev. */
#define HAVE_ST_RDEV 1
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#define HAVE_SYS_WAIT_H 1
/* Define if major, minor, and makedev are declared in <mkdev.h>. */
/* #undef MAJOR_IN_MKDEV */
/* Define if major, minor, and makedev are declared in <sysmacros.h>. */
/* #undef MAJOR_IN_SYSMACROS */
/* Define to `long' if <sys/types.h> doesn't define. */
/* #undef off_t */
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Autoheader needs me */
#define PACKAGE "file"
/* Autoheader needs me */
#define VERSION "3.28"
/* Define if builtin ELF support is enabled. */
#define BUILTIN_ELF 1
/* Define if ELF core file support is enabled. */
#define ELFCORE 1
/* Define if the `long long' type works. */
#define HAVE_LONG_LONG 1
/* Define to `unsigned char' if standard headers don't define. */
#define uint8_t unsigned char
/* Define to `unsigned short' if standard headers don't define. */
#define uint16_t unsigned short
/* Define to `unsigned int' if standard headers don't define. */
#define uint32_t unsigned int
/* Define to `unsigned long long', if available, or `unsigned long', if
standard headers don't define. */
#define uint64_t unsigned long long
/* The number of bytes in a uint8_t. */
#define SIZEOF_UINT8_T 1
/* The number of bytes in a uint16_t. */
#define SIZEOF_UINT16_T 2
/* The number of bytes in a uint32_t. */
#define SIZEOF_UINT32_T 4
/* The number of bytes in a uint64_t. */
#define SIZEOF_UINT64_T 8
/* Define if you have the strerror function. */
#define HAVE_STRERROR 1
/* Define if you have the strtoul function. */
#define HAVE_STRTOUL 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsmagic.c,v 1.12 1998/09/20 15:27:16 christos Exp $ */
/* $NetBSD: fsmagic.c,v 1.13 1999/11/01 17:39:26 christos Exp $ */
/*
* fsmagic - magic based on filesystem info - directory, special files, etc.
@ -27,39 +27,43 @@
* 4. This notice may not be removed or altered.
*/
#include "file.h"
#ifdef __CYGWIN__
#include <errno.h>
#endif
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
/* Since major is a function on SVR4, we can't use `ifndef major'. */
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
# define HAVE_MAJOR
#endif
#ifndef major
# if defined(__SVR4) || defined(_SVR4_SOURCE)
# include <sys/mkdev.h>
# endif
#ifdef MAJOR_IN_SYSMACROS
# include <sys/sysmacros.h>
# define HAVE_MAJOR
#endif
#ifndef major /* if `major' not defined in types.h, */
#include <sys/sysmacros.h> /* try this one. */
#ifdef major /* Might be defined in sys/types.h. */
# define HAVE_MAJOR
#endif
#ifndef major /* still not defined? give up, manual intervention needed */
/* If cc tries to compile this, read and act on it. */
/* On most systems cpp will discard it automatically */
Congratulations, you have found a portability bug.
Please grep /usr/include/sys and edit the above #include
to point at the file that defines the "major" macro.
#endif /*major*/
#include "file.h"
#ifndef HAVE_MAJOR
# define major(dev) (((dev) >> 8) & 0xff)
# define minor(dev) ((dev) & 0xff)
#endif
#undef HAVE_MAJOR
#include <sys/cdefs.h>
#ifndef lint
#if 0
FILE_RCSID("@(#)Id: fsmagic.c,v 1.27 1998/06/27 13:23:39 christos Exp ")
#else
__RCSID("$NetBSD: fsmagic.c,v 1.12 1998/09/20 15:27:16 christos Exp $");
__RCSID("$NetBSD: fsmagic.c,v 1.13 1999/11/01 17:39:26 christos Exp $");
#endif
#endif /* lint */
@ -89,36 +93,79 @@ struct stat *sb;
return 1;
}
#ifdef S_ISUID
if (sb->st_mode & S_ISUID) ckfputs("setuid ", stdout);
#endif
#ifdef S_ISGID
if (sb->st_mode & S_ISGID) ckfputs("setgid ", stdout);
#endif
#ifdef S_ISVTX
if (sb->st_mode & S_ISVTX) ckfputs("sticky ", stdout);
#endif
switch (sb->st_mode & S_IFMT) {
case S_IFDIR:
ckfputs("directory", stdout);
return 1;
#ifdef S_IFCHR
case S_IFCHR:
/*
* If -s has been specified, treat character special files
* like ordinary files. Otherwise, just report that they
* are block special files and go on to the next file.
*/
if (sflag)
break;
#ifdef HAVE_ST_RDEV
# ifdef dv_unit
(void) printf("character special (%d/%d/%d)",
major(sb->st_rdev),
dv_unit(sb->st_rdev),
dv_subunit(sb->st_rdev));
# else
(void) printf("character special (%ld/%ld)",
(long) major(sb->st_rdev), (long) minor(sb->st_rdev));
# endif
#else
(void) printf("character special");
#endif
return 1;
#endif
#ifdef S_IFBLK
case S_IFBLK:
/*
* If -s has been specified, treat block special files
* like ordinary files. Otherwise, just report that they
* are block special files and go on to the next file.
*/
if (sflag)
break;
#ifdef HAVE_ST_RDEV
# ifdef dv_unit
(void) printf("block special (%d/%d/%d)",
major(sb->st_rdev),
dv_unit(sb->st_rdev),
dv_subunit(sb->st_rdev));
# else
(void) printf("block special (%ld/%ld)",
(long) major(sb->st_rdev), (long) minor(sb->st_rdev));
# endif
#else
(void) printf("block special");
#endif
return 1;
#endif
/* TODO add code to handle V7 MUX and Blit MUX files */
#ifdef S_IFIFO
case S_IFIFO:
ckfputs("fifo (named pipe)", stdout);
return 1;
#endif
#ifdef S_IFDOOR
case S_IFDOOR:
ckfputs("door", stdout);
return 1;
#endif
#ifdef S_IFLNK
case S_IFLNK:
{
@ -188,8 +235,17 @@ struct stat *sb;
/*
* regular file, check next possibility
*
* If stat() tells us the file has zero length, report here that
* the file is empty, so we can skip all the work of opening and
* reading the file.
* But if the -s option has been given, we skip this optimization,
* since on some systems, stat() reports zero size for raw disk
* partitions. (If the block special device really has zero length,
* the fact that it is empty will be detected and reported correctly
* when we read the file.)
*/
if (sb->st_size == 0) {
if (!sflag && sb->st_size == 0) {
ckfputs("empty", stdout);
return 1;
}

View File

@ -1,13 +1,13 @@
/* $NetBSD: is_tar.c,v 1.10 1998/11/06 23:11:26 christos Exp $ */
/* $NetBSD: is_tar.c,v 1.11 1999/11/01 17:39:26 christos Exp $ */
/*
* is_tar() -- figure out whether file is a tar archive.
*
* Stolen (by the author!) from the public domain tar program:
* Pubic Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
* Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
*
* @(#)list.c 1.18 9/23/86 Public Domain - gnu
* Id: is_tar.c,v 1.10 1998/06/27 13:23:39 christos Exp
* Id: is_tar.c,v 1.12 1999/02/14 17:16:08 christos Exp
*
* Comments changed and some code/comments reformatted
* for file command by Ian Darwin.
@ -23,19 +23,15 @@
#include <sys/cdefs.h>
#ifndef lint
#if 0
FILE_RCSID("@(#)Id: is_tar.c,v 1.10 1998/06/27 13:23:39 christos Exp ")
FILE_RCSID("@(#)Id: is_tar.c,v 1.12 1999/02/14 17:16:08 christos Exp ")
#else
__RCSID("$NetBSD: is_tar.c,v 1.10 1998/11/06 23:11:26 christos Exp $");
__RCSID("$NetBSD: is_tar.c,v 1.11 1999/11/01 17:39:26 christos Exp $");
#endif
#endif
#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
#if defined(__STDC__) || defined(__cplusplus)
static int from_oct(int, char*); /* Decode octal number */
#else
static int from_oct();
#endif
static int from_oct __P((int, char *)); /* Decode octal number */
/*
* Return

View File

@ -11,7 +11,83 @@
#>4 beshort&0xfff0 x (%d x
#>5 beshort&0x0fff x %d)
0 belong 0x000001ba MPEG system stream data
#0 beshort&0xfff0 0xfff0 MPEG audio stream data
# MPEG Audio (*.mpx)
# from dreesen@math.fu-berlin.de
0 beshort &0xfff0 MP
# MPEG 1.0
>1 byte&0x08 =0x08 \b
# Layer 3
>>1 byte &0x02 \b3
>>>2 byte&0xf0 =0x10 \b, 32 kBits
>>>2 byte&0xf0 =0x20 \b, 40 kBits
>>>2 byte&0xf0 =0x30 \b, 48 kBits
>>>2 byte&0xf0 =0x40 \b, 56 kBits
>>>2 byte&0xf0 =0x50 \b, 64 kBits
>>>2 byte&0xf0 =0x60 \b, 80 kBits
>>>2 byte&0xf0 =0x70 \b, 96 kBits
>>>2 byte&0xf0 =0x80 \b, 112 kBits
>>>2 byte&0xf0 =0x90 \b, 128 kBits
>>>2 byte&0xf0 =0xA0 \b, 160 kBits
>>>2 byte&0xf0 =0xB0 \b, 192 kBits
>>>2 byte&0xf0 =0xC0 \b, 224 kBits
>>>2 byte&0xf0 =0xD0 \b, 256 kBits
>>>2 byte&0xf0 =0xE0 \b, 320 kBits
# Layer 2
>>1 byte &0x04 \b2
>>>2 byte&0xf0 =0x10 \b, 32 kBits
>>>2 byte&0xf0 =0x20 \b, 48 kBits
>>>2 byte&0xf0 =0x30 \b, 56 kBits
>>>2 byte&0xf0 =0x40 \b, 64 kBits
>>>2 byte&0xf0 =0x50 \b, 80 kBits
>>>2 byte&0xf0 =0x60 \b, 96 kBits
>>>2 byte&0xf0 =0x70 \b, 112 kBits
>>>2 byte&0xf0 =0x80 \b, 128 kBits
>>>2 byte&0xf0 =0x90 \b, 160 kBits
>>>2 byte&0xf0 =0xA0 \b, 192 kBits
>>>2 byte&0xf0 =0xB0 \b, 224 kBits
>>>2 byte&0xf0 =0xC0 \b, 256 kBits
>>>2 byte&0xf0 =0xD0 \b, 320 kBits
>>>2 byte&0xf0 =0xE0 \b, 384 kBits
# freq
>>2 byte&0x0C =0x00 \b, 44.1 kHz
>>2 byte&0x0C =0x04 \b, 48 kHz
>>2 byte&0x0C =0x08 \b, 32 kHz
# MPEG 2.0
>1 byte&0x08 =0x00 \b
# Layer 3
>>1 byte &0x02 \b3
# Layer 2
>>1 byte &0x04 \b2
>>2 byte&0xf0 =0x10 \b, 8 kBits
>>2 byte&0xf0 =0x20 \b, 16 kBits
>>2 byte&0xf0 =0x30 \b, 24 kBits
>>2 byte&0xf0 =0x40 \b, 32 kBits
>>2 byte&0xf0 =0x50 \b, 40 kBits
>>2 byte&0xf0 =0x60 \b, 48 kBits
>>2 byte&0xf0 =0x70 \b, 56 kBits
>>2 byte&0xf0 =0x80 \b, 64 kBits
>>2 byte&0xf0 =0x90 \b, 80 kBits
>>2 byte&0xf0 =0xA0 \b, 96 kBits
>>2 byte&0xf0 =0xB0 \b, 112 kBits
>>2 byte&0xf0 =0xC0 \b, 128 kBits
>>2 byte&0xf0 =0xD0 \b, 144 kBits
>>2 byte&0xf0 =0xE0 \b, 160 kBits
# freq
>>2 byte&0x0C =0x00 \b, 22.05 kHz
>>2 byte&0x0C =0x04 \b, 24 kHz
>>2 byte&0x0C =0x08 \b, 16 kHz
# misc
>3 byte&0xC0 =0x00 \b, Stereo
>3 byte&0xC0 =0x40 \b, JStereo
>3 byte&0xC0 =0x80 \b, Dual-Ch
>3 byte&0xC0 =0xC0 \b, Mono
#>1 byte&0x01 =0x00 \b, Error Protection
#>2 byte&0x02 =0x02 \b, Padding
#>2 byte&0x01 =0x01 \b, Private
#>3 byte&0x08 =0x08 \b, Copyright
#>3 byte&0x04 =0x04 \b, Original
#>3 byte&0x03 1 \b, Emphasis 5
#>3 byte&0x03 3 \b, Emphasis c
# FLI animation format
4 leshort 0xAF11 FLI file

View File

@ -4,7 +4,6 @@
#
0 string FiLeStArTfIlEsTaRt binscii (apple ][) text
0 string \x0aGL Binary II (apple ][) data
0 string \x76\xff Squeezed (apple ][) data
0 string NuFile NuFile archive (apple ][) data
0 string N\xf5F\xe9l\xe5 NuFile archive (apple ][) data
0 belong 0x00051600 AppleSingle encoded Macintosh file

View File

@ -214,3 +214,17 @@
# Shell archives
10 string #\ This\ is\ a\ shell\ archive shell archive text
#
# LBR. NB: May conflict with the questionable
# "binary Computer Graphics Metafile" format.
#
0 string \0\ \ \ \ \ \ \ \ \ \ \ \0\0 LBR archive data
#
# PMA (CP/M derivative of LHA)
#
2 string -pm0- PMarc archive data [pm0]
2 string -pm1- PMarc archive data [pm1]
2 string -pm2- PMarc archive data [pm2]
2 string -pms- PMarc SFX archive (CP/M, DOS)
5 string -pc1- PopCom compressed executable (CP/M)

View File

@ -67,12 +67,13 @@
>83 byte 1 (song)
# Real Audio (Magic .ra\0375)
0 belong 0x2e7261fd realaudio sound file
0 belong 0x2e7261fd RealAudio sound file
0 string .RMF RealMedia file
# MTM/669/FAR/S3M/ULT/XM format checking [Aaron Eppert, aeppert@dialin.ind.net]
# Oct 31, 1995
0 string MTM MultiTracker Module sound file
0 string if Composer 669 Module sound data
#0 string if Composer 669 Module sound data
0 string FAR Module sound data
0 string MAS_U ULT(imate) Module sound data
0x2c string SCRM ScreamTracker III Module sound data
@ -110,140 +111,7 @@
#
0 string TOC TOC sound file
# Show MPEG level, layer, kbit/s, hz, stereo/mono for an MPG audio file.
# This section is lengthy because the kbit/s rate depends on the
# level and layer, and file(1) doesn't allow math on the values.
# From <ckane@best.com>
#
####### MPEG begins with three hex 'f' nibbles.
0 beshort&0xfff0 0xfff0 MPEG
####### Level 2
>1 byte&0x08 0x00 2.0
>>1 byte&0x06 0x00 Layer Unknown,
####### Level 2, Layers I, II, and III
>>1 byte&0x06 0x02 Layer III,
>>>2 byte&0xf0 0x00 0 kbit/s,
>>>2 byte&0xf0 0x10 8 kbit/s,
>>>2 byte&0xf0 0x20 16 kbit/s,
>>>2 byte&0xf0 0x30 24 kbit/s,
>>>2 byte&0xf0 0x40 32 kbit/s,
>>>2 byte&0xf0 0x50 40 kbit/s,
>>>2 byte&0xf0 0x60 48 kbit/s,
>>>2 byte&0xf0 0x70 56 kbit/s,
>>>2 byte&0xf0 0x80 64 kbit/s,
>>>2 byte&0xf0 0x90 80 kbit/s,
>>>2 byte&0xf0 0xa0 96 kbit/s,
>>>2 byte&0xf0 0xb0 112 kbit/s,
>>>2 byte&0xf0 0xc0 128 kbit/s,
>>>2 byte&0xf0 0xd0 144 kbit/s,
>>>2 byte&0xf0 0xe0 160 kbit/s,
>>>2 byte&0xf0 0xf0 ? kbit/s,
>>1 byte&0x06 0x04 Layer II,
>>>2 byte&0xf0 0x00 0 kbit/s,
>>>2 byte&0xf0 0x10 8 kbit/s,
>>>2 byte&0xf0 0x20 16 kbit/s,
>>>2 byte&0xf0 0x30 24 kbit/s,
>>>2 byte&0xf0 0x40 32 kbit/s,
>>>2 byte&0xf0 0x50 40 kbit/s,
>>>2 byte&0xf0 0x60 48 kbit/s,
>>>2 byte&0xf0 0x70 56 kbit/s,
>>>2 byte&0xf0 0x80 64 kbit/s,
>>>2 byte&0xf0 0x90 80 kbit/s,
>>>2 byte&0xf0 0xa0 96 kbit/s,
>>>2 byte&0xf0 0xb0 112 kbit/s,
>>>2 byte&0xf0 0xc0 128 kbit/s,
>>>2 byte&0xf0 0xd0 144 kbit/s,
>>>2 byte&0xf0 0xe0 160 kbit/s,
>>>2 byte&0xf0 0xf0 ? kbit/s,
>>1 byte&0x06 0x06 Layer I,
>>>2 byte&0xf0 0x00 0 kbit/s,
>>>2 byte&0xf0 0x10 32 kbit/s,
>>>2 byte&0xf0 0x20 48 kbit/s,
>>>2 byte&0xf0 0x30 56 kbit/s,
>>>2 byte&0xf0 0x40 64 kbit/s,
>>>2 byte&0xf0 0x50 80 kbit/s,
>>>2 byte&0xf0 0x60 96 kbit/s,
>>>2 byte&0xf0 0x70 112 kbit/s,
>>>2 byte&0xf0 0x80 128 kbit/s,
>>>2 byte&0xf0 0x90 144 kbit/s,
>>>2 byte&0xf0 0xa0 160 kbit/s,
>>>2 byte&0xf0 0xb0 176 kbit/s,
>>>2 byte&0xf0 0xc0 192 kbit/s,
>>>2 byte&0xf0 0xd0 224 kbit/s,
>>>2 byte&0xf0 0xe0 256 kbit/s,
>>>2 byte&0xf0 0xf0 ? kbit/s,
####### Level 2, Hz
>>2 byte&0x0c 0x00 22050 Hz
>>2 byte&0x0c 0x04 24000 Hz
>>2 byte&0x0c 0x08 16000 Hz
>>2 byte&0x0c 0x0c ? Hz
####### Level 1 decoding
>1 byte&0x08 0x08 1.0
>>1 byte&0x06 0x00 Layer Unknown.
####### Level 1, Layers I, II, and III
>>1 byte&0x06 0x02 Layer III,
>>>2 byte&0xf0 0x00 0 kbit/s,
>>>2 byte&0xf0 0x10 32 kbit/s,
>>>2 byte&0xf0 0x20 40 kbit/s,
>>>2 byte&0xf0 0x30 48 kbit/s,
>>>2 byte&0xf0 0x40 56 kbit/s,
>>>2 byte&0xf0 0x50 64 kbit/s,
>>>2 byte&0xf0 0x60 80 kbit/s,
>>>2 byte&0xf0 0x70 96 kbit/s,
>>>2 byte&0xf0 0x80 112 kbit/s,
>>>2 byte&0xf0 0x90 128 kbit/s,
>>>2 byte&0xf0 0xa0 160 kbit/s,
>>>2 byte&0xf0 0xb0 192 kbit/s,
>>>2 byte&0xf0 0xc0 224 kbit/s,
>>>2 byte&0xf0 0xd0 256 kbit/s,
>>>2 byte&0xf0 0xe0 320 kbit/s,
>>>2 byte&0xf0 0xf0 ? kbit/s,
>>1 byte&0x06 0x04 Layer II,
>>>2 byte&0xf0 0x00 0 kbit/s,
>>>2 byte&0xf0 0x10 32 kbit/s,
>>>2 byte&0xf0 0x20 48 kbit/s,
>>>2 byte&0xf0 0x30 56 kbit/s,
>>>2 byte&0xf0 0x40 64 kbit/s,
>>>2 byte&0xf0 0x50 80 kbit/s,
>>>2 byte&0xf0 0x60 96 kbit/s,
>>>2 byte&0xf0 0x70 112 kbit/s,
>>>2 byte&0xf0 0x80 128 kbit/s,
>>>2 byte&0xf0 0x90 160 kbit/s,
>>>2 byte&0xf0 0xa0 192 kbit/s,
>>>2 byte&0xf0 0xb0 224 kbit/s,
>>>2 byte&0xf0 0xc0 256 kbit/s,
>>>2 byte&0xf0 0xd0 320 kbit/s,
>>>2 byte&0xf0 0xe0 384 kbit/s,
>>>2 byte&0xf0 0xf0 ? kbit/s,
>>1 byte&0x06 0x06 Layer I,
>>>2 byte&0xf0 0x00 0 kbit/s,
>>>2 byte&0xf0 0x10 32 kbit/s,
>>>2 byte&0xf0 0x20 64 kbit/s,
>>>2 byte&0xf0 0x30 96 kbit/s,
>>>2 byte&0xf0 0x40 128 kbit/s,
>>>2 byte&0xf0 0x50 160 kbit/s,
>>>2 byte&0xf0 0x60 192 kbit/s,
>>>2 byte&0xf0 0x70 224 kbit/s,
>>>2 byte&0xf0 0x80 256 kbit/s,
>>>2 byte&0xf0 0x90 288 kbit/s,
>>>2 byte&0xf0 0xa0 320 kbit/s,
>>>2 byte&0xf0 0xb0 352 kbit/s,
>>>2 byte&0xf0 0xc0 384 kbit/s,
>>>2 byte&0xf0 0xd0 416 kbit/s,
>>>2 byte&0xf0 0xe0 448 kbit/s,
>>>2 byte&0xf0 0xf0 ? kbit/s,
####### Level 2, Hz
>>2 byte&0x0c 0x00 44100 Hz
>>2 byte&0x0c 0x04 48000 Hz
>>2 byte&0x0c 0x08 32000 Hz
>>2 byte&0x0c 0x0c ? Hz
####### Stereo or Mono
>3 byte&0xc0 0x00 stereo
>3 byte&0xc0 0x40 joint-stereo
>3 byte&0xc0 0x80 dual-channel
>3 byte&0xc0 0xc0 mono
#
# sidfiles
# sidfiles <pooka@iki.fi>
0 string SIDPLAY\ INFOFILE Sidplay info file
0 string PSID PlaySID v2.2+ (AMIGA) sidtune
>4 beshort >0 w/ header v%d,

View File

@ -61,11 +61,11 @@
# squeeze and crunch
# Michael Haardt <michael@cantor.informatik.rwth-aachen.de>
0 leshort 0xFF76 squeezed data,
0 beshort 0x76FF squeezed data,
>4 string x original name %s
0 leshort 0xFE76 crunched data,
0 beshort 0x76FE crunched data,
>2 string x original name %s
0 leshort 0xFD76 LZH compressed data,
0 beshort 0x76FD LZH compressed data,
>2 string x original name %s
# Freeze

View File

@ -12,10 +12,12 @@
0 lelong 0x13579ace GNU dbm 1.x or ndbm database, little endian
0 string GDBM GNU dbm 2.x database
#
0 belong 0x061561 Berkeley DB Hash file
0 belong 0x061561 Berkeley DB
>4 belong >2 1.86
>4 belong <3 1.85
>8 belong 4321 Hash/Big Endian
>8 belong 1234 Hash/Little Endian
>4 belong >0 (Version %d,
>8 belong 1234 Little Endian,
>8 belong 4321 Big Endian,
>12 belong x Bucket Size %d,
>16 belong x Bucket Shift %d,
>20 belong x Directory Size %d,
@ -30,15 +32,64 @@
>56 belong x Number of Keys %d)
#
#
0 belong 0x053162 Berkeley DB Btree file/Big Endian
0 belong 0x053162 Berkeley DB 1.85/1.86 Btree/Big Endian
>4 belong >0 (Version %d,
>8 belong x Page Size %d,
>12 belong x Free Page %d,
>16 belong x Number of Records %d,
>20 belong x Flags 0x%x)
0 lelong 0x053162 Berkeley DB Btree file/Little Endian
0 lelong 0x053162 Berkeley DB 1.85/1.86 Btree/Little Endian
>4 lelong >0 (Version %d,
>8 lelong x Page Size %d,
>12 lelong x Free Page %d,
>16 lelong x Number of Records %d,
>20 lelong x Flags 0x%x)
#
#
12 belong 0x061561 Berkeley DB 2.X Hash/Big Endian
>16 belong >0 (Version %d,
>0 belong x Logical sequence number: file - %d,
>4 belong x offset - %d,
>20 belong x Bucket Size %d,
>24 belong x Overflow Point %d,
>28 belong x Last Freed %d,
>32 belong x Max Bucket %d,
>36 belong x High Mask 0x%x,
>40 belong x Low Mask 0x%x,
>44 belong x Fill Factor %d,
>48 belong x Number of Keys %d)
#
# DB2.X formats from Khimenko Victor <khim@sch57.msk.ru>
#
12 lelong 0x061561 Berkeley DB 2.X Hash/Little Endian
>16 lelong >0 (Version %d,
>0 lelong x Logical sequence number: file - %d,
>4 lelong x offset - %d,
>20 lelong x Bucket Size %d,
>24 lelong x Overflow Point %d,
>28 lelong x Last Freed %d,
>32 lelong x Max Bucket %d,
>36 lelong x High Mask 0x%x,
>40 lelong x Low Mask 0x%x,
>44 lelong x Fill Factor %d,
>48 lelong x Number of Keys %d)
#
#
12 belong 0x053162 Berkeley DB 2.X Btree/Big Endian
>16 belong >0 (Version %d,
>0 belong x Logical sequence number: file - %d,
>4 belong x offset - %d,
>20 belong x Page Size %d,
>24 belong x Maxkey %d,
>28 belong x Minkey %d,
>32 belong x Free Page %d)
#
#
12 lelong 0x053162 Berkeley DB 2.X Btree/Little Endian
>16 lelong >0 (Version %d,
>0 lelong x Logical sequence number: file - %d,
>4 lelong x offset - %d,
>20 lelong x Page Size %d,
>24 lelong x Maxkey %d,
>28 lelong x Minkey %d,
>32 lelong x Free Page %d)

View File

@ -6,3 +6,8 @@
0 string ***\ 'diff' output text
0 string Only\ in\ 'diff' output text
0 string Common\ subdirectories:\ 'diff' output text
# xdelta is like diff(1) for binary files (works for text, too).
# Available from: ftp://ftp.xcf.berkeley.edu/pub/xdelta/
0 string %XDZ xdelta diff file
>4 string >% version %.3s

View File

@ -12,6 +12,9 @@
0 string \177ELF ELF
>4 byte 0 invalid class
>4 byte 1 32-bit
# only for MIPS R3000_BE
>>18 beshort 8
>>>36 belong &0x20 N32
>4 byte 2 64-bit
>5 byte 0 invalid byte order
>5 byte 1 LSB
@ -56,7 +59,7 @@
>>18 leshort 47 Hitachi H8/300H,
>>18 leshort 48 Hitachi H8S,
>>18 leshort 49 Hitachi H8/500,
>>18 leshort 50 Intel Merced Processor,
>>18 leshort 50 IA-64 (Intel 64 bit architecture)
>>18 leshort 51 Stanford MIPS-X,
>>18 leshort 52 Motorola Coldfire,
>>18 leshort 53 Motorola M68HC12,
@ -67,6 +70,24 @@
>>36 lelong 1 MathCoPro/FPU/MAU Required
>8 string >\0 (%s)
>5 byte 2 MSB
# only for MIPS R3000_BE
>>18 beshort 8
# only for 32-bit
>>>4 byte 1
>>>>36 belong&0xf0000000 0x00000000 mips-1
>>>>36 belong&0xf0000000 0x10000000 mips-2
>>>>36 belong&0xf0000000 0x20000000 mips-3
>>>>36 belong&0xf0000000 0x30000000 mips-4
>>>>36 belong&0xf0000000 0x40000000 mips-5
>>>>36 belong&0xf0000000 0x50000000 mips-6
# only for 64-bit
>>>4 byte 2
>>>>48 belong&0xf0000000 0x00000000 mips-1
>>>>48 belong&0xf0000000 0x10000000 mips-2
>>>>48 belong&0xf0000000 0x20000000 mips-3
>>>>48 belong&0xf0000000 0x30000000 mips-4
>>>>48 belong&0xf0000000 0x40000000 mips-5
>>>>48 belong&0xf0000000 0x50000000 mips-6
>>16 beshort 0 no file type,
>>16 beshort 1 relocatable,
>>16 beshort 2 executable,
@ -91,6 +112,10 @@
>>18 beshort 16 nCUBE,
>>18 beshort 17 Fujitsu VPP500,
>>18 beshort 18 SPARC32PLUS,
>>>36 belong&0xffff00 &0x000100 V8+ Required,
>>>36 belong&0xffff00 &0x000200 Sun UltraSPARC1 Extensions Required,
>>>36 belong&0xffff00 &0x000400 HaL R1 Extensions Required,
>>>36 belong&0xffff00 &0x000800 Sun UltraSPARC3 Extensions Required,
>>18 beshort 20 PowerPC or cisco 4500,
>>18 beshort 21 cisco 7500,
>>18 beshort 24 cisco SVIP,
@ -102,7 +127,7 @@
>>18 beshort 40 Advanced RISC Machines ARM,
>>18 beshort 41 Alpha,
>>18 beshort 42 Hitachi SH,
>>18 beshort 43 SPARC V9 - invalid byte order,
>>18 beshort 43 SPARC V9,
>>18 beshort 44 Siemens Tricore Embedded Processor,
>>18 beshort 45 Argonaut RISC Core, Argonaut Technologies Inc.,
>>18 beshort 46 Hitachi H8/300,

View File

@ -33,6 +33,7 @@
>>0x36 string FAT \b, %s
>>>0x39 string 12 (%s bit)
>>>0x39 string 16 (%s bit)
>0x52 string FAT32 \b, FAT (32 bit)
>>>43 string >NO\ NAME label: %.11s,
>>>43 string <NO\ NAME label: %.11s,
>>>43 string NO\ NAME unlabeled,
@ -60,3 +61,18 @@
>4 lelong&0xFFFFFF00 !0 unknown mode
0x18b string OS/2 OS/2 Boot Manager
9564 lelong 0x00011954 Unix Fast File system,
>8404 string x last mounted on %s,
>9504 ledate x last checkd at %s,
>8224 ledate x last writen at %s,
>8228 lelong x number of blocks %d,
>8232 lelong x number of data blocks %d,
>8236 lelong x number of cylinder groups %d,
>8240 lelong x number of basic blocks %d,
>8244 lelong x number of fragment blocks %d,
>8248 lelong x minimum percentage of free blocks %d,
>8252 lelong x rotational delay %dms,
>8256 lelong x disk rotational speed %drps,
>8320 lelong 0 TIME optimization
>8320 lelong 1 SPACE optimization

View File

@ -51,7 +51,7 @@
#### PA-RISC 1.1
0 belong 0x02100106 PA-RISC1.1 relocatable object
0 belong 0x02100107 PA-RISC1.1 executable
>168 belong &=0x00000004 dynamically linked
>168 belong &0x00000004 dynamically linked
>(144) belong 0x054ef630 dynamically linked
>96 belong >0 - not stripped
@ -75,17 +75,17 @@
0 belong 0x02140106 PA-RISC2.0 relocatable object
0 belong 0x02140107 PA-RISC2.0 executable
>168 belong &=0x00000004 dynamically linked
>168 belong &0x00000004 dynamically linked
>(144) belong 0x054ef630 dynamically linked
>96 belong >0 - not stripped
0 belong 0x02140108 PA-RISC2.0 shared executable
>168 belong &=0x00000004 dynamically linked
>168 belong &0x00000004 dynamically linked
>(144) belong 0x054ef630 dynamically linked
>96 belong >0 - not stripped
0 belong 0x0214010b PA-RISC2.0 demand-load executable
>168 belong &=0x00000004 dynamically linked
>168 belong &0x00000004 dynamically linked
>(144) belong 0x054ef630 dynamically linked
>96 belong >0 - not stripped
@ -205,30 +205,30 @@
# addendum to /etc/magic with HP-48sx file-types by phk@data.fls.dk 1jan92
0 string HPHP48- HP48 binary
>7 byte >0 - Rev %c
>8 short 0x1129 (ADR)
>8 short 0x3329 (REAL)
>8 short 0x5529 (LREAL)
>8 short 0x7729 (COMPLX)
>8 short 0x9d29 (LCOMPLX)
>8 short 0xbf29 (CHAR)
>8 short 0xe829 (ARRAY)
>8 short 0x0a2a (LNKARRAY)
>8 short 0x2c2a (STRING)
>8 short 0x4e2a (HXS)
>8 short 0x742a (LIST)
>8 short 0x962a (DIR)
>8 short 0xb82a (ALG)
>8 short 0xda2a (UNIT)
>8 short 0xfc2a (TAGGED)
>8 short 0x1e2b (GROB)
>8 short 0x402b (LIB)
>8 short 0x622b (BACKUP)
>8 short 0x882b (LIBDATA)
>8 short 0x9d2d (PROG)
>8 short 0xcc2d (CODE)
>8 short 0x482e (GNAME)
>8 short 0x6d2e (LNAME)
>8 short 0x922e (XLIB)
>8 beshort 0x1129 (ADR)
>8 beshort 0x3329 (REAL)
>8 beshort 0x5529 (LREAL)
>8 beshort 0x7729 (COMPLX)
>8 beshort 0x9d29 (LCOMPLX)
>8 beshort 0xbf29 (CHAR)
>8 beshort 0xe829 (ARRAY)
>8 beshort 0x0a2a (LNKARRAY)
>8 beshort 0x2c2a (STRING)
>8 beshort 0x4e2a (HXS)
>8 beshort 0x742a (LIST)
>8 beshort 0x962a (DIR)
>8 beshort 0xb82a (ALG)
>8 beshort 0xda2a (UNIT)
>8 beshort 0xfc2a (TAGGED)
>8 beshort 0x1e2b (GROB)
>8 beshort 0x402b (LIB)
>8 beshort 0x622b (BACKUP)
>8 beshort 0x882b (LIBDATA)
>8 beshort 0x9d2d (PROG)
>8 beshort 0xcc2d (CODE)
>8 beshort 0x482e (GNAME)
>8 beshort 0x6d2e (LNAME)
>8 beshort 0x922e (XLIB)
0 string %%HP: HP48 text
>6 string T(0) - T(0)
>6 string T(1) - T(1)

View File

@ -7,7 +7,20 @@
# merging several one- and two-line files into here.
#
# little magic: PCX (first byte is 0x0a)
# no magic: Targa
# Targa - matches `povray', `ppmtotga' and `xv' outputs
# by Philippe De Muyter <phdm@macqel.be>
# at 2, byte ImgType must be 1, 2, 3, 9, 10 or 11
# at 1, byte CoMapType must be 1 if ImgType is 1 or 9, 0 otherwise
# at 3, leshort Index is 0 for povray, ppmtotga and xv outputs
# `xv' recognizes only a subset of the following (RGB with pixelsize = 24)
# `tgatoppm' recognizes a superset (Index may be anything)
1 belong&0xfff7ffff 0x01010000 Targa image data - Map
>2 byte&8 8 - RLE
1 belong&0xfff7ffff 0x00020000 Targa image data - RGB
>2 byte&8 8 - RLE
1 belong&0xfff7ffff 0x00030000 Targa image data - Mono
>2 byte&8 8 - RLE
# PBMPLUS images
# The next byte following the magic is always whitespace.
@ -118,19 +131,6 @@
>29 byte 0 \b, normal resolution (204x98 DPI)
>29 byte 1 \b, fine resolution (204x196 DPI)
# JPEG images
# SunOS 5.5.1 had
#
# 0 string \377\330\377\340 JPEG file
# 0 string \377\330\377\356 JPG file
#
# both of which turn into "JPEG image data" here.
#
0 beshort 0xffd8 JPEG image data
>6 string JFIF \b, JFIF standard
# HSI is Handmade Software's proprietary JPEG encoding scheme
0 string hsi1 JPEG image data, HSI proprietary
# PC bitmaps (OS/2, Windoze BMP files) (Greg Roelofs, newt@uchicago.edu)
0 string BM PC bitmap data
>14 leshort 12 \b, OS/2 1.x format

View File

@ -5,4 +5,4 @@
# From <rgooch@atnf.csiro.au>
0 string KarmaRHD Version Karma Data Structure Version
>16 long x %lu
>16 belong x %lu

View File

@ -87,6 +87,7 @@
>24 string @ \b, OS/2 or MS Windows
>>0xe7 string LH/2\ Self-Extract \b, %s
>>0xe9 string PKSFX2 \b, %s
>>122 string Windows\ self-extracting\ ZIP \b, %s
>0x1c string RJSX\xff\xff \b, ARJ SFX
>0x1c string diet\xf9\x9c \b, diet compressed
>0x1e string Copyright\ 1989-1990\ PKWARE\ Inc. \b, PKSFX
@ -149,11 +150,15 @@
2080 string Microsoft\ Word\ 6.0\ Document %s
2080 string Documento\ Microsoft\ Word\ 6 Spanish Microsoft Word 6 document data
# Pawel Wiecek <coven@i17linuxb.ists.pwr.wroc.pl> (for polish Word)
2112 string MSWordDoc Microsoft Word document data
2112 string MSWordDoc Microsoft Word document data
#
0 belong 0x31be0000 Microsoft Word Document
0 belong 0x31be0000 Microsoft Word Document
#
0 string PO^Q` Microsoft Word 6.0 Document
0 string PO^Q` Microsoft Word 6.0 Document
#
0 string \376\067\0\043 Microsoft Office Document
0 string \320\317\021\340\241\261 Microsoft Office Document
0 string \333\245-\0\0\0 Microsoft Office Document
#
2080 string Microsoft\ Excel\ 5.0\ Worksheet %s
#
@ -176,3 +181,6 @@
# Help files
0 string ?_\3\0 MS Windows Help Data
# Microsoft CAB distribution format Dale Worley <root@dworley.ny.mediaone.net>
0 string MSCF\000\000\000\000 Microsoft CAB file

View File

@ -17,6 +17,8 @@
>>>16 string EPS - type %s
>>>16 string Query - type %s
>>>16 string ExitServer - type %s
0 string \033%-12345X%!PS PostScript document
# DOS EPS Binary File Header
# From: Ed Sznyter <ews@Black.Market.NET>

View File

@ -1,21 +1,28 @@
#------------------------------------------------------------------------------
# sgml: file(1) magic for Standard Generalized Markup Language
# HyperText Markup Language (HTML) is an SGML document type,
# from Daniel Quinlan (quinlan@yggdrasil.com)
0 string \<!DOCTYPE\ HTML HTML document text
0 string \<!doctype\ html HTML document text
0 string \<HEAD HTML document text
0 string \<head HTML document text
0 string \<TITLE HTML document text
0 string \<title HTML document text
0 string \<html HTML document text
0 string \<HTML HTML document text
0 string \<!DOCTYPE\ HTML HTML document text
0 string \<!doctype\ html HTML document text
0 string \<HEAD HTML document text
0 string \<head HTML document text
0 string \<TITLE HTML document text
0 string \<title HTML document text
0 string \<html HTML document text
0 string \<HTML HTML document text
# Extensible markup language (XML), a subset of SGML
# from Marc Prud'hommeaux (marc@apocalypse.org)
0 string \<?xml XML document text
0 string \<?XML XML document text
0 string \<?Xml XML document text
# SGML, mostly from rph@sq
0 string \<!DOCTYPE exported SGML document text
0 string \<!doctype exported SGML document text
0 string \<!SUBDOC exported SGML subdocument text
0 string \<!subdoc exported SGML subdocument text
0 string \<!-- exported SGML document text
0 string \<!DOCTYPE exported SGML document text
0 string \<!doctype exported SGML document text
0 string \<!SUBDOC exported SGML subdocument text
0 string \<!subdoc exported SGML subdocument text
0 string \<!-- exported SGML document text

View File

@ -1,10 +1,10 @@
#------------------------------------------------------------------------------
# sniffer: file(1) magic for packet captured files
# sniffer: file(1) magic for packet capture files
#
# From: guy@netapp.com (Guy Harris)
#
# Microsoft NetMon (packet capture/display program) capture files.
# Microsoft Network Monitor capture files.
#
0 string RTSS NetMon capture file
>4 byte x - version %d
@ -16,28 +16,34 @@
#
# Network General Sniffer capture files.
# Sorry, make that "Network Associates Sniffer capture files."
#
0 string TRSNIFF\ data\ \ \ \ \032 Sniffer capture file
>33 byte 2 (compressed)
>23 leshort x - version %d
>25 leshort x \b.%d
>33 byte x (Format %d,
>32 byte 0 Token ring)
>32 byte 1 Ethernet)
>32 byte 2 ARCNET)
>32 byte 3 StarLAN)
>32 byte 4 PC Network broadband)
>32 byte 5 LocalTalk)
>32 byte 6 Znet)
>32 byte 0 (Token Ring)
>32 byte 1 (Ethernet)
>32 byte 2 (ARCNET)
>32 byte 3 (StarLAN)
>32 byte 4 (PC Network broadband)
>32 byte 5 (LocalTalk)
>32 byte 6 (Znet)
>32 byte 7 (Internetwork Analyzer)
>32 byte 9 (FDDI)
>32 byte 10 (ATM)
#
# Cinco Networks NetXRay capture files.
# Sorry, make that "Network General Sniffer Basic capture files."
# Sorry, make that "Network Associates Sniffer Basic capture files."
#
0 string XCP\0 NetXRay capture file
>4 string >\0 - version %s
#
# "libpcap" capture files.
# (We call them "tcpdump capture file(s)" for now, as "tcpdump" is
# the main program that uses that format, but there's also "tcpview",
# and there may be others in the future.)
# the main program that uses that format, but there are other programs
# that use "libpcap", or that use the same capture file format.)
#
0 ubelong 0xa1b2c3d4 tcpdump capture file (big-endian)
>4 beshort x - version %d

View File

@ -15,7 +15,11 @@
6 beshort 0407 unicos (cray) executable
# Ultrix 4.3
596 string \130\337\377\377 Ultrix core file
>600 string >\0 '%s'
>600 string >\0 from '%s'
# BeOS and MAcOS PEF executables
# From: hplus@zilker.net (Jon Watte)
0 string Joy!peffpwpc header for PowerPC PEF executable
#
# ava assembler/linker Uros Platise <uros.platise@ijs.si>
0 string avaobj AVR assembler object code
>7 string >\0 version '%s'

View File

@ -1,4 +1,4 @@
/* $NetBSD: names.h,v 1.8 1998/09/20 15:27:16 christos Exp $ */
/* $NetBSD: names.h,v 1.9 1999/11/01 17:39:26 christos Exp $ */
/*
* Names.h - names and types used by ascmagic in file(1).
@ -12,7 +12,7 @@
*
* See LEGAL.NOTICE
*
* Id: names.h,v 1.15 1998/09/12 13:17:52 christos Exp
* Id: names.h,v 1.16 1999/01/13 15:44:08 christos Exp
*/
/* these types are used to index the table 'types': keep em in sync! */
@ -106,7 +106,6 @@ static struct names {
{"double", L_C},
{"extern", L_C},
{"float", L_C},
{"real", L_C},
{"struct", L_C},
{"union", L_C},
{"CFLAGS", L_MAKE},

View File

@ -1,13 +1,25 @@
/* $NetBSD: patchlevel.h,v 1.9 1998/09/20 15:27:16 christos Exp $ */
/* $NetBSD: patchlevel.h,v 1.10 1999/11/01 17:39:26 christos Exp $ */
#define FILE_VERSION_MAJOR 3
#define patchlevel 26
#define patchlevel 28
/*
* Patchlevel file for Ian Darwin's MAGIC command.
* Id: patchlevel.h,v 1.26 1998/09/12 13:19:39 christos Exp
* Id: patchlevel.h,v 1.28 1999/10/31 22:11:48 christos Exp
*
* Log: patchlevel.h,v
* Revision 1.28 1999/10/31 22:11:48 christos
* - add "char" type for compatibility with HP/UX
* - recognize HP/UX syntax &=n etc.
* - include errno.h for CYGWIN
* - conditionalize the S_IS* macros
* - revert the SHT_DYNSYM test that broke the linux stripped binaries test
* - lots of Magdir changes
*
* Revision 1.27 1999/02/14 17:21:41 christos
* Automake support and misc cleanups from Rainer Orth
* Enable reading character and block special files from Dale R. Worley
*
* Revision 1.26 1998/09/12 13:19:39 christos
* - add support for bi-endian indirect offsets (Richard Verhoeven)
* - add recognition for bcpl (Joseph Myers)

View File

@ -1,4 +1,4 @@
/* $NetBSD: print.c,v 1.15 1998/09/30 18:51:13 thorpej Exp $ */
/* $NetBSD: print.c,v 1.16 1999/11/01 17:39:26 christos Exp $ */
/*
* print.c - debugging printout routines
@ -27,25 +27,27 @@
* 4. This notice may not be removed or altered.
*/
#include "file.h"
#include <stdio.h>
#include <errno.h>
#include <string.h>
#if __STDC__
#ifdef __STDC__
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <time.h>
#include "file.h"
#include <sys/cdefs.h>
#ifndef lint
#if 0
FILE_RCSID("@(#)Id: print.c,v 1.26 1998/06/27 13:57:23 christos Exp ")
FILE_RCSID("@(#)Id: print.c,v 1.29 1999/10/31 22:23:04 christos Exp ")
#else
__RCSID("$NetBSD: print.c,v 1.15 1998/09/30 18:51:13 thorpej Exp $");
__RCSID("$NetBSD: print.c,v 1.16 1999/11/01 17:39:26 christos Exp $");
#endif
#endif /* lint */
@ -72,8 +74,7 @@ struct magic *m;
(void) fprintf(stderr, " %s%s", (m->flag & UNSIGNED) ? "u" : "",
/* Note: type is unsigned */
(m->type < SZOF(typ)) ?
typ[(unsigned char) m->type] : "*bad*");
(m->type < SZOF(typ)) ? typ[m->type] : "*bad*");
if (m->mask != ~((uint32)0))
(void) fprintf(stderr, " & %.8x", m->mask);
@ -130,7 +131,7 @@ ckfputs(str, fil)
/*VARARGS*/
void
#if __STDC__
#ifdef __STDC__
ckfprintf(FILE *f, const char *fmt, ...)
#else
ckfprintf(va_alist)
@ -138,7 +139,7 @@ ckfprintf(va_alist)
#endif
{
va_list va;
#if __STDC__
#ifdef __STDC__
va_start(va, fmt);
#else
FILE *f;
@ -158,7 +159,7 @@ ckfprintf(va_alist)
*/
/*VARARGS*/
void
#if __STDC__
#ifdef __STDC__
error(const char *f, ...)
#else
error(va_alist)
@ -166,7 +167,7 @@ error(va_alist)
#endif
{
va_list va;
#if __STDC__
#ifdef __STDC__
va_start(va, f);
#else
const char *f;
@ -185,7 +186,7 @@ error(va_alist)
/*VARARGS*/
void
#if __STDC__
#ifdef __STDC__
magwarn(const char *f, ...)
#else
magwarn(va_alist)
@ -193,7 +194,7 @@ magwarn(va_alist)
#endif
{
va_list va;
#if __STDC__
#ifdef __STDC__
va_start(va, f);
#else
const char *f;

View File

@ -1,5 +1,6 @@
/* $NetBSD: readelf.c,v 1.4 1998/09/20 15:27:16 christos Exp $ */
/* $NetBSD: readelf.c,v 1.5 1999/11/01 17:39:26 christos Exp $ */
#include "file.h"
#ifdef BUILTIN_ELF
#include <sys/types.h>
@ -7,55 +8,153 @@
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "readelf.h"
#include "file.h"
#include <sys/cdefs.h>
#ifndef lint
#if 0
FILE_RCSID("@(#)Id: readelf.c,v 1.9 1998/09/12 13:21:01 christos Exp ")
FILE_RCSID("@(#)Id: readelf.c,v 1.11 1999/10/31 22:23:04 christos Exp ")
#else
__RCSID("$NetBSD: readelf.c,v 1.4 1998/09/20 15:27:16 christos Exp $");
__RCSID("$NetBSD: readelf.c,v 1.5 1999/11/01 17:39:26 christos Exp $");
#endif
#endif
#ifdef ELFCORE
static void dophn_core __P((int, off_t, int, size_t, char *));
static void dophn_core __P((int, int, int, off_t, int, size_t));
#endif
static void dophn_exec __P((int, off_t, int, size_t, char *));
static void doshn __P((int, off_t, int, size_t, char *));
static void dophn_exec __P((int, int, int, off_t, int, size_t));
static void doshn __P((int, int, int, off_t, int, size_t));
static uint16_t getu16 __P((int, int));
static uint32_t getu32 __P((int, uint32_t));
static uint64_t getu64 __P((int, uint64_t));
static uint16_t
getu16(swap, value)
int swap;
uint16_t value;
{
union {
uint16_t ui;
char c[2];
} retval, tmpval;
if (swap) {
tmpval.ui = value;
retval.c[0] = tmpval.c[1];
retval.c[1] = tmpval.c[0];
return retval.ui;
} else
return value;
}
static uint32_t
getu32(swap, value)
int swap;
uint32_t value;
{
union {
uint32_t ui;
char c[4];
} retval, tmpval;
if (swap) {
tmpval.ui = value;
retval.c[0] = tmpval.c[3];
retval.c[1] = tmpval.c[2];
retval.c[2] = tmpval.c[1];
retval.c[3] = tmpval.c[0];
return retval.ui;
} else
return value;
}
static uint64_t
getu64(swap, value)
int swap;
uint64_t value;
{
union {
uint64_t ui;
char c[8];
} retval, tmpval;
if (swap) {
tmpval.ui = value;
retval.c[0] = tmpval.c[7];
retval.c[1] = tmpval.c[6];
retval.c[2] = tmpval.c[5];
retval.c[3] = tmpval.c[4];
retval.c[4] = tmpval.c[3];
retval.c[5] = tmpval.c[2];
retval.c[6] = tmpval.c[1];
retval.c[7] = tmpval.c[0];
return retval.ui;
} else
return value;
}
#define sh_addr (class == ELFCLASS32 \
? (void *) &sh32 \
: (void *) &sh64)
#define shs_type (class == ELFCLASS32 \
? getu32(swap, sh32.sh_type) \
: getu32(swap, sh64.sh_type))
#define ph_addr (class == ELFCLASS32 \
? (void *) &ph32 \
: (void *) &ph64)
#define ph_type (class == ELFCLASS32 \
? getu32(swap, ph32.p_type) \
: getu32(swap, ph64.p_type))
#define ph_offset (class == ELFCLASS32 \
? getu32(swap, ph32.p_offset) \
: getu64(swap, ph64.p_offset))
#define nh_size (class == ELFCLASS32 \
? sizeof *nh32 \
: sizeof *nh64)
#define nh_type (class == ELFCLASS32 \
? getu32(swap, nh32->n_type) \
: getu32(swap, nh64->n_type))
#define nh_namesz (class == ELFCLASS32 \
? getu32(swap, nh32->n_namesz) \
: getu32(swap, nh64->n_namesz))
#define nh_descsz (class == ELFCLASS32 \
? getu32(swap, nh32->n_descsz) \
: getu32(swap, nh64->n_descsz))
#define prpsoffsets(i) (class == ELFCLASS32 \
? prpsoffsets32[i] \
: prpsoffsets64[i])
static void
doshn(fd, off, num, size, buf)
doshn(class, swap, fd, off, num, size)
int class;
int swap;
int fd;
off_t off;
int num;
size_t size;
char *buf;
{
/*
* This works for both 32-bit and 64-bit ELF formats,
* because it looks only at the "sh_type" field, which is
* always 32 bits, and is preceded only by the "sh_name"
* field which is also always 32 bits, and because it uses
* the shdr size from the ELF header rather than using
* the size of an "Elf32_Shdr".
*/
Elf32_Shdr *sh = (Elf32_Shdr *) buf;
Elf32_Shdr sh32;
Elf64_Shdr sh64;
if (lseek(fd, off, SEEK_SET) == -1)
error("lseek failed (%s).\n", strerror(errno));
for ( ; num; num--) {
if (read(fd, buf, size) == -1)
if (read(fd, sh_addr, size) == -1)
error("read failed (%s).\n", strerror(errno));
if (sh->sh_type == SHT_SYMTAB) {
if (shs_type == SHT_SYMTAB /* || shs_type == SHT_DYNSYM */) {
(void) printf (", not stripped");
return;
}
@ -69,15 +168,16 @@ doshn(fd, off, num, size, buf)
* otherwise it's statically linked.
*/
static void
dophn_exec(fd, off, num, size, buf)
dophn_exec(class, swap, fd, off, num, size)
int class;
int swap;
int fd;
off_t off;
int num;
size_t size;
char *buf;
{
/* I am not sure if this works for 64 bit elf formats */
Elf32_Phdr *ph = (Elf32_Phdr *) buf;
Elf32_Phdr ph32;
Elf64_Phdr ph64;
char *linking_style = "statically";
char *shared_libraries = "";
@ -85,10 +185,10 @@ dophn_exec(fd, off, num, size, buf)
error("lseek failed (%s).\n", strerror(errno));
for ( ; num; num--) {
if (read(fd, buf, size) == -1)
if (read(fd, ph_addr, size) == -1)
error("read failed (%s).\n", strerror(errno));
switch (ph->p_type) {
switch (ph_type) {
case PT_DYNAMIC:
linking_style = "dynamically";
break;
@ -101,12 +201,19 @@ dophn_exec(fd, off, num, size, buf)
}
#ifdef ELFCORE
size_t prpsoffsets[] = {
size_t prpsoffsets32[] = {
84, /* SunOS 5.x */
32, /* Linux */
};
#define NOFFSETS (sizeof prpsoffsets / sizeof prpsoffsets[0])
size_t prpsoffsets64[] = {
120, /* SunOS 5.x, 64-bit */
};
#define NOFFSETS32 (sizeof prpsoffsets32 / sizeof prpsoffsets32[0])
#define NOFFSETS64 (sizeof prpsoffsets64 / sizeof prpsoffsets64[0])
#define NOFFSETS (class == ELFCLASS32 ? NOFFSETS32 : NOFFSETS64)
/*
* Look through the program headers of an executable image, searching
@ -120,19 +227,18 @@ size_t prpsoffsets[] = {
* containing the start of the command line for that program.
*/
static void
dophn_core(fd, off, num, size, buf)
dophn_core(class, swap, fd, off, num, size)
int class;
int swap;
int fd;
off_t off;
int num;
size_t size;
char *buf;
{
/*
* This doesn't work for 64-bit ELF, as the "p_offset" field is
* 64 bits in 64-bit ELF.
*/
Elf32_Phdr *ph = (Elf32_Phdr *) buf;
Elf32_Nhdr *nh;
Elf32_Phdr ph32;
Elf32_Nhdr *nh32;
Elf64_Phdr ph64;
Elf64_Nhdr *nh64;
size_t offset, noffset, reloffset;
unsigned char c;
int i, j;
@ -142,12 +248,12 @@ dophn_core(fd, off, num, size, buf)
for ( ; num; num--) {
if (lseek(fd, off, SEEK_SET) == -1)
error("lseek failed (%s).\n", strerror(errno));
if (read(fd, buf, size) == -1)
if (read(fd, ph_addr, size) == -1)
error("read failed (%s).\n", strerror(errno));
off += size;
if (ph->p_type != PT_NOTE)
if (ph_type != PT_NOTE)
continue;
if (lseek(fd, ph->p_offset, SEEK_SET) == -1)
if (lseek(fd, (off_t) ph_offset, SEEK_SET) == -1)
error("lseek failed (%s).\n", strerror(errno));
bufsize = read(fd, nbuf, BUFSIZ);
if (bufsize == -1)
@ -156,17 +262,20 @@ dophn_core(fd, off, num, size, buf)
for (;;) {
if (offset >= bufsize)
break;
nh = (Elf32_Nhdr *)&nbuf[offset];
offset += sizeof *nh;
if (class == ELFCLASS32)
nh32 = (Elf32_Nhdr *)&nbuf[offset];
else
nh64 = (Elf64_Nhdr *)&nbuf[offset];
offset += nh_size;
/*
* If this note isn't an NT_PRPSINFO note, it's
* not what we're looking for.
*/
if (nh->n_type != NT_PRPSINFO) {
offset += nh->n_namesz;
if (nh_type != NT_PRPSINFO) {
offset += nh_namesz;
offset = ((offset + 3)/4)*4;
offset += nh->n_descsz;
offset += nh_descsz;
offset = ((offset + 3)/4)*4;
continue;
}
@ -174,16 +283,16 @@ dophn_core(fd, off, num, size, buf)
/*
* Make sure this note has the name "CORE".
*/
if (offset + nh->n_namesz >= bufsize) {
if (offset + nh_namesz >= bufsize) {
/*
* We're past the end of the buffer.
*/
break;
}
if (nh->n_namesz != 5
if (nh_namesz != 5
|| strcmp(&nbuf[offset], "CORE") != 0)
continue;
offset += nh->n_namesz;
offset += nh_namesz;
offset = ((offset + 3)/4)*4;
/*
@ -197,7 +306,7 @@ dophn_core(fd, off, num, size, buf)
* it.
*/
for (i = 0; i < NOFFSETS; i++) {
reloffset = prpsoffsets[i];
reloffset = prpsoffsets(i);
noffset = offset + reloffset;
for (j = 0; j < 16;
j++, noffset++, reloffset++) {
@ -215,7 +324,7 @@ dophn_core(fd, off, num, size, buf)
* are, this obviously isn't
* the right offset.
*/
if (reloffset >= nh->n_descsz)
if (reloffset >= nh_descsz)
goto tryanother;
c = nbuf[noffset];
@ -227,13 +336,13 @@ dophn_core(fd, off, num, size, buf)
* Well, that worked.
*/
printf(", from '%.16s'",
&nbuf[offset + prpsoffsets[i]]);
&nbuf[offset + prpsoffsets(i)]);
return;
tryanother:
;
}
offset += nh->n_descsz;
offset += nh_descsz;
offset = ((offset + 3)/4)*4;
}
}
@ -243,13 +352,15 @@ dophn_core(fd, off, num, size, buf)
void
tryelf(fd, buf, nbytes)
int fd;
char *buf;
unsigned char *buf;
int nbytes;
{
union {
int32 l;
char c[sizeof (int32)];
} u;
int class;
int swap;
/*
* ELF executables have multiple section headers in arbitrary
@ -263,7 +374,9 @@ tryelf(fd, buf, nbytes)
return;
if (buf[4] == ELFCLASS32) {
class = buf[4];
if (class == ELFCLASS32) {
Elf32_Ehdr elfhdr;
if (nbytes <= sizeof (Elf32_Ehdr))
return;
@ -271,36 +384,36 @@ tryelf(fd, buf, nbytes)
u.l = 1;
(void) memcpy(&elfhdr, buf, sizeof elfhdr);
/*
* If the system byteorder does not equal the
* object byteorder then don't test.
* XXX - we could conceivably fix up the "dophn_XXX()" and
* "doshn()" routines to extract stuff in the right
* byte order....
*/
if ((u.c[sizeof(long) - 1] + 1) == elfhdr.e_ident[5]) {
if (elfhdr.e_type == ET_CORE)
swap = (u.c[sizeof(long) - 1] + 1) != elfhdr.e_ident[5];
if (getu16(swap, elfhdr.e_type) == ET_CORE)
#ifdef ELFCORE
dophn_core(fd, elfhdr.e_phoff, elfhdr.e_phnum,
elfhdr.e_phentsize, buf);
dophn_core(class, swap,
fd,
getu32(swap, elfhdr.e_phoff),
getu16(swap, elfhdr.e_phnum),
getu16(swap, elfhdr.e_phentsize));
#else
;
;
#endif
else {
if (elfhdr.e_type == ET_EXEC) {
dophn_exec(fd,
elfhdr.e_phoff,
elfhdr.e_phnum,
elfhdr.e_phentsize, buf);
}
doshn(fd, elfhdr.e_shoff, elfhdr.e_shnum,
elfhdr.e_shentsize, buf);
else {
if (getu16(swap, elfhdr.e_type) == ET_EXEC) {
dophn_exec(class, swap,
fd,
getu32(swap, elfhdr.e_phoff),
getu16(swap, elfhdr.e_phnum),
getu16(swap, elfhdr.e_phentsize));
}
doshn(class, swap,
fd,
getu32(swap, elfhdr.e_shoff),
getu16(swap, elfhdr.e_shnum),
getu16(swap, elfhdr.e_shentsize));
}
return;
}
if (buf[4] == ELFCLASS64) {
if (class == ELFCLASS64) {
Elf64_Ehdr elfhdr;
if (nbytes <= sizeof (Elf64_Ehdr))
return;
@ -308,49 +421,44 @@ tryelf(fd, buf, nbytes)
u.l = 1;
(void) memcpy(&elfhdr, buf, sizeof elfhdr);
swap = (u.c[sizeof(long) - 1] + 1) != elfhdr.e_ident[5];
/*
* If the system byteorder does not equal the
* object byteorder then don't test.
* XXX - we could conceivably fix up the "dophn_XXX()" and
* "doshn()" routines to extract stuff in the right
* byte order....
*/
if ((u.c[sizeof(long) - 1] + 1) == elfhdr.e_ident[5]) {
if (elfhdr.e_type == ET_CORE)
if (getu16(swap, elfhdr.e_type) == ET_CORE)
#ifdef ELFCORE
dophn_core(fd,
#ifndef __GNUC__
elfhdr.e_phoff[1],
dophn_core(class, swap,
fd,
#ifdef USE_ARRAY_FOR_64BIT_TYPES
getu32(swap, elfhdr.e_phoff[1]),
#else
elfhdr.e_phoff,
getu64(swap, elfhdr.e_phoff),
#endif
elfhdr.e_phnum,
elfhdr.e_phentsize, buf);
getu16(swap, elfhdr.e_phnum),
getu16(swap, elfhdr.e_phentsize));
#else
;
;
#endif
else
{
if (elfhdr.e_type == ET_EXEC) {
dophn_exec(fd,
#ifndef __GNUC__
elfhdr.e_phoff[1],
else
{
if (getu16(swap, elfhdr.e_type) == ET_EXEC) {
dophn_exec(class, swap,
fd,
#ifdef USE_ARRAY_FOR_64BIT_TYPES
getu32(swap, elfhdr.e_phoff[1]),
#else
elfhdr.e_phoff,
getu64(swap, elfhdr.e_phoff),
#endif
elfhdr.e_phnum,
elfhdr.e_phentsize, buf);
}
doshn(fd,
#ifndef __GNUC__
elfhdr.e_shoff[1],
#else
elfhdr.e_shoff,
#endif
elfhdr.e_shnum,
elfhdr.e_shentsize, buf);
getu16(swap, elfhdr.e_phnum),
getu16(swap, elfhdr.e_phentsize));
}
doshn(class, swap,
fd,
#ifdef USE_ARRAY_FOR_64BIT_TYPES
getu32(swap, elfhdr.e_shoff[1]),
#else
getu64(swap, elfhdr.e_shoff),
#endif
getu16(swap, elfhdr.e_shnum),
getu16(swap, elfhdr.e_shentsize));
}
return;
}

View File

@ -1,8 +1,8 @@
/* $NetBSD: readelf.h,v 1.4 1998/09/20 15:27:16 christos Exp $ */
/* $NetBSD: readelf.h,v 1.5 1999/11/01 17:39:27 christos Exp $ */
/*
* readelf.h
* @(#)Id: readelf.h,v 1.6 1998/09/12 13:21:01 christos Exp
* @(#)Id: readelf.h,v 1.7 1999/02/14 17:16:11 christos Exp
*
* Provide elf data structures for non-elf machines, allowing file
* non-elf hosts to determine if an elf binary is stripped.
@ -11,23 +11,25 @@
#ifndef __fake_elf_h__
#define __fake_elf_h__
typedef unsigned int Elf32_Addr;
typedef unsigned int Elf32_Off;
typedef unsigned short Elf32_Half;
typedef unsigned int Elf32_Word;
typedef unsigned char Elf32_Char;
typedef uint32_t Elf32_Addr;
typedef uint32_t Elf32_Off;
typedef uint16_t Elf32_Half;
typedef uint32_t Elf32_Word;
typedef uint8_t Elf32_Char;
#ifdef __GNUC__
typedef unsigned long long Elf64_Addr;
typedef unsigned long long Elf64_Off;
#if SIZEOF_UINT64_T != 8
#define USE_ARRAY_FOR_64BIT_TYPES
typedef uint32_t Elf64_Addr[2];
typedef uint32_t Elf64_Off[2];
typedef uint32_t Elf64_Xword[2];
#else
/* XXX: We need 64 bit numbers here */
typedef unsigned int Elf64_Addr[2];
typedef unsigned int Elf64_Off[2];
typedef uint64_t Elf64_Addr;
typedef uint64_t Elf64_Off;
typedef uint64_t Elf64_Xword;
#endif
typedef unsigned short Elf64_Half;
typedef unsigned int Elf64_Word;
typedef unsigned char Elf64_Char;
typedef uint16_t Elf64_Half;
typedef uint32_t Elf64_Word;
typedef uint8_t Elf64_Char;
#define EI_NIDENT 16
@ -72,6 +74,7 @@ typedef struct {
/* sh_type */
#define SHT_SYMTAB 2
#define SHT_NOTE 7
#define SHT_DYNSYM 11
/* elf type */
#define ELFDATANONE 0 /* e_ident[EI_DATA] */
@ -113,6 +116,17 @@ typedef struct {
Elf32_Word p_align;
} Elf32_Phdr;
typedef struct {
Elf64_Word p_type;
Elf64_Word p_flags;
Elf64_Off p_offset;
Elf64_Addr p_vaddr;
Elf64_Addr p_paddr;
Elf64_Xword p_filesz;
Elf64_Xword p_memsz;
Elf64_Xword p_align;
} Elf64_Phdr;
#define PT_NULL 0 /* p_type */
#define PT_LOAD 1
#define PT_DYNAMIC 2
@ -156,9 +170,9 @@ typedef struct {
/* Note header in a PT_NOTE section */
typedef struct elf_note {
Elf32_Word n_namesz; /* Name size */
Elf32_Word n_descsz; /* Content size */
Elf32_Word n_type; /* Content type */
Elf32_Word n_namesz; /* Name size */
Elf32_Word n_descsz; /* Content size */
Elf32_Word n_type; /* Content type */
} Elf32_Nhdr;
typedef struct {

View File

@ -1,4 +1,4 @@
/* $NetBSD: softmagic.c,v 1.16 1998/09/20 15:27:17 christos Exp $ */
/* $NetBSD: softmagic.c,v 1.17 1999/11/01 17:39:27 christos Exp $ */
/*
* softmagic - interpret variable magic from MAGIC
@ -33,9 +33,6 @@
#include <time.h>
#include <sys/types.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "file.h"
#include <sys/cdefs.h>
@ -43,7 +40,7 @@
#if 0
FILE_RCSID("@(#)Id: softmagic.c,v 1.38 1998/09/12 13:21:01 christos Exp ")
#else
__RCSID("$NetBSD: softmagic.c,v 1.16 1998/09/20 15:27:17 christos Exp $");
__RCSID("$NetBSD: softmagic.c,v 1.17 1999/11/01 17:39:27 christos Exp $");
#endif
#endif /* lint */

View File

@ -1,4 +1,4 @@
/* $NetBSD: tar.h,v 1.7 1998/09/20 15:27:17 christos Exp $ */
/* $NetBSD: tar.h,v 1.8 1999/11/01 17:39:27 christos Exp $ */
/*
* Header file for public domain tar (tape archive) program.
@ -7,7 +7,7 @@
*
* Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
*
* Id: tar.h,v 1.4 1998/06/27 13:57:23 christos Exp # checkin only
* Id: tar.h,v 1.5 1999/01/13 15:44:10 christos Exp # checkin only
*/
/*