summaryrefslogtreecommitdiffstats
path: root/usr.bin/file
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/file')
-rw-r--r--usr.bin/file/Magdir/freebsd16
-rw-r--r--usr.bin/file/Makefile147
-rw-r--r--usr.bin/file/file.110
-rw-r--r--usr.bin/file/magic.54
4 files changed, 46 insertions, 131 deletions
diff --git a/usr.bin/file/Magdir/freebsd b/usr.bin/file/Magdir/freebsd
new file mode 100644
index 0000000..28ad615
--- /dev/null
+++ b/usr.bin/file/Magdir/freebsd
@@ -0,0 +1,16 @@
+# the following are for 386BSD/FreeBSD
+
+0 lelong 0410 pure executable
+0 lelong 0413 demand paged executable
+0 lelong&077777777 041400314 FreeBSD/i386 demand paged
+>3 byte &0x80
+>>20 lelong <4096 shared library
+>>20 lelong =4096 dynamically linked executable
+>>20 lelong >4096 dynamically linked executable
+>3 byte ^0x80 executable
+>16 lelong >0 not stripped
+
+# This covers object files, and is better than "PDP-11 executable"
+0 lelong 000000407 impure format
+>16 lelong >0 not stripped
+
diff --git a/usr.bin/file/Makefile b/usr.bin/file/Makefile
index d59f490..54c7483 100644
--- a/usr.bin/file/Makefile
+++ b/usr.bin/file/Makefile
@@ -21,139 +21,38 @@
# ever read sources, credits must appear in the documentation.
#
# 4. This notice may not be removed or altered.
-VERSION = 3.14
-SHELL = /bin/sh
-#MAGIC = /etc/magic
-MAGIC = /usr/local/etc/magic
-DEFS = -DMAGIC='"$(MAGIC)"' # -Dvoid=int
-CC = cc
-COPTS = -O -g # newer compilers allow both; else drop -O
-# For truly antique environments, use this for (dummy) include files:
-COPTS = -O # -Ilocalinc
-CFLAGS = $(COPTS) $(DEFS)
-LDFLAGS = $(COPTS) # -Bstatic # older gdb couldn't handle shared libs
-SHAR = bundle
-OFILE = /usr/bin/file # old or distributed version, for comparison
-# Where new binary lives; typically /usr/local (BSD), /usr/lbin (USG).
-BINDIR = /usr/local/bin
-# For installing our man pages;
-# MANCxxx is manual section for Commands, MANFxxx is section for file formats.
-# MANxDIR is directory names; MANxEXT is the filename extention. Usual values:
-# Variable V7 4BSD Sys V
-# MANCDIR /usr/man/man1 /usr/man/man1 /usr/man/u_man/man1
-# MANFDIR /usr/man/man5 /usr/man/man5 /usr/man/u_man/man4
-# MANCEXT 1 1 1
-# MANFEXT 5 5 4
-# --- possible alternative for 4BSD ---
-# MANCDIR /usr/local/man/man1
-# MANCEXT 1
-# or
-# MANCDIR /usr/man/manl
-# MANCEXT l
-# --- possible alternative for USG ---
-# MANCDIR /usr/man/local/man1
-# MANCEXT 1
-
-MANCDIR = /usr/local/man/man1
-MANCEXT = 1
-MANFDIR = /usr/local/man/man4
-MANFEXT = 4
-
-# There are no system-dependant configuration options (except maybe CFLAGS).
-# Uncomment any of these that is missing from your "standard" library.
-LOCALSRCS = # localsrc/getopt.c localsrc/strtol.c \
-# localsrc/strtok.c localsrc/strchr.c
-LOCALOBJS = # localsrc/getopt.o localsrc/strtol.o \
-# localsrc/strtok.o localsrc/strchr.o
-# These are not compiled in unless you use -Ilocalinc, but
-# are not commented out as "make dist" &c use them.
-LOCALINC = # localinc/*.h localinc/sys/*.h
-
-SRCS = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
- compress.c is_tar.c \
- print.c $(LOCALSRCS) $(LOCALINC)
-OBJS = file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \
- compress.o is_tar.o \
- print.o $(LOCALOBJS)
-
-ALLSRC = LEGAL.NOTICE README MAINT PORTING $(SRCS) *.h \
- Makefile file.man magic.man
-ALLMAGIC = Magdir/Makefile Magdir/Localstuff Magdir/Header Magdir/[a-z]*
-
-all: file magic file.${MANCEXT} magic.${MANFEXT}
-
-TESTFILES = * tst/*
-try: all $(OFILE)
- cd tst; $(MAKE)
- time $(OFILE) $(TESTFILES) >/tmp/t1 # can't use ./magic
- time ./file -m ./magic $(TESTFILES) >/tmp/t2
- -diff -b /tmp/t[12]
- what ./file >lastnocore
-
-file: $(OBJS)
- $(CC) $(CFLAGS) $(OBJS) -o $@
-lint: $(SRCS)
- lint -ha $(DEFS) $(SRCS) | tee $@
-magic: Magdir
-# Magdir/Makefile's "install" mv's magic to here for testing.
- cd Magdir; $(MAKE) install
-
-ascmagic.o: names.h
-
-compress.o apprentice.o ascmagic.o file.o fsmagic.o print.o softmagic.o: file.h
+#
+# Hacked and dismembered for bmake (Geoff Rehmet).
+MAGIC= /etc/magic
+MAGICOWN= bin
+MAGICGRP= bin
+MAGICMODE= 444
-install: file magic
- cp file $(BINDIR)/file
- cp magic $(MAGIC)
-install.man: file.${MANCEXT} magic.${MANFEXT}
- cp file.${MANCEXT} $(MANCDIR)/file.$(MANCEXT)
- cp magic.${MANFEXT} $(MANFDIR)/magic.$(MANFEXT)
+CFLAGS+= -DMAGIC='"$(MAGIC)"'
-clean:
- rm -f *.o core file magic lint dist.* MANIFEST \
- magic.${MANFEXT} file.${MANCEXT}
-clobber:
- cd tst; $(MAKE) clean
+PROG= file
+SRCS= file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
+ compress.c is_tar.c print.c
+MAN1= file.1
+MAN5= magic.5
-magic.${MANFEXT} : Makefile magic.man
- @rm -f $@
- sed -e s@__SECTION__@${MANFEXT}@g \
- -e s@__MAGIC__@${MAGIC}@g magic.man > $@
+CLEANFILES+= magic
-file.${MANCEXT} : Makefile file.man
- @rm -f $@
- sed -e s@__SECTION__@${MANCEXT}@g \
- -e s@__MAGIC__@${MAGIC}@g file.man > $@
+MAGFILES= $(.CURDIR)/Magdir/Header\
+ $(.CURDIR)/Magdir/Localstuff\
+ $(.CURDIR)/Magdir/[a-z]*
-send: dist
- ftp ftp.cs
-dist: dist.src dist.magic
- @echo Now check this patchlevel!
- ident patchlevel.h
+all: file magic
-dist.src: $(ALLSRC) MANIFEST
-# Some versions of shar can't handle a single file from
-# a subdirectory, so we manually insert mkdir as needed.
-# The point is to exclude all the generable targets in tst.
- (echo mkdir localinc localinc/sys localsrc tst; \
- $(SHAR) $(ALLSRC) MANIFEST) > $@
+magic: $(MAGFILES)
+ cat $(MAGFILES) > $(.TARGET)
-rcsdiff: $(ALLSRC)
- rcsdiff -q RCS/*
+afterinstall:
+ install -c -o $(MAGICOWN) -g $(MAGICGRP) -m $(MAGICMODE) magic \
+ $(DESTDIR)$(MAGIC)
-MANIFEST: $(ALLSRC)
- ident $(ALLSRC) > MANIFEST
-dist.magic: Magdir
-# As above, but to exclude Magdir/RCS from being shipped.
- (echo mkdir Magdir; $(SHAR) $(ALLMAGIC)) >$@
+.include <bsd.prog.mk>
-tar: $(ALLSRC) $(ALLMAGIC)
- -rm -fr file-${VERSION}
- -mkdir file-${VERSION} file-${VERSION}/Magdir
- ln $(ALLSRC) file-${VERSION}
- ln ${ALLMAGIC} file-${VERSION}/Magdir
- tar cvf file-${VERSION}.tar file-${VERSION}
- -rm -fr file-${VERSION}
diff --git a/usr.bin/file/file.1 b/usr.bin/file/file.1
index c10b221..555261f 100644
--- a/usr.bin/file/file.1
+++ b/usr.bin/file/file.1
@@ -43,7 +43,7 @@ meaning anything else (data is usually `binary' or non-printable).
Exceptions are well-known file formats (core files, tar archives)
that are known to contain binary data.
When modifying the file
-.I __MAGIC__
+.I /etc/magic
or the program itself,
.B "preserve these keywords" .
People depend on knowing that all the readable files in a directory
@@ -79,7 +79,7 @@ The concept of `magic number' has been applied by extension to data files.
Any file with some invariant identifier at a small fixed
offset into the file can usually be described in this way.
The information in these files is read from the magic file
-.I __MAGIC__.
+.I /etc/magic.
.PP
If an argument appears to be an
.SM ASCII
@@ -135,10 +135,10 @@ The
option causes symlinks to be followed, as the like-named option in
.IR ls (1).
.SH FILES
-.I __MAGIC__
+.I /etc/magic
\- default list of magic numbers
.SH SEE ALSO
-.IR magic (__SECTION__)
+.IR magic (5)
\- description of magic file format.
.br
.IR Strings (1), " od" (1)
@@ -197,7 +197,7 @@ If your old
command uses a magic file,
keep the old magic file around for comparison purposes
(rename it to
-.IR __MAGIC__.orig ).
+.IR /etc/magic.orig ).
.SH HISTORY
There has been a
.I file
diff --git a/usr.bin/file/magic.5 b/usr.bin/file/magic.5
index 7c2788e..6c6f3ef 100644
--- a/usr.bin/file/magic.5
+++ b/usr.bin/file/magic.5
@@ -1,4 +1,4 @@
-.TH MAGIC __SECTION__ "Public Domain"
+.TH MAGIC 5 "Public Domain"
.\" install as magic.4 on USG, magic.5 on V7 or Berkeley systems.
.SH NAME
magic \- file command's magic number file
@@ -10,7 +10,7 @@ among other tests,
a test for whether the file begins with a certain
.IR "magic number" .
The file
-.B __MAGIC__
+.B /etc/magic
specifies what magic numbers are to be tested for,
what message to print if a particular magic number is found,
and additional information to extract from the file.
OpenPOWER on IntegriCloud