Merge from head

This commit is contained in:
Baptiste Daroussin 2015-10-01 09:36:43 +00:00
commit 5a2b666ce5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/release-pkg/; revision=288441
1213 changed files with 34741 additions and 18521 deletions

View file

@ -244,9 +244,9 @@ cleanworld:
# Handle the user-driven targets, using the source relative mk files.
#
.if empty(.MAKEFLAGS:M-n)
.if !(!empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n")
# skip this for -n to avoid changing previous behavior of
# 'make -n buildworld' etc.
# 'make -n buildworld' etc. Using -n -n will run it.
${TGTS}: .MAKE
tinderbox toolchains kernel-toolchains: .MAKE
.endif
@ -382,17 +382,8 @@ kernel-toolchains:
# existing system is.
#
.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
# XXX Add arm64 to universe only if we have an external binutils installed.
# It does not build with the in-tree linker.
.if exists(/usr/local/aarch64-freebsd/bin/ld)
UNIVERSE_arm64=arm64
.elif empty(${TARGETS})
universe: universe_arm64_skip
universe_epilogue: universe_arm64_skip
universe_arm64_skip: universe_prologue
@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
.endif
TARGETS?=amd64 arm ${UNIVERSE_arm64} i386 mips pc98 powerpc sparc64
TARGETS?=amd64 arm arm64 i386 mips pc98 powerpc sparc64
_UNIVERSE_TARGETS= ${TARGETS}
TARGET_ARCHES_arm?= arm armeb armv6 armv6hf
TARGET_ARCHES_arm64?= aarch64
TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32
@ -402,6 +393,16 @@ TARGET_ARCHES_pc98?= i386
TARGET_ARCHES_${target}?= ${target}
.endfor
# XXX Add arm64 to universe only if we have an external binutils installed.
# It does not build with the in-tree linker.
.if !exists(/usr/local/aarch64-freebsd/bin/ld) && empty(${TARGETS})
_UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:Narm64}
universe: universe_arm64_skip
universe_epilogue: universe_arm64_skip
universe_arm64_skip: universe_prologue
@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
.endif
.if defined(UNIVERSE_TARGET)
MAKE_JUST_WORLDS= YES
.else
@ -433,7 +434,7 @@ universe_prologue:
.if defined(DOING_TINDERBOX)
@rm -f ${FAILFILE}
.endif
.for target in ${TARGETS}
.for target in ${_UNIVERSE_TARGETS}
universe: universe_${target}
universe_epilogue: universe_${target}
universe_${target}: universe_${target}_prologue

View file

@ -272,9 +272,8 @@ BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
WORLDTMP=${WORLDTMP} \
VERSION="${VERSION}" \
MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
DESTDIR= \
# need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
BSARGS= DESTDIR= \
BOOTSTRAPPING=${OSRELDATE} \
SSP_CFLAGS= \
MK_HTML=no NO_LINT=yes MK_MAN=no \
@ -282,7 +281,11 @@ BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
MK_LLDB=no MK_TESTS=no \
MK_INCLUDES=yes
MK_INCLUDES=yes
BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
${BSARGS}
# build-tools stage
TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
@ -345,6 +348,7 @@ CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
# support the target architecture), provide a default cross-binutils prefix.
# This allows aarch64 builds, for example, to automatically use the
# aarch64-binutils port or package.
.if !make(showconfig)
.if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
!defined(CROSS_BINUTILS_PREFIX)
CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
@ -352,6 +356,7 @@ CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
.error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
.endif
.endif
.endif
XCOMPILERS= CC CXX CPP
.for COMPILER in ${XCOMPILERS}
@ -1377,12 +1382,12 @@ update:
# ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
.if ${BOOTSTRAPPING} < 1100006
_elftoolchain_libs= lib/libelf lib/libdwarf
_elftoolchain_libs= lib/libelf lib/libdwarf
.endif
legacy:
.if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
@echo "ERROR: Source upgrades from versions prior to 8.0 not supported."; \
@echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
false
.endif
.for _tool in tools/build ${_elftoolchain_libs}
@ -1401,7 +1406,7 @@ legacy:
# binaries is usually quite narrow. Bootstrap tools use the host's compiler and
# libraries, augmented by -legacy.
#
_bt= _bootstrap-tools
_bt= _bootstrap-tools
.if ${MK_GAMES} != "no"
_strfile= games/fortune/strfile
@ -1479,20 +1484,6 @@ ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/c
${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
.endif
# ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
# dtrace tools are required for older bootstrap env and cross-build
# pre libdwarf
.if ${BOOTSTRAPPING} < 1100006 || (${MACHINE} != ${TARGET} || \
${MACHINE_ARCH} != ${TARGET_ARCH})
.if ${MK_CDDL} != "no"
_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf cddl/usr.bin/ctfconvert \
cddl/usr.bin/ctfmerge
${_bt}-cddl/usr.bin/ctfconvert: ${_bt}-cddl/lib/libctf
${_bt}-cddl/usr.bin/ctfmerge: ${_bt}-cddl/lib/libctf
.endif
.endif
# Default to building the GPL DTC, but build the BSDL one if users explicitly
# request it.
_dtc= usr.bin/dtc
@ -1532,7 +1523,6 @@ bootstrap-tools: .PHONY
.for _tool in \
${_clang_tblgen} \
${_kerberos5_bootstrap_tools} \
${_dtrace_tools} \
${_strfile} \
${_gperf} \
${_groff} \
@ -1628,6 +1618,13 @@ _btxld= usr.sbin/btxld
.endif
.endif
# Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
# resulting from missing bug fixes or ELF Toolchain updates.
.if ${MK_CDDL} != "no"
_dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
cddl/usr.bin/ctfmerge
.endif
# If we're given an XAS, don't build binutils.
.if ${XAS:M/*} == ""
.if ${MK_BINUTILS_BOOTSTRAP} != "no"
@ -1671,6 +1668,7 @@ cross-tools: .MAKE
${_clang} \
${_binutils} \
${_elftctools} \
${_dtrace_tools} \
${_cc} \
${_btxld} \
${_crunchide} \

View file

@ -38,6 +38,14 @@
# xargs -n1 | sort | uniq -d;
# done
# 20150928: unused sgsmsg utility is removed
OLD_FILES+=usr/bin/sgsmsg
# 20150926: remove links to removed/unimplemented mbuf(9) macros
OLD_FILES+=usr/share/man/man9/MEXT_ADD_REF.9.gz
OLD_FILES+=usr/share/man/man9/MEXTFREE.9.gz
OLD_FILES+=usr/share/man/man9/MEXT_IS_REF.9.gz
OLD_FILES+=usr/share/man/man9/MEXT_REM_REF.9.gz
OLD_FILES+=usr/share/man/man9/MFREE.9.gz
# 20150818: *allocm() are gone in jemalloc 4.0.0
OLD_FILES+=usr/share/man/man3/allocm.3.gz
OLD_FILES+=usr/share/man/man3/dallocm.3.gz
@ -483,8 +491,6 @@ OLD_FILES+=usr/share/man/man9/splstatclock.9.gz
OLD_FILES+=usr/share/man/man9/spltty.9.gz
OLD_FILES+=usr/share/man/man9/splvm.9.gz
OLD_FILES+=usr/share/man/man9/splx.9.gz
# 20150122: callout changes reverted
OLD_FILES+=usr/share/man/man9/callout_drain_async.9.gz
# 20150118: toeplitz.c moved from netinet to net
OLD_FILES+=usr/include/netinet/toeplitz.h
# 20150118: new clang import which bumps version from 3.5.0 to 3.5.1.
@ -7236,6 +7242,12 @@ OLD_LIBS+=usr/lib/libposix1e.so.2
OLD_LIBS+=usr/lib/libskey.so.2
OLD_LIBS+=usr/lib/libusbhid.so.0
OLD_LIBS+=usr/lib/libvgl.so.2
# 20030218: OpenSSL 0.9.7 import
OLD_FILES+=usr/include/des.h
OLD_FILES+=usr/lib/libdes.a
OLD_FILES+=usr/lib/libdes.so
OLD_LIBS+=usr/lib/libdes.so.3
OLD_FILES+=usr/lib/libdes_p.a
# 200302XX
OLD_LIBS+=usr/lib/libacl.so.3
OLD_LIBS+=usr/lib/libasn1.so.5
@ -7294,6 +7306,8 @@ OLD_LIBS+=usr/lib/libtermcap.so.2
OLD_LIBS+=usr/lib/libutil.so.2
OLD_LIBS+=usr/lib/libvgl.so.1
OLD_LIBS+=usr/lib/libwrap.so.2
# 19991216
OLD_FILES+=usr/sbin/xntpdc
# 199909XX
OLD_LIBS+=usr/lib/libc_r.so.3
# ???

View file

@ -31,6 +31,19 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
20150924:
Kernel debug files have been moved to /usr/lib/debug/boot/kernel/,
and renamed from .symbols to .debug. This reduces the size requirements
on the boot partition or file system and provides consistency with
userland debug files.
When using the supported kernel installation method the
/usr/lib/debug/boot/kernel directory will be renamed (to kernel.old)
as is done with /boot/kernel.
Developers wishing to maintain the historical behavior of installing
debug files in /boot/kernel/ can set KERN_DEBUGDIR="" in src.conf(5).
20150827:
The wireless drivers had undergone changes that remove the 'parent
interface' from the ifconfig -l output. The rc.d network scripts

View file

@ -13,4 +13,8 @@ CFLAGS+= -DCOLORLS
LIBADD+= termcapw
.endif
.if ${MK_TESTS} != "no"
SUBDIR+= tests
.endif
.include <bsd.prog.mk>

View file

@ -32,7 +32,7 @@
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
.\" $FreeBSD$
.\"
.Dd June 8, 2015
.Dd September 27, 2015
.Dt LS 1
.Os
.Sh NAME
@ -296,9 +296,9 @@ subsection below, except (if the long format is not also requested)
the directory totals are not output when the output is in a
single column, even if multi-column output is requested.
.It Fl t
Sort by descending time modified (most recently modified first). If two files
have the same modification timestamp, sort their names in ascending
lexicographical order.
Sort by descending time modified (most recently modified first).
If two files have the same modification timestamp, sort their names
in ascending lexicographical order.
The
.Fl r
option reverses both of these sort orders.
@ -320,7 +320,7 @@ or use the
option.
This causes
.Nm
to reverse the lexicographal sort order when sorting files with the
to reverse the lexicographical sort order when sorting files with the
same modification timestamp.
.It Fl u
Use time of last access,

11
bin/ls/tests/Makefile Normal file
View file

@ -0,0 +1,11 @@
# $FreeBSD$
TESTSDIR= ${TESTSBASE}/bin/ls
ATF_TESTS_SH+= ls_tests
# This seems like overkill, but the idea in mind is that all of the testcases
# should be runnable as !root
TEST_METADATA.ls_tests+= required_user="unprivileged"
TEST_METADATA.ls_tests+= required_files="/usr/bin/nc"
.include <bsd.test.mk>

359
bin/ls/tests/ls_tests.sh Executable file
View file

@ -0,0 +1,359 @@
#
# Copyright 2015 EMC Corp.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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.
#
# $FreeBSD$
#
create_test_dir()
{
[ -z "$ATF_TMPDIR" ] || return 0
export ATF_TMPDIR=$(pwd)
# XXX: need to nest this because of how kyua creates $TMPDIR; otherwise
# it will run into EPERM issues later
TEST_INPUTS_DIR="${ATF_TMPDIR}/test/inputs"
atf_check -e empty -s exit:0 mkdir -m 0777 -p $TEST_INPUTS_DIR
cd $TEST_INPUTS_DIR
}
create_test_inputs()
{
create_test_dir
atf_check -e empty -s exit:0 mkdir -m 0755 -p a/b
atf_check -e empty -s exit:0 ln -s a/b c
atf_check -e empty -s exit:0 touch d
atf_check -e empty -s exit:0 ln d e
atf_check -e empty -s exit:0 touch .f
atf_check -e empty -s exit:0 mkdir .g
atf_check -e empty -s exit:0 mkfifo h
atf_check -e ignore -s exit:0 dd if=/dev/zero of=i count=1000 bs=1
atf_check -e empty -s exit:0 \
sh -c "pid=${ATF_TMPDIR}/nc.pid; daemon -p \$pid nc -lU j; sleep 2; pkill -F \$pid"
atf_check -e empty -s exit:0 touch klmn
atf_check -e empty -s exit:0 touch opqr
atf_check -e empty -s exit:0 touch stuv
atf_check -e empty -s exit:0 touch wxyz
atf_check -e empty -s exit:0 touch 0b00000001
atf_check -e empty -s exit:0 touch 0b00000010
atf_check -e empty -s exit:0 touch 0b00000011
atf_check -e empty -s exit:0 touch 0b00000100
atf_check -e empty -s exit:0 touch 0b00000101
atf_check -e empty -s exit:0 touch 0b00000110
atf_check -e empty -s exit:0 touch 0b00000111
atf_check -e empty -s exit:0 touch 0b00001000
atf_check -e empty -s exit:0 touch 0b00001001
atf_check -e empty -s exit:0 touch 0b00001010
atf_check -e empty -s exit:0 touch 0b00001011
atf_check -e empty -s exit:0 touch 0b00001100
atf_check -e empty -s exit:0 touch 0b00001101
atf_check -e empty -s exit:0 touch 0b00001110
atf_check -e empty -s exit:0 touch 0b00001111
}
atf_test_case a_flag
a_flag_head()
{
atf_set "descr" "Verify -a support"
}
a_flag_body()
{
create_test_dir
# Make sure "." and ".." show up with -a
atf_check -e empty -o match:'\.[[:space:]]+\.\.' -s exit:0 ls -ax
create_test_inputs
WITH_a=$PWD/../with_a.out
WITHOUT_a=$PWD/../without_a.out
atf_check -e empty -o save:$WITH_a -s exit:0 ls -A
atf_check -e empty -o save:$WITHOUT_a -s exit:0 ls
echo "-A usage"
cat $WITH_a
echo "No -A usage"
cat $WITHOUT_a
for dot_path in '\.f' '\.g'; do
atf_check -e empty -o not-empty -s exit:0 grep "${dot_path}" \
$WITH_a
atf_check -e empty -o empty -s not-exit:0 grep "${dot_path}" \
$WITHOUT_a
done
}
atf_test_case A_flag
A_flag_head()
{
atf_set "descr" "Verify -A support with unprivileged users"
}
A_flag_body()
{
create_test_dir
atf_check -e empty -o empty -s exit:0 ls -A
create_test_inputs
WITH_A=$PWD/../with_A.out
WITHOUT_A=$PWD/../without_A.out
atf_check -e empty -o save:$WITH_A -s exit:0 ls -A
atf_check -e empty -o save:$WITHOUT_A -s exit:0 ls
echo "-A usage"
cat $WITH_A
echo "No -A usage"
cat $WITHOUT_A
for dot_path in '\.f' '\.g'; do
atf_check -e empty -o not-empty -s exit:0 grep "${dot_path}" \
$WITH_A
atf_check -e empty -o empty -s not-exit:0 grep "${dot_path}" \
$WITHOUT_A
done
}
atf_test_case A_flag_implied_when_root
A_flag_implied_when_root_head()
{
atf_set "descr" "Verify that -A is implied for root"
atf_set "require.user" "root"
}
A_flag_implied_when_root_body()
{
create_test_dir
atf_check -e empty -o empty -s exit:0 ls -A
create_test_inputs
WITH_EXPLICIT=$PWD/../with_explicit_A.out
WITH_IMPLIED=$PWD/../with_implied_A.out
atf_check -e empty -o save:$WITH_EXPLICIT -s exit:0 ls -A
atf_check -e empty -o save:$WITH_IMPLIED -s exit:0 ls
echo "Explicit -A usage"
cat $WITH_EXPLICIT
echo "Implicit -A usage"
cat $WITH_IMPLIED
atf_check_equal "$(cat $WITH_EXPLICIT)" "$(cat $WITH_IMPLIED)"
}
atf_test_case B_flag
B_flag_head()
{
atf_set "descr" "Verify that the output from ls -B prints out non-printable characters"
}
B_flag_body()
{
atf_skip "kyua report-jenkins doesn't properly escape non-printable chars: https://github.com/jmmv/kyua/issues/136"
atf_check -e empty -o empty -s exit:0 touch "$(printf "y\013z")"
atf_check -e empty -o match:'y\\013z' -s exit:0 ls -B
}
atf_test_case C_flag
C_flag_head()
{
atf_set "descr" "Verify that the output from ls -C is multi-column, sorted down"
}
C_flag_body()
{
create_test_inputs
WITH_C=$PWD/../with_C.out
atf_check -e empty -o save:$WITH_C -s exit:0 ls -C
echo "With -C usage"
cat $WITH_C
atf_check -e ignore -o not-empty -s exit:0 \
egrep "0b00000001[[:space:]]+0b00000111[[:space:]]+0b00001101[[:space:]]+e[[:space:]]+stuv" $WITH_C
atf_check -e ignore -o not-empty -s exit:0 \
egrep "0b00000010[[:space:]]+0b00001000[[:space:]]+0b00001110[[:space:]]+h[[:space:]]+wxyz" $WITH_C
}
atf_test_case I_flag
I_flag_head()
{
atf_set "descr" "Verify that the output from ls -I is the same as ls for an unprivileged user"
}
I_flag_body()
{
create_test_inputs
WITH_I=$PWD/../with_I.out
WITHOUT_I=$PWD/../without_I.out
atf_check -e empty -o save:$WITH_I -s exit:0 ls -I
atf_check -e empty -o save:$WITHOUT_I -s exit:0 ls
echo "Explicit -I usage"
cat $WITH_I
echo "No -I usage"
cat $WITHOUT_I
atf_check_equal "$(cat $WITH_I)" "$(cat $WITHOUT_I)"
}
atf_test_case I_flag_voids_implied_A_flag_when_root
I_flag_voids_implied_A_flag_when_root_head()
{
atf_set "descr" "Verify that -I voids out implied -A for root"
atf_set "require.user" "root"
}
I_flag_voids_implied_A_flag_when_root_body()
{
create_test_inputs
atf_check -o not-match:'\.f' -s exit:0 ls -I
atf_check -o not-match:'\.g' -s exit:0 ls -I
atf_check -o match:'\.f' -s exit:0 ls -A -I
atf_check -o match:'\.g' -s exit:0 ls -A -I
}
lcomma_flag_head()
{
atf_set "descr" "Verify that -l, prints out the size with , delimiters"
}
lcomma_flag_body()
{
create_test_inputs
atf_check \
-o match:'\-rw\-r\-\-r\-\-[[:space:]]+.+[[:space:]]+1,000[[:space:]]+.+i' \
env LC_ALL=en_US.ISO8859-1 ls -l, i
}
x_flag_head()
{
atf_set "descr" "Verify that -x prints out one item per line"
}
x_flag_body()
{
create_test_inputs
WITH_x=$PWD/../with_x.out
atf_check -e empty -o save:$WITH_x -s exit:0 ls -x
echo "With -x usage"
cat $WITH_x
atf_check -e ignore -o not-empty -s exit:0 \
egrep "a[[:space:]]+c[[:space:]]+d[[:space:]]+e[[:space:]]+h" $WITH_x
atf_check -e ignore -o not-empty -s exit:0 \
egrep "i[[:space:]]+j[[:space:]]+klmn[[:space:]]+opqr[[:space:]]+stuv" $WITH_x
}
1_flag_head()
{
atf_set "descr" "Verify that -1 prints out one item per line"
}
1_flag_body()
{
create_test_inputs
WITH_1=$PWD/../with_1.out
WITHOUT_1=$PWD/../without_1.out
atf_check -e empty -o save:$WITH_1 -s exit:0 ls -1
atf_check -e empty -o save:$WITHOUT_1 -s exit:0 \
sh -c 'for i in $(ls); do echo $i; done'
echo "Explicit -1 usage"
cat $WITH_1
echo "No -1 usage"
cat $WITHOUT_1
atf_check_equal "$(cat $WITH_1)" "$(cat $WITHOUT_1)"
}
atf_init_test_cases()
{
atf_add_test_case A_flag
atf_add_test_case A_flag_implied_when_root
atf_add_test_case B_flag
atf_add_test_case C_flag
#atf_add_test_case D_flag
#atf_add_test_case F_flag
#atf_add_test_case G_flag
#atf_add_test_case H_flag
atf_add_test_case I_flag
atf_add_test_case I_flag_voids_implied_A_flag_when_root
#atf_add_test_case L_flag
#atf_add_test_case P_flag
#atf_add_test_case R_flag
#atf_add_test_case S_flag
#atf_add_test_case T_flag
#atf_add_test_case U_flag
#atf_add_test_case W_flag
#atf_add_test_case Z_flag
atf_add_test_case a_flag
#atf_add_test_case b_flag
#atf_add_test_case c_flag
#atf_add_test_case d_flag
#atf_add_test_case f_flag
#atf_add_test_case g_flag
#atf_add_test_case h_flag
#atf_add_test_case i_flag
#atf_add_test_case k_flag
#atf_add_test_case l_flag
atf_add_test_case lcomma_flag
#atf_add_test_case m_flag
#atf_add_test_case n_flag
#atf_add_test_case o_flag
#atf_add_test_case p_flag
#atf_add_test_case q_flag
#atf_add_test_case r_flag
#atf_add_test_case s_flag
#atf_add_test_case t_flag
#atf_add_test_case u_flag
#atf_add_test_case w_flag
atf_add_test_case x_flag
#atf_add_test_case y_flag
atf_add_test_case 1_flag
}

View file

@ -11,6 +11,7 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libjail \
lib/libkvm \
lib/libutil \
lib/libxo \
lib/msun \

View file

@ -65,6 +65,7 @@ exportcmd -s export -s readonly
#exprcmd expr
falsecmd false
fgcmd -j fg
freebsd_wordexpcmd freebsd_wordexp
getoptscmd getopts
hashcmd hash
histcmd -h fc

View file

@ -1656,3 +1656,57 @@ wordexpcmd(int argc, char **argv)
outbin(argv[i], strlen(argv[i]) + 1, out1);
return (0);
}
/*
* Do most of the work for wordexp(3), new version.
*/
int
freebsd_wordexpcmd(int argc __unused, char **argv __unused)
{
struct arglist arglist;
union node *args, *n;
struct strlist *sp;
size_t count, len;
int ch;
int protected = 0;
int fd = -1;
while ((ch = nextopt("f:p")) != '\0') {
switch (ch) {
case 'f':
fd = number(shoptarg);
break;
case 'p':
protected = 1;
break;
}
}
if (*argptr != NULL)
error("wrong number of arguments");
if (fd < 0)
error("missing fd");
INTOFF;
setinputfd(fd, 1);
INTON;
args = parsewordexp();
popfile(); /* will also close fd */
if (protected)
for (n = args; n != NULL; n = n->narg.next) {
if (n->narg.backquote != NULL) {
outcslow('C', out1);
error("command substitution disabled");
}
}
outcslow(' ', out1);
arglist.lastp = &arglist.list;
for (n = args; n != NULL; n = n->narg.next)
expandarg(n, &arglist, EXP_FULL | EXP_TILDE);
*arglist.lastp = NULL;
for (sp = arglist.list, count = len = 0; sp; sp = sp->next)
count++, len += strlen(sp->text);
out1fmt("%016zx %016zx", count, len);
for (sp = arglist.list; sp; sp = sp->next)
outbin(sp->text, strlen(sp->text) + 1, out1);
return (0);
}

View file

@ -231,6 +231,39 @@ parsecmd(int interact)
}
/*
* Read and parse words for wordexp.
* Returns a list of NARG nodes; NULL if there are no words.
*/
union node *
parsewordexp(void)
{
union node *n, *first = NULL, **pnext;
int t;
/* This assumes the parser is not re-entered,
* which could happen if we add command substitution on PS1/PS2.
*/
parser_temp_free_all();
heredoclist = NULL;
tokpushback = 0;
checkkwd = 0;
doprompt = 0;
setprompt(0);
needprompt = 0;
pnext = &first;
while ((t = readtoken()) != TEOF) {
if (t != TWORD)
synexpect(TWORD);
n = makename();
*pnext = n;
pnext = &n->narg.next;
}
return first;
}
static union node *
list(int nlflag)
{

View file

@ -76,6 +76,7 @@ extern const char *const parsekwd[];
union node *parsecmd(int);
union node *parsewordexp(void);
void forcealias(void);
void fixredir(union node *, const char *, int);
int goodname(const char *);

View file

@ -0,0 +1,112 @@
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright (c) 2015, Joyent, Inc. All rights reserved.
#
err=/tmp/err.$$
ppriv -s A=basic,dtrace_user $$
#
# When we lack dtrace_kernel, we expect to not be able to get at kernel memory
# via any subroutine or other vector.
#
# trace(func((void *)&\`utsname)); }
/usr/sbin/dtrace -wq -Cs /dev/stdin 2> $err <<EOF
#define FAIL \
printf("able to read kernel memory via %s!\n", badsubr); \
exit(2);
#define CANTREAD1(func) \
BEGIN { badsubr = "func()"; func((void *)&\`utsname); FAIL }
#define CANTREAD2(func, arg1) \
BEGIN { badsubr = "func()"; func((void *)&\`utsname, arg1); FAIL }
#define CANTREAD2ARG1(func, arg0) \
BEGIN { badsubr = "func() (arg1)"; func(arg0, (void *)&\`utsname); FAIL }
#define CANTREAD3(func, arg1, arg2) \
BEGIN { badsubr = "func()"; func((void *)&\`utsname, arg1, arg2); FAIL }
CANTREAD1(mutex_owned)
CANTREAD1(mutex_owner)
CANTREAD1(mutex_type_adaptive)
CANTREAD1(mutex_type_spin)
CANTREAD1(rw_read_held)
CANTREAD1(rw_write_held)
CANTREAD1(rw_iswriter)
CANTREAD3(bcopy, alloca(1), 1)
CANTREAD1(msgsize)
CANTREAD1(msgdsize)
CANTREAD1(strlen)
CANTREAD2(strchr, '!')
CANTREAD2(strrchr, '!')
CANTREAD2(strstr, "doogle")
CANTREAD2ARG1(strstr, "doogle")
CANTREAD2(index, "bagnoogle")
CANTREAD2ARG1(index, "bagnoogle")
CANTREAD2(rindex, "bagnoogle")
CANTREAD2ARG1(rindex, "bagnoogle")
CANTREAD2(strtok, "doogle")
CANTREAD2ARG1(strtok, "doogle")
CANTREAD2(json, "doogle")
CANTREAD2ARG1(json, "doogle")
CANTREAD1(toupper)
CANTREAD1(tolower)
CANTREAD2(ddi_pathname, 1)
CANTREAD2(strjoin, "doogle")
CANTREAD2ARG1(strjoin, "doogle")
CANTREAD1(strtoll)
CANTREAD1(dirname)
CANTREAD1(basename)
CANTREAD1(cleanpath)
#if defined(__amd64)
CANTREAD3(copyout, uregs[R_R9], 1)
CANTREAD3(copyoutstr, uregs[R_R9], 1)
#else
#if defined(__i386)
CANTREAD3(copyout, uregs[R_ESP], 1)
CANTREAD3(copyoutstr, uregs[R_ESP], 1)
#endif
#endif
BEGIN
{
exit(0);
}
ERROR
/arg4 != DTRACEFLT_KPRIV/
{
printf("bad error code via %s (expected %d, found %d)\n",
badsubr, DTRACEFLT_KPRIV, arg4);
exit(3);
}
ERROR
/arg4 == DTRACEFLT_KPRIV/
{
printf("illegal kernel access properly prevented from %s\n", badsubr);
}
EOF
status=$?
if [[ $status -eq 1 ]]; then
cat $err
fi
exit $status

View file

@ -0,0 +1,26 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/
struct mrbig {
char toomany[100000];
};
struct mrbig mrbig;
BEGIN
{
mrbig.toomany[0] = '!';
exit(0);
}

View file

@ -0,0 +1,26 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/
struct mrbig {
char toomany[100000];
};
this struct mrbig mrbig;
BEGIN
{
this->mrbig.toomany[0] = '!';
exit(0);
}

View file

@ -69,7 +69,7 @@ prov.h: prov.d
$dtrace -h -s prov.d
prov.o: prov.d main.o
$dtrace -G -32 -s prov.d main.o
$dtrace -G -s prov.d main.o
EOF
cat > prov.d <<EOF

View file

@ -77,7 +77,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -66,7 +66,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -82,7 +82,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -75,7 +75,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -76,7 +76,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -70,7 +70,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -67,7 +67,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -69,7 +69,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -70,7 +70,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -71,7 +71,7 @@ EOF
exit 1
fi
$dtrace -G -32 -s $oogle.d $oogle.o -o $oogle.d.o
$dtrace -G -s $oogle.d $oogle.o -o $oogle.d.o
if [ $? -ne 0 ]; then
print -u2 "failed to process $oogle.d"

View file

@ -47,7 +47,7 @@ provider doogle {
EOF
cc -c test.c
$dtrace -G -32 -s doogle.d test.o -o doogle.d.o
$dtrace -G -s doogle.d test.o -o doogle.d.o
if [ $? -eq 0 ]; then
print -u2 "dtrace succeeded despite having no probe sites"

View file

@ -56,7 +56,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -56,7 +56,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -67,7 +67,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -56,7 +56,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -57,7 +57,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -68,7 +68,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -72,13 +72,13 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create initial DOF"
exit 1
fi
rm -f prov.o
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create final DOF"
exit 1

View file

@ -67,7 +67,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View file

@ -21,7 +21,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd May 24, 2015
.Dd September 29, 2015
.Dt LOCKSTAT 1
.Os
.Sh NAME
@ -38,7 +38,7 @@
.Op Fl d Ar duration
.Op Fl f Ar function Oo Ns , Ns Ar size Oc
.Op Fl T
.Op Fl ckgwWRpP
.Op Fl kgwWRpP
.Op Fl D Ar count
.Op Fl o filename
.Op Fl x Ar opt Oo Ns = Ns Ar val Oc
@ -172,8 +172,6 @@ This is off by default.
.El
.Ss Data Reporting
.Bl -tag -width indent
.It Fl c
Coalesce lock data for lock arrays.
.It Fl D Ar count
Only display the top
.Ar count

View file

@ -65,7 +65,11 @@ typedef uintptr_t pc_t;
typedef struct lsrec {
struct lsrec *ls_next; /* next in hash chain */
#ifdef illumos
uintptr_t ls_lock; /* lock address */
#else
char *ls_lock; /* lock name */
#endif
uintptr_t ls_caller; /* caller address */
uint32_t ls_count; /* cumulative event count */
uint32_t ls_event; /* type of event */
@ -338,7 +342,9 @@ usage(void)
" -d duration only watch events longer than <duration>\n"
" -T trace (rather than sample) events\n"
"\nData reporting options:\n\n"
#ifdef illumos
" -c coalesce lock data for arrays like pse_mutex[]\n"
#endif
" -k coalesce PCs within functions\n"
" -g show total events generated by function\n"
" -w wherever: don't distinguish events by caller\n"
@ -381,12 +387,16 @@ lockcmp(lsrec_t *a, lsrec_t *b)
if (a->ls_caller > b->ls_caller)
return (1);
#ifdef illumos
if (a->ls_lock < b->ls_lock)
return (-1);
if (a->ls_lock > b->ls_lock)
return (1);
return (0);
#else
return (strcmp(a->ls_lock, b->ls_lock));
#endif
}
static int
@ -424,26 +434,40 @@ lockcmp_anywhere(lsrec_t *a, lsrec_t *b)
if (a->ls_event > b->ls_event)
return (1);
#ifdef illumos
if (a->ls_lock < b->ls_lock)
return (-1);
if (a->ls_lock > b->ls_lock)
return (1);
return (0);
#else
return (strcmp(a->ls_lock, b->ls_lock));
#endif
}
static int
lock_and_count_cmp_anywhere(lsrec_t *a, lsrec_t *b)
{
#ifndef illumos
int cmp;
#endif
if (a->ls_event < b->ls_event)
return (-1);
if (a->ls_event > b->ls_event)
return (1);
#ifdef illumos
if (a->ls_lock < b->ls_lock)
return (-1);
if (a->ls_lock > b->ls_lock)
return (1);
#else
cmp = strcmp(a->ls_lock, b->ls_lock);
if (cmp != 0)
return (cmp);
#endif
return (b->ls_count - a->ls_count);
}
@ -698,7 +722,11 @@ dprog_addevent(int event)
caller = "(uintptr_t)arg0";
arg1 = "arg2";
} else {
#ifdef illumos
arg0 = "(uintptr_t)arg0";
#else
arg0 = "stringof(args[0]->lock_object.lo_name)";
#endif
caller = "caller";
}
@ -912,12 +940,17 @@ lsrec_fill(lsrec_t *lsrec, const dtrace_recdesc_t *rec, int nrecs, caddr_t data)
lsrec->ls_event = (uint32_t)*((uint64_t *)(data + rec->dtrd_offset));
rec++;
#ifdef illumos
if (rec->dtrd_size != sizeof (uintptr_t))
fail(0, "bad lock address size in second record");
/* LINTED - alignment */
lsrec->ls_lock = *((uintptr_t *)(data + rec->dtrd_offset));
rec++;
#else
lsrec->ls_lock = strdup((const char *)(data + rec->dtrd_offset));
rec++;
#endif
if (rec->dtrd_size != sizeof (uintptr_t))
fail(0, "bad caller size in third record");
@ -1224,9 +1257,11 @@ main(int argc, char **argv)
events_specified = 1;
break;
#ifdef illumos
case 'c':
g_cflag = 1;
break;
#endif
case 'k':
g_kflag = 1;
@ -1539,6 +1574,9 @@ main(int argc, char **argv)
caller_in_stack = 1;
bcopy(oldlsp, lsp, LS_TIME);
lsp->ls_caller = oldlsp->ls_stack[fr];
#ifndef illumos
lsp->ls_lock = strdup(oldlsp->ls_lock);
#endif
/* LINTED - alignment */
lsp = (lsrec_t *)((char *)lsp + LS_TIME);
}
@ -1547,6 +1585,9 @@ main(int argc, char **argv)
/* LINTED - alignment */
lsp = (lsrec_t *)((char *)lsp + LS_TIME);
}
#ifndef illumos
free(oldlsp->ls_lock);
#endif
}
g_nrecs = g_nrecs_used =
((uintptr_t)lsp - (uintptr_t)newlsp) / LS_TIME;
@ -1604,8 +1645,10 @@ main(int argc, char **argv)
for (i = 0; i < g_nrecs_used; i++) {
int fr;
lsp = sort_buf[i];
#ifdef illumos
if (g_cflag)
coalesce_symbol(&lsp->ls_lock);
#endif
if (g_kflag) {
for (fr = 0; fr < g_stkdepth; fr++)
coalesce_symbol(&lsp->ls_stack[fr]);
@ -1659,6 +1702,15 @@ main(int argc, char **argv)
first = current;
}
#ifndef illumos
/*
* Free lock name buffers
*/
for (i = 0, lsp = (lsrec_t *)data_buf; i < g_nrecs_used; i++,
lsp = (lsrec_t *)((char *)lsp + g_recsize))
free(lsp->ls_lock);
#endif
return (0);
}
@ -1748,8 +1800,12 @@ report_stats(FILE *out, lsrec_t **sort_buf, size_t nrecs, uint64_t total_count,
(void) fprintf(out, "%u %u",
lsp->ls_event, lsp->ls_count);
#ifdef illumos
(void) fprintf(out, " %s",
format_symbol(buf, lsp->ls_lock, g_cflag));
#else
(void) fprintf(out, " %s", lsp->ls_lock);
#endif
(void) fprintf(out, " %s",
format_symbol(buf, lsp->ls_caller, 0));
(void) fprintf(out, " %f",
@ -1811,8 +1867,12 @@ report_stats(FILE *out, lsrec_t **sort_buf, size_t nrecs, uint64_t total_count,
(void) fprintf(out, "%4.2f %8s ",
(double)lsp->ls_refcnt / lsp->ls_count, buf);
#ifdef illumos
(void) fprintf(out, "%-22s ",
format_symbol(buf, lsp->ls_lock, g_cflag));
#else
(void) fprintf(out, "%-22s ", lsp->ls_lock);
#endif
(void) fprintf(out, "%-24s\n",
format_symbol(buf, lsp->ls_caller, 0));
@ -1908,7 +1968,11 @@ report_trace(FILE *out, lsrec_t **sort_buf)
(void) fprintf(out, "%2d %10llu %11p %-24s %-24s\n",
lsp->ls_event, (unsigned long long)lsp->ls_time,
(void *)lsp->ls_next,
#ifdef illumos
format_symbol(buf, lsp->ls_lock, 0),
#else
lsp->ls_lock,
#endif
format_symbol(buf2, lsp->ls_caller, 0));
if (rectype <= LS_STACK(0))

View file

@ -1,126 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef __STRING_TABLE_DOT_H
#define __STRING_TABLE_DOT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sys/avl.h>
#include <string_table.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* A string is represented in a string table using two values: length, and
* value. Grouping all the strings of a given length together allows for
* efficient matching of tail strings, as each input string value is hashed.
* Each string table uses a 2-level AVL tree of AVL trees to represent this
* organization.
*
* The outer (main) AVL tree contains LenNode structures. The search key for
* nodes on this main tree is the string length. Each such node represents
* all strings of a given length, and all strings of that length are found
* within.
*
* The strings within each LenNode are maintained using a secondary AVL tree
* of StrNode structures. The search key for this inner tree is the string
* itself. The strings are maintained in lexical order.
*/
typedef struct {
avl_node_t sn_avlnode; /* AVL book-keeping */
const char *sn_str; /* string */
size_t sn_refcnt; /* reference count */
} StrNode;
typedef struct {
avl_node_t ln_avlnode; /* AVL book-keeping */
avl_tree_t *ln_strtree; /* AVL tree of associated strings */
size_t ln_strlen; /* length of associated strings */
} LenNode;
/*
* Define a master string data item. Other strings may be suffixes of this
* string. The final string table will consist of the master string values,
* laid end to end, with the other strings referencing their tails.
*/
typedef struct str_master Str_master;
struct str_master {
const char *sm_str; /* pointer to master string */
Str_master *sm_next; /* used for tracking master strings */
size_t sm_strlen; /* length of master string */
uint_t sm_hashval; /* hashval of master string */
size_t sm_stroff; /* offset into destination strtab */
};
/*
* Define a hash data item. This item represents an individual string that has
* been input into the String hash table. The string may either be a suffix of
* another string, or a master string.
*/
typedef struct str_hash Str_hash;
struct str_hash {
size_t hi_strlen; /* string length */
size_t hi_refcnt; /* number of references to str */
uint_t hi_hashval; /* hash for string */
Str_master *hi_mstr; /* pointer to master string */
Str_hash *hi_next; /* next entry in hash bucket */
};
/*
* Controlling data structure for a String Table.
*/
struct str_tbl {
avl_tree_t *st_lentree; /* AVL tree of string lengths */
char *st_strbuf; /* string buffer */
Str_hash **st_hashbcks; /* hash buckets */
Str_master *st_mstrlist; /* list of all master strings */
size_t st_fullstrsize; /* uncompressed table size */
size_t st_nextoff; /* next available string */
size_t st_strsize; /* compressed size */
size_t st_strcnt; /* number of strings */
uint_t st_hbckcnt; /* number of buckets in */
/* hashlist */
uint_t st_flags;
};
#define FLG_STTAB_COMPRESS 0x01 /* compressed string table */
#define FLG_STTAB_COOKED 0x02 /* offset has been assigned */
/*
* Starting value for use with string hashing functions inside of string_table.c
*/
#define HASHSEED 5381
#ifdef __cplusplus
}
#endif
#endif /* __STRING_TABLE_DOT_H */

View file

@ -1,280 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Define an Alist, a list maintained as a reallocable array, and a for() loop
* macro to generalize its traversal. Note that the array can be reallocated
* as it is being traversed, thus the offset of each element is recomputed from
* the start of the structure.
*/
#ifndef _ALIST_H
#define _ALIST_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#ifdef illumos
#include <sys/machelf.h>
#else
#include <sys/elf.h>
#endif
/*
* An Alist implements array lists. The functionality is similar to
* that of a linked list. However, an Alist is represented by a single
* contigious allocation of memory. The head of the memory is a header
* that contains control information for the list. Following the header
* is an array used to hold the user data. In the type definitions that
* follow, we define these as an array with a single element, but when
* we allocate the memory, we actually allocate the amount of memory needed.
*
* There are two "flavors" of array list:
*
* Alist - Contain arbitrary data, usually structs.
* APlist - Contain pointers to data allocated elsewhere.
*
* This differentiation is useful, because pointer lists are heavily
* used, and support a slightly different set of operations that are
* unique to their purpose.
*
* Array lists are initially represented by a NULL pointer. The memory
* for the list is only allocated if an item is inserted. This is very
* efficient for data structures that may or may not be needed for a
* given linker operation --- you only pay for what you use. In addition:
*
* - Array lists grow as needed (memory is reallocated as necessary)
* - Data is kept contiguously (no unused holes in between elements)
* at the beginning of the data area. This locality has
* good cache behavior, as access to adjacent items are
* highly likely to be in the same page of memory.
* - Insert/Delete operations at the end of the list are very
* efficient. However, insert/delete operations elsewhere
* will cause a relatively expensive overlapped memory
* copy of the data following the insert/delete location.
* - As with any generic memory alloctor (i.e. malloc()/free()),
* array lists are not type safe for the data they contain.
* Data is managed as (void *) pointers to data of a given
* length, so the Alist module cannot prevent the caller from
* inserting/extracting the wrong type of data. The caller
* must guard against this.
* - To free an array list, simply call the standard free() function
* on the list pointer.
*/
/*
* Aliste is used to represent list indexes, offsets, and sizes.
*/
typedef size_t Aliste;
/*
* Alist is used to hold non-pointer items --- usually structs:
* - There must be an even number of Aliste fields before the
* al_data field. This ensures that al_data will have
* an alignment of 8, no matter whether sizeof(Aliste)
* is 4 or 8. That means that al_data will have sufficient
* alignment for any use, just like memory allocated via
* malloc().
* - al_nitems and al_next are redundant, in that they are
* directly related:
* al_next = al_nitems * al_size
* We do this to make ALIST_TRAVERSE_BYOFFSET maximally
* efficient. This doesn't waste space, because of the
* requirement to have an even # of Alist fields (above).
*
* Note that Alists allow the data to be referenced by 0 based array
* index, or by their byte offset from the start of the Alist memory
* allocation. The index form is preferred for most use, as it is simpler.
* However, by-offset access is used by rtld link maps, and this ability
* is convenient in that case.
*/
typedef struct {
Aliste al_arritems; /* # of items in al_data allocation */
Aliste al_nitems; /* # items (index of next avail item) */
Aliste al_next; /* offset of next available al_data[] */
Aliste al_size; /* size of each al_data[] item */
void *al_data[1]; /* data (can grow) */
} Alist;
/*
* APlist is a variant of Alist that contains pointers. There are several
* benefits to this special type:
* - API is simpler
* - Pointers are used directly, instead of requiring a
* pointer-to-pointer double indirection.
* - The implementation is slightly more efficient.
* - Operations that make particular sense for pointers
* can be supported without confusing the API for the
* regular Alists.
*/
typedef struct {
Aliste apl_arritems; /* # of items in apl_data allocation */
Aliste apl_nitems; /* # items (index of next avail item) */
void *apl_data[1]; /* data area: (arrcnt * size) bytes */
} APlist;
/*
* The ALIST_OFF_DATA and APLIST_OFF_DATA macros give the byte offset
* from the start of an array list to the first byte of the data area
* used to hold user data. The same trick used by the standard offsetof()
* macro is used.
*/
#define ALIST_OFF_DATA ((size_t)(((Alist *)0)->al_data))
#define APLIST_OFF_DATA ((size_t)(((APlist *)0)->apl_data))
/*
* The TRAVERSE macros are intended to be used within a for(), and
* cause the resulting loop to iterate over each item in the loop,
* in order.
* ALIST_TRAVERSE: Traverse over the items in an Alist,
* using the zero based item array index to refer to
* each item.
* ALIST_TRAVERSE_BY_OFFSET: Traverse over the items in an
* Alist using the byte offset from the head of the
* Alist pointer to refer to each item. It should be noted
* that the first such offset is given by ALIST_OFF_DATA,
* and as such, there will never be a 0 offset. Some code
* uses this fact to treat 0 as a reserved value with
* special meaning.
*
* By-offset access is convenient for some parts of
* rtld, where a value of 0 is used to indicate an
* uninitialized link map control.
*
* APLIST_TRAVERSE: Traverse over the pointers in an APlist, using
* the zero based item array index to refer to each pointer.
*/
/*
* Within the loop:
*
* LIST - Pointer to Alist structure for list
* IDX - The current item index
* OFF - The current item offset
* DATA - Pointer to item
*/
#define ALIST_TRAVERSE(LIST, IDX, DATA) \
(IDX) = 0, \
((LIST) != NULL) && ((DATA) = (void *)(LIST)->al_data); \
\
((LIST) != NULL) && ((IDX) < (LIST)->al_nitems); \
\
(IDX)++, \
(DATA) = (void *) (((LIST)->al_size * (IDX)) + (char *)(LIST)->al_data)
#define ALIST_TRAVERSE_BY_OFFSET(LIST, OFF, DATA) \
(((LIST) != NULL) && ((OFF) = ALIST_OFF_DATA) && \
(((DATA) = (void *)((char *)(LIST) + (OFF))))); \
\
(((LIST) != NULL) && ((OFF) < (LIST)->al_next)); \
\
(((OFF) += ((LIST)->al_size)), \
((DATA) = (void *)((char *)(LIST) + (OFF))))
/*
* Within the loop:
*
* LIST - Pointer to APlist structure for list
* IDX - The current item index
* PTR - item value
*
* Note that this macro is designed to ensure that PTR retains the
* value of the final pointer in the list after exiting the for loop,
* and to avoid dereferencing an out of range address. This is done by
* doing the dereference in the middle expression, using the comma
* operator to ensure that a NULL pointer won't stop the loop.
*/
#define APLIST_TRAVERSE(LIST, IDX, PTR) \
(IDX) = 0; \
\
((LIST) != NULL) && ((IDX) < (LIST)->apl_nitems) && \
(((PTR) = ((LIST)->apl_data)[IDX]), 1); \
\
(IDX)++
/*
* Possible values returned by aplist_test()
*/
typedef enum {
ALE_ALLOCFAIL = 0, /* Memory allocation error */
ALE_EXISTS = 1, /* alist entry already exists */
ALE_NOTFND = 2, /* item not found and insert not required */
ALE_CREATE = 3 /* alist entry created */
} aplist_test_t;
/*
* Access to an Alist item by index or offset. This is needed because the
* size of an item in an Alist is not known by the C compiler, and we
* have to do the indexing arithmetic explicitly.
*
* For an APlist, index the apl_data field directly --- No macro is needed.
*/
#define alist_item(_lp, _idx) \
((void *)(ALIST_OFF_DATA + ((_idx) * (_lp)->al_size) + (char *)(_lp)))
#define alist_item_by_offset(_lp, _off) \
((void *)((_off) + (char *)(_lp)))
/*
* # of items currently found in a list. These macros handle the case
* where the list has not been allocated yet.
*/
#define alist_nitems(_lp) (((_lp) == NULL) ? 0 : (_lp)->al_nitems)
#define aplist_nitems(_lp) (((_lp) == NULL) ? 0 : (_lp)->apl_nitems)
extern void *alist_append(Alist **, const void *, size_t, Aliste);
extern void alist_delete(Alist *, Aliste *);
extern void alist_delete_by_offset(Alist *, Aliste *);
extern void *alist_insert(Alist **, const void *, size_t,
Aliste, Aliste);
extern void *alist_insert_by_offset(Alist **, const void *, size_t,
Aliste, Aliste);
extern void alist_reset(Alist *);
extern void *aplist_append(APlist **, const void *, Aliste);
extern void aplist_delete(APlist *, Aliste *);
extern int aplist_delete_value(APlist *, const void *);
extern void *aplist_insert(APlist **, const void *,
Aliste, Aliste idx);
extern void aplist_reset(APlist *);
extern aplist_test_t aplist_test(APlist **, const void *, Aliste);
#ifdef __cplusplus
}
#endif
#endif /* _ALIST_H */

File diff suppressed because it is too large Load diff

View file

@ -1,296 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1988 AT&T
* All Rights Reserved
*
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Global include file for all sgs.
*/
#ifndef _SGS_H
#define _SGS_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/* <assert.h> keys off of NDEBUG */
#ifdef DEBUG
#undef NDEBUG
#else
#define NDEBUG
#endif
#ifndef _ASM
#include <sys/types.h>
#ifdef illumos
#include <sys/machelf.h>
#else
#include <elf.h>
#endif
#include <stdlib.h>
#include <libelf.h>
#include <assert.h>
#include <alist.h>
#endif /* _ASM */
/*
* Software identification.
*/
#define SGS ""
#define SGU_PKG "Software Generation Utilities"
#define SGU_REL "(SGU) Solaris-ELF (4.0)"
#ifndef _ASM
/*
* link_ver_string[] contains a version string for use by the link-editor
* and all other linker components. It is found in libconv, and is
* generated by sgs/libconv/common/bld_vernote.ksh. That script produces
* libconv/{plat}/vernote.s, which is in turn assembled/linked into
* libconv.
*/
extern const char link_ver_string[];
/*
* Macro to round to next double word boundary.
*/
#define S_DROUND(x) (((x) + sizeof (double) - 1) & ~(sizeof (double) - 1))
/*
* General align and round macros.
*/
#define S_ALIGN(x, a) ((x) & ~(((a) ? (a) : 1) - 1))
#define S_ROUND(x, a) ((x) + (((a) ? (a) : 1) - 1) & ~(((a) ? (a) : 1) - 1))
/*
* Bit manipulation macros; generic bit mask and is `v' in the range
* supportable in `n' bits?
*/
#define S_MASK(n) ((1 << (n)) -1)
#define S_INRANGE(v, n) (((-(1 << (n)) - 1) < (v)) && ((v) < (1 << (n))))
/*
* Yet another definition of the OFFSETOF macro, used with the AVL routines.
*/
#define SGSOFFSETOF(s, m) ((size_t)(&(((s *)0)->m)))
/*
* When casting between integer and pointer types, gcc will complain
* if the integer type used is not large enough to hold the pointer
* value without loss. Although a dubious practice in general, this
* is sometimes done by design. In those cases, the general solution
* is to introduce an intermediate cast to widen the integer value. The
* CAST_PTRINT macro does this, and its use documents the fact that
* the programmer is doing that sort of cast.
*/
#ifdef __GNUC__
#define CAST_PTRINT(cast, value) ((cast)(uintptr_t)value)
#else
#define CAST_PTRINT(cast, value) ((cast)value)
#endif
/*
* General typedefs.
*/
typedef enum {
FALSE = 0,
TRUE = 1
} Boolean;
/*
* Types of errors (used by eprintf()), together with a generic error return
* value.
*/
typedef enum {
ERR_NONE,
ERR_WARNING,
ERR_FATAL,
ERR_ELF,
ERR_NUM /* Must be last */
} Error;
#if defined(_LP64) && !defined(_ELF64)
#define S_ERROR (~(uint_t)0)
#else
#define S_ERROR (~(uintptr_t)0)
#endif
/*
* LIST_TRAVERSE() is used as the only "argument" of a "for" loop to
* traverse a linked list. The node pointer `node' is set to each node in
* turn and the corresponding data pointer is copied to `data'. The macro
* is used as in
* for (LIST_TRAVERSE(List *list, Listnode *node, void *data)) {
* process(data);
* }
*/
#define LIST_TRAVERSE(L, N, D) \
(void) (((N) = (L)->head) != NULL && ((D) = (N)->data) != NULL); \
(N) != NULL; \
(void) (((N) = (N)->next) != NULL && ((D) = (N)->data) != NULL)
typedef struct listnode Listnode;
typedef struct list List;
struct listnode { /* a node on a linked list */
void *data; /* the data item */
Listnode *next; /* the next element */
};
struct list { /* a linked list */
Listnode *head; /* the first element */
Listnode *tail; /* the last element */
};
#ifdef _SYSCALL32
typedef struct listnode32 Listnode32;
typedef struct list32 List32;
struct listnode32 { /* a node on a linked list */
Elf32_Addr data; /* the data item */
Elf32_Addr next; /* the next element */
};
struct list32 { /* a linked list */
Elf32_Addr head; /* the first element */
Elf32_Addr tail; /* the last element */
};
#endif /* _SYSCALL32 */
/*
* Structure to maintain rejected files elf information. Files that are not
* applicable to the present link-edit are rejected and a search for an
* appropriate file may be resumed. The first rejected files information is
* retained so that a better error diagnostic can be given should an appropriate
* file not be located.
*/
typedef struct {
ushort_t rej_type; /* SGS_REJ_ value */
ushort_t rej_flag; /* additional information */
uint_t rej_info; /* numeric and string information */
const char *rej_str; /* associated with error */
const char *rej_name; /* object name - expanded library */
/* name and archive members */
} Rej_desc;
#define SGS_REJ_NONE 0
#define SGS_REJ_MACH 1 /* wrong ELF machine type */
#define SGS_REJ_CLASS 2 /* wrong ELF class (32-bit/64-bit) */
#define SGS_REJ_DATA 3 /* wrong ELF data format (MSG/LSB) */
#define SGS_REJ_TYPE 4 /* bad ELF type */
#define SGS_REJ_BADFLAG 5 /* bad ELF flags value */
#define SGS_REJ_MISFLAG 6 /* mismatched ELF flags value */
#define SGS_REJ_VERSION 7 /* mismatched ELF/lib version */
#define SGS_REJ_HAL 8 /* HAL R1 extensions required */
#define SGS_REJ_US3 9 /* Sun UltraSPARC III extensions */
/* required */
#define SGS_REJ_STR 10 /* generic error - info is a string */
#define SGS_REJ_UNKFILE 11 /* unknown file type */
#define SGS_REJ_HWCAP_1 12 /* hardware capabilities mismatch */
/*
* For those source files used both inside and outside of the
* libld source base (tools/common/string_table.c) we can
* automatically switch between the allocation models
* based off of the 'cc -DUSE_LIBLD_MALLOC' flag.
*/
#ifdef USE_LIBLD_MALLOC
#define calloc(x, a) libld_malloc(((size_t)x) * ((size_t)a))
#define free libld_free
#define malloc libld_malloc
#define realloc libld_realloc
#define libld_calloc(x, a) libld_malloc(((size_t)x) * ((size_t)a))
extern void libld_free(void *);
extern void *libld_malloc(size_t);
extern void *libld_realloc(void *, size_t);
#endif
/*
* Data structures (defined in libld.h).
*/
typedef struct ent_desc Ent_desc;
typedef struct group_desc Group_desc;
typedef struct ifl_desc Ifl_desc;
typedef struct is_desc Is_desc;
typedef struct isa_desc Isa_desc;
typedef struct isa_opt Isa_opt;
typedef struct mv_desc Mv_desc;
typedef struct ofl_desc Ofl_desc;
typedef struct os_desc Os_desc;
typedef struct rel_cache Rel_cache;
typedef struct sdf_desc Sdf_desc;
typedef struct sdv_desc Sdv_desc;
typedef struct sg_desc Sg_desc;
typedef struct sort_desc Sort_desc;
typedef struct sec_order Sec_order;
typedef struct sym_desc Sym_desc;
typedef struct sym_aux Sym_aux;
typedef struct sym_avlnode Sym_avlnode;
typedef struct uts_desc Uts_desc;
typedef struct ver_desc Ver_desc;
typedef struct ver_index Ver_index;
typedef struct audit_desc Audit_desc;
typedef struct audit_info Audit_info;
typedef struct audit_list Audit_list;
/*
* Data structures defined in machrel.h.
*/
typedef struct rel_desc Rel_desc;
/*
* Data structures defined in rtld.h.
*/
typedef struct lm_list Lm_list;
#ifdef _SYSCALL32
typedef struct lm_list32 Lm_list32;
#endif /* _SYSCALL32 */
/*
* For the various utilities that include sgs.h
*/
extern int assfail(const char *, const char *, int);
extern void eprintf(Lm_list *, Error, const char *, ...);
extern char *sgs_demangle(char *);
extern uint_t sgs_str_hash(const char *);
extern uint_t findprime(uint_t);
#endif /* _ASM */
#ifdef __cplusplus
}
#endif
#endif /* _SGS_H */

View file

@ -1,63 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _STRING_TABLE_DOT_H
#define _STRING_TABLE_DOT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Exported, opaque string table handle.
*/
typedef struct str_tbl Str_tbl;
/*
* Exported string table functions.
*/
extern int st_delstring(Str_tbl *, const char *);
extern void st_destroy(Str_tbl *);
extern size_t st_getstrtab_sz(Str_tbl *);
extern const char *st_getstrbuf(Str_tbl *);
extern int st_insert(Str_tbl *, const char *);
extern Str_tbl *st_new(uint_t);
extern int st_setstrbuf(Str_tbl *, char *, size_t);
extern int st_setstring(Str_tbl *, const char *, size_t *);
/*
* Exported flags values for st_new().
*/
#define FLG_STNEW_COMPRESS 0x01 /* compressed string table */
#ifdef __cplusplus
}
#endif
#endif /* _STRING_TABLE_DOT_H */

View file

@ -1,62 +0,0 @@
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# ident "%Z%%M% %I% %E% SMI"
#
#
# Global message identifiers for the sgs utilities. This information is read
# by sgsmsg(1l) using the -i option.
# Each utilities message file references one of the `MSGID' identifiers. Its
# associated numeric setid is used when creating catgets(3c) messages, the
# string domain is used when creating gettext(3i) messages.
#
mesgid setid domain
MSG_ID_RTLD 1 SUNW_OST_SGS /* sgs/rtld */
MSG_ID_LIBRTLD 2 SUNW_OST_SGS /* sgs/librtld */
MSG_ID_LIBLD 3 SUNW_OST_SGS /* sgs/libld */
MSG_ID_LIBLDDBG 4 SUNW_OST_SGS /* sgs/liblddbg */
MSG_ID_LIBLDSTAB 5 SUNW_OST_SGS /* sgs/libldstab */
MSG_ID_LIBRTLD_DB 6 SUNW_OST_SGS /* sgs/librtld_db */
MSG_ID_LIBPROF 7 SUNW_OST_SGS /* sgs/libprof */
MSG_ID_LIBCRLE 8 SUNW_OST_SGS /* sgs/libcrle */
MSG_ID_LIBELF 10 SUNW_OST_SGS /* sgs/libelf */
MSG_ID_LD 20 SUNW_OST_SGS /* sgs/ld */
MSG_ID_LDD 21 SUNW_OST_SGS /* sgs/ldd */
MSG_ID_PVS 22 SUNW_OST_SGS /* sgs/pvs */
MSG_ID_CRLE 23 SUNW_OST_SGS /* sgs/crle */
MSG_ID_ELFDUMP 24 SUNW_OST_SGS /* sgs/elfdump */
MSG_ID_MOE 25 SUNW_OST_SGS /* sgs/moe */
MSG_ID_ELFEDIT 26 SUNW_OST_SGS /* sgs/elfedit */
MSG_ID_ELFEDIT_CAP 27 SUNW_OST_SGS /* cap: */
MSG_ID_ELFEDIT_DYN 27 SUNW_OST_SGS /* dyn: */
MSG_ID_ELFEDIT_EHDR 27 SUNW_OST_SGS /* ehdr: */
MSG_ID_ELFEDIT_PHDR 27 SUNW_OST_SGS /* phdr: */
MSG_ID_ELFEDIT_SHDR 27 SUNW_OST_SGS /* shdr: */
MSG_ID_ELFEDIT_STR 27 SUNW_OST_SGS /* str: */
MSG_ID_ELFEDIT_SYM 27 SUNW_OST_SGS /* sym: */
MSG_ID_ELFEDIT_SYMINFO 27 SUNW_OST_SGS /* syminfo: */
MSG_ID_ELFWRAP 28 SUNW_OST_SGS /* sgs/elfwrap */

View file

@ -1,56 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sgs.h>
/*
* function that will find a prime'ish number. Usefull for
* hashbuckets and related things.
*/
uint_t
findprime(uint_t count)
{
uint_t h, f;
if (count <= 3)
return (3);
/*
* Check to see if divisible by two, if so
* increment.
*/
if ((count & 0x1) == 0)
count++;
for (h = count, f = 2; f * f <= h; f++)
if ((h % f) == 0)
h += f = 1;
return (h);
}

File diff suppressed because it is too large Load diff

View file

@ -1,685 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <_string_table.h>
#include <strings.h>
#include <sgs.h>
#include <stdio.h>
/*
* This file provides the interfaces to build a Str_tbl suitable for use by
* either the sgsmsg message system, or a standard ELF string table (SHT_STRTAB)
* as created by ld(1).
*
* There are two modes which can be used when constructing a string table:
*
* st_new(0)
* standard string table - no compression. This is the
* traditional, fast method.
*
* st_new(FLG_STTAB_COMPRESS)
* builds a compressed string table which both eliminates
* duplicate strings, and permits strings with common suffixes
* (atexit vs. exit) to overlap in the table. This provides space
* savings for many string tables. Although more work than the
* traditional method, the algorithms used are designed to scale
* and keep any overhead at a minimum.
*
* These string tables are built with a common interface in a two-pass manner.
* The first pass finds all of the strings required for the string-table and
* calculates the size required for the final string table.
*
* The second pass allocates the string table, populates the strings into the
* table and returns the offsets the strings have been assigned.
*
* The calling sequence to build and populate a string table is:
*
* st_new(); // initialize strtab
*
* st_insert(st1); // first pass of strings ...
* // calculates size required for
* // string table
*
* st_delstring(st?); // remove string previously
* // inserted
* st_insert(stN);
*
* st_getstrtab_sz(); // freezes strtab and computes
* // size of table.
*
* st_setstrbuf(); // associates a final destination
* // for the string table
*
* st_setstring(st1); // populate the string table
* ... // offsets are based off of second
* // pass through the string table
* st_setstring(stN);
*
* st_destroy(); // tear down string table
* // structures.
*
* String Suffix Compression Algorithm:
*
* Here's a quick high level overview of the Suffix String
* compression algorithm used. First - the heart of the algorithm
* is a Hash table list which represents a dictionary of all unique
* strings inserted into the string table. The hash function for
* this table is a standard string hash except that the hash starts
* at the last character in the string (&str[n - 1]) and works towards
* the first character in the function (&str[0]). As we compute the
* HASH value for a given string, we also compute the hash values
* for all of the possible suffix strings for that string.
*
* As we compute the hash - at each character see if the current
* suffix string for that hash is already present in the table. If
* it is, and the string is a master string. Then change that
* string to a suffix string of the new string being inserted.
*
* When the final hash value is found (hash for str[0...n]), check
* to see if it is in the hash table - if so increment the reference
* count for the string. If it is not yet in the table, insert a
* new hash table entry for a master string.
*
* The above method will find all suffixes of a given string given
* that the strings are inserted from shortest to longest. That is
* why this is a two phase method, we first collect all of the
* strings and store them based off of their length in an AVL tree.
* Once all of the strings have been submitted we then start the
* hash table build by traversing the AVL tree in order and
* inserting the strings from shortest to longest as described
* above.
*/
/* LINTLIBRARY */
static int
avl_len_compare(const void *n1, const void *n2)
{
size_t len1, len2;
len1 = ((LenNode *)n1)->ln_strlen;
len2 = ((LenNode *)n2)->ln_strlen;
if (len1 == len2)
return (0);
if (len2 < len1)
return (1);
return (-1);
}
static int
avl_str_compare(const void *n1, const void *n2)
{
const char *str1, *str2;
int rc;
str1 = ((StrNode *)n1)->sn_str;
str2 = ((StrNode *)n2)->sn_str;
rc = strcmp(str1, str2);
if (rc > 0)
return (1);
if (rc < 0)
return (-1);
return (0);
}
/*
* Return an initialized Str_tbl - returns NULL on failure.
*
* flags:
* FLG_STTAB_COMPRESS - build a compressed string table
*/
Str_tbl *
st_new(uint_t flags)
{
Str_tbl *stp;
if ((stp = calloc(sizeof (Str_tbl), 1)) == NULL)
return (NULL);
/*
* Start with a leading '\0' - it's tradition.
*/
stp->st_strsize = stp->st_fullstrsize = stp->st_nextoff = 1;
/*
* Do we compress this string table?
*/
stp->st_flags = flags;
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0)
return (stp);
if ((stp->st_lentree = calloc(sizeof (avl_tree_t), 1)) == NULL)
return (NULL);
avl_create(stp->st_lentree, &avl_len_compare, sizeof (LenNode),
SGSOFFSETOF(LenNode, ln_avlnode));
return (stp);
}
/*
* Insert a new string into the Str_tbl. There are two AVL trees used.
*
* . The first LenNode AVL tree maintains a tree of nodes based on string
* sizes.
* . Each LenNode maintains a StrNode AVL tree for each string. Large
* applications have been known to contribute thousands of strings of
* the same size. Should strings need to be removed (-z ignore), then
* the string AVL tree makes this removal efficient and scalable.
*/
int
st_insert(Str_tbl *stp, const char *str)
{
size_t len;
StrNode *snp, sn = { 0 };
LenNode *lnp, ln = { 0 };
avl_index_t where;
/*
* String table can't have been cooked
*/
assert((stp->st_flags & FLG_STTAB_COOKED) == 0);
/*
* Null strings always point to the head of the string
* table - no reason to keep searching.
*/
if ((len = strlen(str)) == 0)
return (0);
stp->st_fullstrsize += len + 1;
stp->st_strcnt++;
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0)
return (0);
/*
* From the controlling string table, determine which LenNode AVL node
* provides for this string length. If the node doesn't exist, insert
* a new node to represent this string length.
*/
ln.ln_strlen = len;
if ((lnp = avl_find(stp->st_lentree, &ln, &where)) == NULL) {
if ((lnp = calloc(sizeof (LenNode), 1)) == NULL)
return (-1);
lnp->ln_strlen = len;
avl_insert(stp->st_lentree, lnp, where);
if ((lnp->ln_strtree = calloc(sizeof (avl_tree_t), 1)) == NULL)
return (0);
avl_create(lnp->ln_strtree, &avl_str_compare, sizeof (StrNode),
SGSOFFSETOF(StrNode, sn_avlnode));
}
/*
* From the string length AVL node determine whether a StrNode AVL node
* provides this string. If the node doesn't exist, insert a new node
* to represent this string.
*/
sn.sn_str = str;
if ((snp = avl_find(lnp->ln_strtree, &sn, &where)) == NULL) {
if ((snp = calloc(sizeof (StrNode), 1)) == NULL)
return (-1);
snp->sn_str = str;
avl_insert(lnp->ln_strtree, snp, where);
}
snp->sn_refcnt++;
return (0);
}
/*
* Remove a previously inserted string from the Str_tbl.
*/
int
st_delstring(Str_tbl *stp, const char *str)
{
size_t len;
LenNode *lnp, ln = { 0 };
StrNode *snp, sn = { 0 };
/*
* String table can't have been cooked
*/
assert((stp->st_flags & FLG_STTAB_COOKED) == 0);
len = strlen(str);
stp->st_fullstrsize -= len + 1;
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0)
return (0);
/*
* Determine which LenNode AVL node provides for this string length.
*/
ln.ln_strlen = len;
if ((lnp = avl_find(stp->st_lentree, &ln, 0)) != NULL) {
sn.sn_str = str;
if ((snp = avl_find(lnp->ln_strtree, &sn, 0)) != NULL) {
/*
* Reduce the reference count, and if zero remove the
* node.
*/
if (--snp->sn_refcnt == 0)
avl_remove(lnp->ln_strtree, snp);
return (0);
}
}
/*
* No strings of this length, or no string itself - someone goofed.
*/
return (-1);
}
/*
* Tear down a String_Table structure.
*/
void
st_destroy(Str_tbl *stp)
{
Str_hash *sthash, *psthash;
Str_master *mstr, *pmstr;
uint_t i;
/*
* cleanup the master strings
*/
for (mstr = stp->st_mstrlist, pmstr = 0; mstr;
mstr = mstr->sm_next) {
if (pmstr)
free(pmstr);
pmstr = mstr;
}
if (pmstr)
free(pmstr);
if (stp->st_hashbcks) {
for (i = 0; i < stp->st_hbckcnt; i++) {
for (sthash = stp->st_hashbcks[i], psthash = 0;
sthash; sthash = sthash->hi_next) {
if (psthash)
free(psthash);
psthash = sthash;
}
if (psthash)
free(psthash);
}
free(stp->st_hashbcks);
}
free(stp);
}
/*
* For a given string - copy it into the buffer associated with
* the string table - and return the offset it has been assigned.
*
* If a value of '-1' is returned - the string was not found in
* the Str_tbl.
*/
int
st_setstring(Str_tbl *stp, const char *str, size_t *stoff)
{
size_t stlen;
uint_t hashval;
Str_hash *sthash;
Str_master *mstr;
int i;
/*
* String table *must* have been previously cooked
*/
assert(stp->st_strbuf);
assert(stp->st_flags & FLG_STTAB_COOKED);
stlen = strlen(str);
/*
* Null string always points to head of string table
*/
if (stlen == 0) {
*stoff = 0;
return (0);
}
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0) {
size_t _stoff;
stlen++; /* count for trailing '\0' */
_stoff = stp->st_nextoff;
/*
* Have we overflowed our assigned buffer?
*/
if ((_stoff + stlen) > stp->st_fullstrsize)
return (-1);
memcpy(stp->st_strbuf + _stoff, str, stlen);
*stoff = _stoff;
stp->st_nextoff += stlen;
return (0);
}
/*
* Calculate reverse hash for string.
*/
hashval = HASHSEED;
for (i = stlen; i >= 0; i--) {
hashval = ((hashval << 5) + hashval) +
str[i]; /* h = ((h * 33) + c) */
}
for (sthash = stp->st_hashbcks[hashval % stp->st_hbckcnt]; sthash;
sthash = sthash->hi_next) {
const char *hstr;
if (sthash->hi_hashval != hashval)
continue;
hstr = &sthash->hi_mstr->sm_str[sthash->hi_mstr->sm_strlen -
sthash->hi_strlen];
if (strcmp(str, hstr) == 0)
break;
}
/*
* Did we find the string?
*/
if (sthash == 0)
return (-1);
/*
* Has this string been copied into the string table?
*/
mstr = sthash->hi_mstr;
if (mstr->sm_stroff == 0) {
size_t mstrlen = mstr->sm_strlen + 1;
mstr->sm_stroff = stp->st_nextoff;
/*
* Have we overflowed our assigned buffer?
*/
if ((mstr->sm_stroff + mstrlen) > stp->st_fullstrsize)
return (-1);
(void) memcpy(stp->st_strbuf + mstr->sm_stroff,
mstr->sm_str, mstrlen);
stp->st_nextoff += mstrlen;
}
/*
* Calculate offset of (sub)string.
*/
*stoff = mstr->sm_stroff + mstr->sm_strlen - sthash->hi_strlen;
return (0);
}
static int
st_hash_insert(Str_tbl *stp, const char *str, size_t len)
{
int i;
uint_t hashval = HASHSEED;
uint_t bckcnt = stp->st_hbckcnt;
Str_hash **hashbcks = stp->st_hashbcks;
Str_hash *sthash;
Str_master *mstr = 0;
/*
* We use a classic 'Bernstein k=33' hash function. But
* instead of hashing from the start of the string to the
* end, we do it in reverse.
*
* This way - we are essentially building all of the
* suffix hashvalues as we go. We can check to see if
* any suffixes already exist in the tree as we generate
* the hash.
*/
for (i = len; i >= 0; i--) {
hashval = ((hashval << 5) + hashval) +
str[i]; /* h = ((h * 33) + c) */
for (sthash = hashbcks[hashval % bckcnt];
sthash; sthash = sthash->hi_next) {
const char *hstr;
Str_master *_mstr;
if (sthash->hi_hashval != hashval)
continue;
_mstr = sthash->hi_mstr;
hstr = &_mstr->sm_str[_mstr->sm_strlen -
sthash->hi_strlen];
if (strcmp(&str[i], hstr))
continue;
if (i == 0) {
/*
* Entry already in table, increment refcnt and
* get out.
*/
sthash->hi_refcnt++;
return (0);
} else {
/*
* If this 'suffix' is presently a 'master
* string, then take over it's record.
*/
if (sthash->hi_strlen == _mstr->sm_strlen) {
/*
* we should only do this once.
*/
assert(mstr == 0);
mstr = _mstr;
}
}
}
}
/*
* Do we need a new master string, or can we take over
* one we already found in the table?
*/
if (mstr == 0) {
/*
* allocate a new master string
*/
if ((mstr = calloc(sizeof (Str_hash), 1)) == 0)
return (-1);
mstr->sm_next = stp->st_mstrlist;
stp->st_mstrlist = mstr;
stp->st_strsize += len + 1;
} else {
/*
* We are taking over a existing master string, the string size
* only increments by the difference between the current string
* and the previous master.
*/
assert(len > mstr->sm_strlen);
stp->st_strsize += len - mstr->sm_strlen;
}
if ((sthash = calloc(sizeof (Str_hash), 1)) == 0)
return (-1);
mstr->sm_hashval = sthash->hi_hashval = hashval;
mstr->sm_strlen = sthash->hi_strlen = len;
mstr->sm_str = str;
sthash->hi_refcnt = 1;
sthash->hi_mstr = mstr;
/*
* Insert string element into head of hash list
*/
hashval = hashval % bckcnt;
sthash->hi_next = hashbcks[hashval];
hashbcks[hashval] = sthash;
return (0);
}
/*
* Return amount of space required for the string table.
*/
size_t
st_getstrtab_sz(Str_tbl *stp)
{
assert(stp->st_fullstrsize > 0);
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0) {
stp->st_flags |= FLG_STTAB_COOKED;
return (stp->st_fullstrsize);
}
if ((stp->st_flags & FLG_STTAB_COOKED) == 0) {
LenNode *lnp;
void *cookie;
stp->st_flags |= FLG_STTAB_COOKED;
/*
* allocate a hash table about the size of # of
* strings input.
*/
stp->st_hbckcnt = findprime(stp->st_strcnt);
if ((stp->st_hashbcks =
calloc(sizeof (Str_hash), stp->st_hbckcnt)) == NULL)
return (0);
/*
* We now walk all of the strings in the list, from shortest to
* longest, and insert them into the hashtable.
*/
if ((lnp = avl_first(stp->st_lentree)) == NULL) {
/*
* Is it possible we have an empty string table, if so,
* the table still contains '\0', so return the size.
*/
if (avl_numnodes(stp->st_lentree) == 0) {
assert(stp->st_strsize == 1);
return (stp->st_strsize);
}
return (0);
}
while (lnp) {
StrNode *snp;
/*
* Walk the string lists and insert them into the hash
* list. Once a string is inserted we no longer need
* it's entry, so the string can be freed.
*/
for (snp = avl_first(lnp->ln_strtree); snp;
snp = AVL_NEXT(lnp->ln_strtree, snp)) {
if (st_hash_insert(stp, snp->sn_str,
lnp->ln_strlen) == -1)
return (0);
}
/*
* Now that the strings have been copied, walk the
* StrNode tree and free all the AVL nodes. Note,
* avl_destroy_nodes() beats avl_remove() as the
* latter balances the nodes as they are removed.
* We just want to tear the whole thing down fast.
*/
cookie = NULL;
while ((snp = avl_destroy_nodes(lnp->ln_strtree,
&cookie)) != NULL)
free(snp);
avl_destroy(lnp->ln_strtree);
free(lnp->ln_strtree);
lnp->ln_strtree = NULL;
/*
* Move on to the next LenNode.
*/
lnp = AVL_NEXT(stp->st_lentree, lnp);
}
/*
* Now that all of the strings have been freed, walk the
* LenNode tree and free all of the AVL nodes. Note,
* avl_destroy_nodes() beats avl_remove() as the latter
* balances the nodes as they are removed. We just want to
* tear the whole thing down fast.
*/
cookie = NULL;
while ((lnp = avl_destroy_nodes(stp->st_lentree,
&cookie)) != NULL)
free(lnp);
avl_destroy(stp->st_lentree);
free(stp->st_lentree);
stp->st_lentree = 0;
}
assert(stp->st_strsize > 0);
assert(stp->st_fullstrsize >= stp->st_strsize);
return (stp->st_strsize);
}
/*
* Associate a buffer with a string table.
*/
const char *
st_getstrbuf(Str_tbl *stp)
{
return (stp->st_strbuf);
}
int
st_setstrbuf(Str_tbl *stp, char *stbuf, size_t bufsize)
{
assert(stp->st_flags & FLG_STTAB_COOKED);
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0) {
if (bufsize < stp->st_fullstrsize)
return (-1);
} else {
if (bufsize < stp->st_strsize)
return (-1);
}
stp->st_strbuf = stbuf;
#ifdef DEBUG
/*
* for debug builds - start with a stringtable filled in
* with '0xff'. This makes it very easy to find wholes
* which we failed to fill in - in the strtab.
*/
memset(stbuf, 0xff, bufsize);
stbuf[0] = '\0';
#else
memset(stbuf, 0x0, bufsize);
#endif
return (0);
}

View file

@ -1205,7 +1205,9 @@ snprintf_blkptr_compact(char *blkbuf, size_t buflen, const blkptr_t *bp)
if (BP_IS_HOLE(bp)) {
(void) snprintf(blkbuf + strlen(blkbuf),
buflen - strlen(blkbuf), "B=%llu",
buflen - strlen(blkbuf),
"%llxL B=%llu",
(u_longlong_t)BP_GET_LSIZE(bp),
(u_longlong_t)bp->blk_birth);
} else {
(void) snprintf(blkbuf + strlen(blkbuf),

View file

@ -31,7 +31,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 30, 2015
.Dd September 14, 2015
.Dt ZFS 8
.Os
.Sh NAME
@ -2144,7 +2144,8 @@ Property name
.It value
Property value
.It source
Property source. Can either be local, default, temporary, inherited, or none
Property source. Can either be local, default, temporary, inherited, received,
or none
(\&-).
.El
.Pp
@ -2210,8 +2211,11 @@ The default value is all sources.
.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot Ns ...
.Xc
.Pp
Clears the specified property, causing it to be inherited from an ancestor. If
no ancestor has the property set, then the default value is used. See the
Clears the specified property, causing it to be inherited from an ancestor,
restored to default if no ancestor has the property set, or with the
.Fl S
option reverted to the received value if one exists.
See the
.Qq Sx Properties
section for a listing of default values, and details on which properties can be
inherited.
@ -2219,8 +2223,10 @@ inherited.
.It Fl r
Recursively inherit the given property for all children.
.It Fl S
For properties with a received value, revert to this value. This flag has no
effect on properties that do not have a received value.
Revert the property to the received value if one exists; otherwise operate as
if the
.Fl S
option was not specified.
.El
.It Xo
.Nm

View file

@ -1928,9 +1928,13 @@ zfs_do_inherit(int argc, char **argv)
if (prop == ZFS_PROP_QUOTA ||
prop == ZFS_PROP_RESERVATION ||
prop == ZFS_PROP_REFQUOTA ||
prop == ZFS_PROP_REFRESERVATION)
prop == ZFS_PROP_REFRESERVATION) {
(void) fprintf(stderr, gettext("use 'zfs set "
"%s=none' to clear\n"), propname);
(void) fprintf(stderr, gettext("use 'zfs "
"inherit -S %s' to revert to received "
"value\n"), propname);
}
return (1);
}
if (received && (prop == ZFS_PROP_VOLSIZE ||

File diff suppressed because it is too large Load diff

View file

@ -55,7 +55,6 @@
#include "zfs_prop.h"
#include "zfeature_common.h"
int aok;
int
libzfs_errno(libzfs_handle_t *hdl)

View file

@ -45,7 +45,9 @@
* Emulation of kernel services in userland.
*/
#ifndef __FreeBSD__
int aok;
#endif
uint64_t physmem;
vnode_t *rootdir = (vnode_t *)0xabcd1234;
char hw_serial[HW_HOSTID_LEN];

View file

@ -56,6 +56,10 @@ DSRCS= errno.d \
udp.d \
unistd.d
FILES= ${DSRCS}
FILESDIR= /usr/lib/dtrace
FILESMODE= ${NOBINMODE}
WARNS?= 1
CFLAGS+= -I${.OBJDIR} -I${.CURDIR} \
@ -120,11 +124,4 @@ dt_names.c:
beforedepend: dt_errtags.c dt_names.c
beforeinstall:
.if !defined(LIBRARIES_ONLY) && exists(${DESTDIR}/usr/lib/dtrace)
.for file in ${DSRCS}
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} ${.CURDIR}/${file} ${DESTDIR}/usr/lib/dtrace
.endfor
.endif
.include <bsd.lib.mk>

View file

@ -110,7 +110,6 @@ typedef struct ipv4info {
* These values are NULL if the packet is not IPv6.
*/
typedef struct in6_addr in6_addr_t;
typedef struct ip6_hdr ip6_t;
typedef struct ipv6info {
uint8_t ipv6_ver; /* IP version (6) */
uint8_t ipv6_tclass; /* traffic class */
@ -123,7 +122,7 @@ typedef struct ipv6info {
in6_addr_t *ipv6_dst; /* destination address */
string ipv6_saddr; /* source address, string */
string ipv6_daddr; /* destination address, string */
ip6_t *ipv6_hdr; /* pointer to raw header */
struct ip6_hdr *ipv6_hdr; /* pointer to raw header */
} ipv6info_t;
#pragma D binding "1.5" IPPROTO_IP
@ -282,5 +281,5 @@ translator ipv6info_t < struct ip6_hdr *p > {
ipv6_dst = p == NULL ? 0 : (in6_addr_t *)&p->ip6_dst;
ipv6_saddr = p == NULL ? 0 : inet_ntoa6(&p->ip6_src);
ipv6_daddr = p == NULL ? 0 : inet_ntoa6(&p->ip6_dst);
ipv6_hdr = (ip6_t *)p;
ipv6_hdr = p;
};

View file

@ -103,11 +103,15 @@ typedef struct tcpsinfo {
int32_t tcps_state; /* TCP state */
uint32_t tcps_iss; /* Initial sequence # sent */
uint32_t tcps_suna; /* sequence # sent but unacked */
uint32_t tcps_smax; /* highest sequence number sent */
uint32_t tcps_snxt; /* next sequence # to send */
uint32_t tcps_rack; /* sequence # we have acked */
uint32_t tcps_rnxt; /* next sequence # expected */
uint32_t tcps_swnd; /* send window size */
int32_t tcps_snd_ws; /* send window scaling */
uint32_t tcps_swl1; /* window update seg seq number */
uint32_t tcps_swl2; /* window update seg ack number */
uint32_t tcps_rup; /* receive urgent pointer */
uint32_t tcps_rwnd; /* receive window size */
int32_t tcps_rcv_ws; /* receive window scaling */
uint32_t tcps_cwnd; /* congestion window */
@ -117,7 +121,8 @@ typedef struct tcpsinfo {
uint32_t tcps_rto; /* round-trip timeout, msec */
uint32_t tcps_mss; /* max segment size */
int tcps_retransmit; /* retransmit send event, boolean */
int tcps_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */
int tcps_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */
int tcps_debug; /* socket has SO_DEBUG set */
} tcpsinfo_t;
/*
@ -188,12 +193,16 @@ translator tcpsinfo_t < struct tcpcb *p > {
tcps_state = p == NULL ? -1 : p->t_state;
tcps_iss = p == NULL ? 0 : p->iss;
tcps_suna = p == NULL ? 0 : p->snd_una;
tcps_smax = p == NULL ? 0 : p->snd_max;
tcps_snxt = p == NULL ? 0 : p->snd_nxt;
tcps_rack = p == NULL ? 0 : p->last_ack_sent;
tcps_rnxt = p == NULL ? 0 : p->rcv_nxt;
tcps_swnd = p == NULL ? -1 : p->snd_wnd;
tcps_snd_ws = p == NULL ? -1 : p->snd_scale;
tcps_swl1 = p == NULL ? -1 : p->snd_wl1;
tcps_swl2 = p == NULL ? -1 : p->snd_wl2;
tcps_rwnd = p == NULL ? -1 : p->rcv_wnd;
tcps_rup = p == NULL ? -1 : p->rcv_up;
tcps_rcv_ws = p == NULL ? -1 : p->rcv_scale;
tcps_cwnd = p == NULL ? -1 : p->snd_cwnd;
tcps_cwnd_ssthresh = p == NULL ? -1 : p->snd_ssthresh;
@ -203,6 +212,8 @@ translator tcpsinfo_t < struct tcpcb *p > {
tcps_mss = p == NULL ? -1 : p->t_maxseg;
tcps_retransmit = p == NULL ? -1 : p->t_rxtshift > 0 ? 1 : 0;
tcps_srtt = p == NULL ? -1 : p->t_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */
tcps_debug = p == NULL ? 0 :
p->t_inpcb->inp_socket->so_options & 1;
};
#pragma D binding "1.6.3" translator
@ -242,3 +253,123 @@ translator tcpinfoh_t < struct tcphdr *p > {
translator tcplsinfo_t < int s > {
tcps_state = s;
};
/* Support for TCP debug */
#pragma D binding "1.12.1" TA_INPUT
inline int TA_INPUT = 0;
#pragma D binding "1.12.1" TA_OUTPUT
inline int TA_OUTPUT = 1;
#pragma D binding "1.12.1" TA_USER
inline int TA_USER = 2;
#pragma D binding "1.12.1" TA_RESPOND
inline int TA_RESPOND = 3;
#pragma D binding "1.12.1" TA_DROP
inline int TA_DROP = 4;
/* direction strings. */
#pragma D binding "1.12.1" tcpdebug_dir_string
inline string tcpdebug_dir_string[uint8_t direction] =
direction == TA_INPUT ? "input" :
direction == TA_OUTPUT ? "output" :
direction == TA_USER ? "user" :
direction == TA_RESPOND ? "respond" :
direction == TA_OUTPUT ? "drop" :
"unknown" ;
#pragma D binding "1.12.1" tcpflag_string
inline string tcpflag_string[uint8_t flags] =
flags & TH_FIN ? "FIN" :
flags & TH_SYN ? "SYN" :
flags & TH_RST ? "RST" :
flags & TH_PUSH ? "PUSH" :
flags & TH_ACK ? "ACK" :
flags & TH_URG ? "URG" :
flags & TH_ECE ? "ECE" :
flags & TH_CWR ? "CWR" :
"unknown" ;
#pragma D binding "1.12.1" PRU_ATTACH
inline int PRU_ATTACH = 0;
#pragma D binding "1.12.1" PRU_DETACH
inline int PRU_DETACH = 1;
#pragma D binding "1.12.1" PRU_BIND
inline int PRU_BIND = 2;
#pragma D binding "1.12.1" PRU_LISTEN
inline int PRU_LISTEN = 3;
#pragma D binding "1.12.1" PRU_CONNECT
inline int PRU_CONNECT = 4;
#pragma D binding "1.12.1" PRU_ACCEPT
inline int PRU_ACCEPT = 5 ;
#pragma D binding "1.12.1" PRU_DISCONNECT
inline int PRU_DISCONNECT= 6;
#pragma D binding "1.12.1" PRU_SHUTDOWN
inline int PRU_SHUTDOWN = 7;
#pragma D binding "1.12.1" PRU_RCVD
inline int PRU_RCVD = 8;
#pragma D binding "1.12.1" PRU_SEND
inline int PRU_SEND = 9;
#pragma D binding "1.12.1" PRU_ABORT
inline int PRU_ABORT = 10;
#pragma D binding "1.12.1" PRU_CONTROL
inline int PRU_CONTROL = 11;
#pragma D binding "1.12.1" PRU_SENSE
inline int PRU_SENSE = 12;
#pragma D binding "1.12.1" PRU_RCVOOB
inline int PRU_RCVOOB = 13;
#pragma D binding "1.12.1" PRU_SENDOOB
inline int PRU_SENDOOB = 14;
#pragma D binding "1.12.1" PRU_SOCKADDR
inline int PRU_SOCKADDR = 15;
#pragma D binding "1.12.1" PRU_PEERADDR
inline int PRU_PEERADDR = 16;
#pragma D binding "1.12.1" PRU_CONNECT2
inline int PRU_CONNECT2 = 17;
#pragma D binding "1.12.1" PRU_FASTTIMO
inline int PRU_FASTTIMO = 18;
#pragma D binding "1.12.1" PRU_SLOWTIMO
inline int PRU_SLOWTIMO = 19;
#pragma D binding "1.12.1" PRU_PROTORCV
inline int PRU_PROTORCV = 20;
#pragma D binding "1.12.1" PRU_PROTOSEND
inline int PRU_PROTOSEND = 21;
#pragma D binding "1.12.1" PRU_SEND_EOF
inline int PRU_SEND_EOF = 22;
#pragma D binding "1.12.1" PRU_SOSETLABEL
inline int PRU_SOSETLABEL = 23;
#pragma D binding "1.12.1" PRU_CLOSE
inline int PRU_CLOSE = 24;
#pragma D binding "1.12.1" PRU_FLUSH
inline int PRU_FLUSH = 25;
#pragma D binding "1.12.1" prureq_string
inline string prureq_string[uint8_t req] =
req == PRU_ATTACH ? "ATTACH" :
req == PRU_DETACH ? "DETACH" :
req == PRU_BIND ? "BIND" :
req == PRU_LISTEN ? "LISTEN" :
req == PRU_CONNECT ? "CONNECT" :
req == PRU_ACCEPT ? "ACCEPT" :
req == PRU_DISCONNECT ? "DISCONNECT" :
req == PRU_SHUTDOWN ? "SHUTDOWN" :
req == PRU_RCVD ? "RCVD" :
req == PRU_SEND ? "SEND" :
req == PRU_ABORT ? "ABORT" :
req == PRU_CONTROL ? "CONTROL" :
req == PRU_SENSE ? "SENSE" :
req == PRU_RCVOOB ? "RCVOOB" :
req == PRU_SENDOOB ? "SENDOOB" :
req == PRU_SOCKADDR ? "SOCKADDR" :
req == PRU_PEERADDR ? "PEERADDR" :
req == PRU_CONNECT2 ? "CONNECT2" :
req == PRU_FASTTIMO ? "FASTTIMO" :
req == PRU_SLOWTIMO ? "SLOWTIMO" :
req == PRU_PROTORCV ? "PROTORCV" :
req == PRU_PROTOSEND ? "PROTOSEND" :
req == PRU_SEND ? "SEND_EOF" :
req == PRU_SOSETLABEL ? "SOSETLABEL" :
req == PRU_CLOSE ? "CLOSE" :
req == PRU_FLUSH ? "FLUSE" :
"unknown" ;

View file

@ -6,7 +6,6 @@ SUBDIR= \
ctfconvert \
ctfdump \
ctfmerge \
sgsmsg \
${_tests} \
${_zinject} \
${_zlook} \

View file

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
cddl/lib/libctf \
gnu/lib/csu \

View file

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \

View file

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
cddl/lib/libctf \
gnu/lib/csu \

View file

@ -1,17 +0,0 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/sgs/tools/common
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/avl
# This program is required as a bootstrap tool for 'make buildworld'
PROG= sgsmsg
MAN=
SRCS= avl.c sgsmsg.c string_table.c findprime.c
WARNS?= 0
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
-I${.CURDIR}/../../../cddl/compat/opensolaris/include \
-I${OPENSOLARIS_USR_DISTDIR}/cmd/sgs/include \
-I${OPENSOLARIS_SYS_DISTDIR}/uts/common
.include <bsd.prog.mk>

View file

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
cddl/lib/libctf \
cddl/lib/libdtrace \

View file

@ -8,6 +8,7 @@ TESTFILES= \
tst.fds.ksh \
tst.func_access.ksh \
tst.getf.ksh \
tst.kpriv.ksh \
tst.op_access.ksh \
tst.procpriv.ksh \
tst.providers.ksh \

View file

@ -14,6 +14,8 @@ TESTFILES= \
err.D_OP_INCOMPAT.dupltype.d \
err.D_OP_INCOMPAT.dupttype.d \
err.D_SYNTAX.declare.d \
err.bigglobal.d \
err.biglocal.d \
tst.basicvar.d \
tst.basicvar.d.out \
tst.localvar.d \

View file

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \

View file

@ -1767,7 +1767,7 @@ print_insn_coprocessor (bfd_vma pc, struct disassemble_info *info, long given,
/* Is ``imm'' a negative number? */
if (imm & 0x40)
imm |= (-1 << 7);
imm |= -(1 << 7);
func (stream, "%d", imm);
}

View file

@ -18,3 +18,5 @@ END_COMPILERRT_FUNCTION(__aeabi_memcmp)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcmp4, __aeabi_memcmp)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcmp8, __aeabi_memcmp)
.section .note.GNU-stack,"",%progbits

View file

@ -18,3 +18,5 @@ END_COMPILERRT_FUNCTION(__aeabi_memcpy)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcpy4, __aeabi_memcpy)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcpy8, __aeabi_memcpy)
.section .note.GNU-stack,"",%progbits

View file

@ -18,3 +18,5 @@ END_COMPILERRT_FUNCTION(__aeabi_memmove)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memmove4, __aeabi_memmove)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memmove8, __aeabi_memmove)
.section .note.GNU-stack,"",%progbits

View file

@ -32,3 +32,4 @@ END_COMPILERRT_FUNCTION(__aeabi_memclr)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memclr4, __aeabi_memclr)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memclr8, __aeabi_memclr)
.section .note.GNU-stack,"",%progbits

View file

@ -248,7 +248,13 @@ translate(Dwarf_Debug dbg, const char* addrstr)
continue;
}
if (dwarf_srclines(die, &lbuf, &lcount, &de) != DW_DLV_OK) {
switch (dwarf_srclines(die, &lbuf, &lcount, &de)) {
case DW_DLV_OK:
break;
case DW_DLV_NO_ENTRY:
/* If one CU lacks debug info, just skip it. */
continue;
default:
warnx("dwarf_srclines: %s", dwarf_errmsg(de));
goto out;
}

View file

@ -272,7 +272,7 @@ static const char *ei_data[] = {
};
static const char *ei_abis[] = {
"ELFOSABI_SYSV", "ELFOSABI_HPUX", "ELFOSABI_NETBSD", "ELFOSABI_LINUX",
"ELFOSABI_NONE", "ELFOSABI_HPUX", "ELFOSABI_NETBSD", "ELFOSABI_LINUX",
"ELFOSABI_HURD", "ELFOSABI_86OPEN", "ELFOSABI_SOLARIS",
"ELFOSABI_MONTEREY", "ELFOSABI_IRIX", "ELFOSABI_FREEBSD",
"ELFOSABI_TRU64", "ELFOSABI_MODESTO", "ELFOSABI_OPENBSD"

View file

@ -414,8 +414,8 @@ elf_osabi(unsigned int abi)
static char s_abi[32];
switch(abi) {
case ELFOSABI_SYSV: return "SYSV";
case ELFOSABI_HPUX: return "HPUS";
case ELFOSABI_NONE: return "NONE";
case ELFOSABI_HPUX: return "HPUX";
case ELFOSABI_NETBSD: return "NetBSD";
case ELFOSABI_GNU: return "GNU";
case ELFOSABI_HURD: return "HURD";

View file

@ -1,3 +1,19 @@
2015-09-16 9:50 Christos Zoulas <christos@zoulas.com>
* release 5.25
2015-09-11 13:25 Christos Zoulas <christos@zoulas.com>
* add a limit to the length of regex searches
2015-09-08 9:50 Christos Zoulas <christos@zoulas.com>
* fix problems with --parameter (Christoph Biedl)
2015-07-11 10:35 Christos Zoulas <christos@zoulas.com>
* Windows fixes PR/466 (Jason Hood)
2015-07-09 10:35 Christos Zoulas <christos@zoulas.com>
* release 5.24

View file

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for file 5.24.
# Generated by GNU Autoconf 2.69 for file 5.25.
#
# Report bugs to <christos@astron.com>.
#
@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='file'
PACKAGE_TARNAME='file'
PACKAGE_VERSION='5.24'
PACKAGE_STRING='file 5.24'
PACKAGE_VERSION='5.25'
PACKAGE_STRING='file 5.25'
PACKAGE_BUGREPORT='christos@astron.com'
PACKAGE_URL=''
@ -1327,7 +1327,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures file 5.24 to adapt to many kinds of systems.
\`configure' configures file 5.25 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1397,7 +1397,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of file 5.24:";;
short | recursive ) echo "Configuration of file 5.25:";;
esac
cat <<\_ACEOF
@ -1507,7 +1507,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
file configure 5.24
file configure 5.25
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -2163,7 +2163,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by file $as_me 5.24, which was
It was created by file $as_me 5.25, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -3029,7 +3029,7 @@ fi
# Define the identity of the package.
PACKAGE='file'
VERSION='5.24'
VERSION='5.25'
cat >>confdefs.h <<_ACEOF
@ -15036,7 +15036,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by file $as_me 5.24, which was
This file was extended by file $as_me 5.25, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -15102,7 +15102,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
file config.status 5.24
file config.status 5.25
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View file

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT([file],[5.24],[christos@astron.com])
AC_INIT([file],[5.25],[christos@astron.com])
AM_INIT_AUTOMAKE([subdir-objects foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

View file

@ -1,5 +1,5 @@
.\" $File: file.man,v 1.117 2015/06/03 19:51:27 christos Exp $
.Dd June 3, 2015
.\" $File: file.man,v 1.118 2015/09/11 17:24:09 christos Exp $
.Dd September 11, 2015
.Dt FILE __CSECTION__
.Os
.Sh NAME
@ -316,6 +316,7 @@ Set various parameter limits.
.It Li elf_notes Ta 256 Ta max ELF notes processed
.It Li elf_phnum Ta 128 Ta max ELF program sections processed
.It Li elf_shnum Ta 32768 Ta max ELF sections processed
.It Li regex Ta 8192 Ta length limit for regex searches
.El
.It Fl r , Fl Fl raw
Don't translate unprintable characters to \eooo.

View file

@ -1,4 +1,4 @@
.\" $File: libmagic.man,v 1.37 2015/06/03 18:21:24 christos Exp $
.\" $File: libmagic.man,v 1.38 2015/09/11 17:24:09 christos Exp $
.\"
.\" Copyright (c) Christos Zoulas 2003.
.\" All Rights Reserved.
@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd June 3, 2015
.Dd September 11, 2015
.Dt LIBMAGIC 3
.Os
.Sh NAME
@ -291,6 +291,7 @@ library.
.It Li MAGIC_PARAM_ELF_NOTES_MAX Ta size_t Ta 256
.It Li MAGIC_PARAM_ELF_PHNUM_MAX Ta size_t Ta 128
.It Li MAGIC_PARAM_ELF_SHNUM_MAX Ta size_t Ta 32768
.It Li MAGIC_PARAM_REGEX_MAX Ta size_t Ta 8192
.El
.Pp
The

View file

@ -1,4 +1,4 @@
.\" $File: magic.man,v 1.85 2015/01/01 17:07:34 christos Exp $
.\" $File: magic.man,v 1.86 2015/09/08 13:48:44 christos Exp $
.Dd January 1, 2015
.Dt MAGIC __FSECTION__
.Os
@ -200,7 +200,7 @@ interpreted as a UNIX-style date, but interpreted as local time rather
than UTC.
.It Dv indirect
Starting at the given offset, consult the magic database again.
The offset of th
The offset of the
.Dv indirect
magic is by default absolute in the file, but one can specify
.Dv /r

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: adventure,v 1.14 2012/06/21 01:32:26 christos Exp $
# $File: adventure,v 1.15 2015/09/07 10:03:21 christos Exp $
# adventure: file(1) magic for Adventure game files
#
# from Allen Garvin <earendil@faeryland.tamu-commerce.edu>
@ -17,6 +17,7 @@
# Infocom (see z-machine)
#------------------------------------------------------------------------------
# Z-machine: file(1) magic for Z-machine binaries.
# Sanity checks by David Griffith <dave@661.org>
# Updated by Adam Buchbinder <adam.buchbinder@gmail.com>
#
#http://www.gnelson.demon.co.uk/zspec/sect11.html
@ -41,10 +42,12 @@
>>>>>>>2 ubeshort < 10 Release %d /
>>>>>>>>18 string >\0 Serial %.6s)
!:strength + 40
!:mime application/x-zmachine
#------------------------------------------------------------------------------
# Glulx: file(1) magic for Glulx binaries.
#
# David Griffith <dave@661.org>
# I haven't checked for false matches yet.
#
0 string Glul Glulx game data
@ -52,7 +55,7 @@
>>6 byte x \b.%d
>>8 byte x \b.%d)
>36 string Info Compiled by Inform
!:mime application/x-glulx
# For Quetzal and blorb magic see iff
@ -66,11 +69,13 @@
>9 belong !0x0A0D1A00 game data, CORRUPTED
>9 belong 0x0A0D1A00
>>13 string >\0 %s game data
!:mime application/x-tads
# Resource files start with "TADS2 rsc\n\r\032\0" then the compiler version.
0 string TADS2\ rsc TADS
>9 belong !0x0A0D1A00 resource data, CORRUPTED
>9 belong 0x0A0D1A00
>>13 string >\0 %s resource data
!:mime application/x-tads
# Some saved game files start with "TADS2 save/g\n\r\032\0", a little-endian
# 2-byte length N, the N-char name of the game file *without* a NUL (darn!),
# "TADS2 save\n\r\032\0" and the interpreter version.
@ -78,12 +83,14 @@
>12 belong !0x0A0D1A00 saved game data, CORRUPTED
>12 belong 0x0A0D1A00
>>(16.s+32) string >\0 %s saved game data
!:mime application/x-tads
# Other saved game files start with "TADS2 save\n\r\032\0" and the interpreter
# version.
0 string TADS2\ save TADS
>10 belong !0x0A0D1A00 saved game data, CORRUPTED
>10 belong 0x0A0D1A00
>>14 string >\0 %s saved game data
!:mime application/x-tads
# TADS (Text Adventure Development System) version 3
# Game files start with "T3-image\015\012\032"
@ -97,14 +104,18 @@
>>11 byte x \b%c
>>12 byte x \b%c
>>13 byte x \b%c)
!:mime application/x-t3vm-image
# edited by David Griffith <dave@661.org>
# Danny Milosavljevic <danny.milo@gmx.net>
# this are adrift (adventure game standard) game files, extension .taf
# depending on version magic continues with 0x93453E6139FA (V 4.0)
# 0x9445376139FA (V 3.90)
# 0x9445366139FA (V 3.80)
# this is from source (http://www.adrift.org.uk/) and I have some taf
# files, and checked them.
#0 belong 0x3C423FC9
#>4 belong 0x6A87C2CF Adrift game file
#!:mime application/x-adrift
# These are ADRIFT (adventure game standard) game files, extension .taf
# Checked from source at (http://www.adrift.co/) and various taf files
# found at the Interactive Fiction Archive (http://ifarchive.org/)
0 belong 0x3C423FC9
>4 belong 0x6A87C2CF Adrift game file version
>>8 belong 0x94453661 3.80
>>8 belong 0x94453761 3.90
>>8 belong 0x93453E61 4.0
>>8 belong 0x92453E61 5.0
>>8 default x unknown
!:mime application/x-adrift

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: apple,v 1.30 2015/04/13 13:09:06 christos Exp $
# $File: apple,v 1.31 2015/08/29 07:10:35 christos Exp $
# apple: file(1) magic for Apple file formats
#
0 search/1/t FiLeStArTfIlEsTaRt binscii (apple ][) text
@ -265,14 +265,14 @@
>>20 beshort x \b, descriptors %d
# Assume 8 partitions each at a multiple of the sector size.
# We could glean this from the partition descriptors, but they are empty!?!?
>>(2.S*1) indirect \b, contains[@0x%x]:
>>(2.S*2) indirect \b, contains[@0x%x]:
>>(2.S*3) indirect \b, contains[@0x%x]:
>>(2.S*4) indirect \b, contains[@0x%x]:
>>(2.S*5) indirect \b, contains[@0x%x]:
>>(2.S*6) indirect \b, contains[@0x%x]:
>>(2.S*7) indirect \b, contains[@0x%x]:
>>(2.S*8) indirect \b, contains[@0x%x]:
>>(2.S*1) indirect x \b, contains[@0x%x]:
>>(2.S*2) indirect x \b, contains[@0x%x]:
>>(2.S*3) indirect x \b, contains[@0x%x]:
>>(2.S*4) indirect x \b, contains[@0x%x]:
>>(2.S*5) indirect x \b, contains[@0x%x]:
>>(2.S*6) indirect x \b, contains[@0x%x]:
>>(2.S*7) indirect x \b, contains[@0x%x]:
>>(2.S*8) indirect x \b, contains[@0x%x]:
# Yes, the 3rd and 4th bytes are reserved, but we use them to make the
# magic stronger.

View file

@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
# $File: archive,v 1.90 2015/04/24 15:44:12 christos Exp $
# $File: archive,v 1.91 2015/09/16 13:49:33 christos Exp $
# archive: file(1) magic for archive formats (see also "msdos" for self-
# extracting compressed archives)
#
@ -434,16 +434,34 @@
# AIN
0 string \x33\x18 AIN archive data
0 string \x33\x17 AIN archive data
# XPA32
0 string xpa\0\1 XPA32 archive data
# XPA32 test moved and merged with XPA by Joerg Jenderek at Sep 2015
# SZip (TODO: doesn't catch all versions)
0 string SZ\x0a\4 SZip archive data
# XPack DiskImage
0 string jm XPack DiskImage archive data
# *.XDI updated by Joerg Jenderek Sep 2015
# ftp://ftp.sac.sk/pub/sac/pack/0index.txt
# GRR: this test is still too general as it catches also text files starting with jm
0 string jm
# only found examples with this additional characteristic 2 bytes
>2 string \x2\x4 Xpack DiskImage archive data
#!:ext xdi
# XPack Data
0 string xpa XPack archive data
# *.xpa updated by Joerg Jenderek Sep 2015
# ftp://ftp.elf.stuba.sk/pub/pc/pack/
0 string xpa XPA
!:ext xpa
# XPA32
# ftp://ftp.elf.stuba.sk/pub/pc/pack/xpa32.zip
# created by XPA32.EXE version 1.0.2 for Windows
>0 string xpa\0\1 \b32 archive data
# created by XPACK.COM version 1.67m or 1.67r with short 0x1800
>3 ubeshort !0x0001 \bck archive data
# XPack Single Data
0 string \xc3\x8d\ jm XPack single archive data
# changed by Joerg Jenderek Sep 2015 back to like in version 5.12
# letter 'I'+ acute accent is equivalent to \xcd
0 string \xcd\ jm Xpack single archive data
#!:mime application/x-xpa-compressed
!:ext xpa
# TODO: missing due to unknown magic/magic at end of file:
#DWC

View file

@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
# $File: c-lang,v 1.19 2014/06/03 19:17:27 christos Exp $
# $File: c-lang,v 1.20 2015/07/27 14:33:10 christos Exp $
# c-lang: file(1) magic for C and related languages programs
#
@ -29,7 +29,7 @@
# C++
# The strength of these rules is increased so they beat the C rules above
0 regex \^template[\ \t\n]+ C++ source text
0 regex \^template[\ \t]+<.*>[\ \t\n]+ C++ source text
!:strength + 5
!:mime text/x-c++
0 regex \^virtual[\ \t\n]+ C++ source text

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: c64,v 1.5 2009/09/19 16:28:08 christos Exp $
# $File: c64,v 1.6 2015/08/24 05:17:42 christos Exp $
# c64: file(1) magic for various commodore 64 related files
#
# From: Dirk Jagdmann <doj@cubic.org>
@ -41,3 +41,9 @@
>32 leshort x Version:0x%x
>36 leshort !0 Entries:%i
>40 string x Name:%.24s
# Raw tape file format (.tap files)
# Esa Hyyti <esa@netlab.tkk.fi>
0 string C64-TAPE-RAW C64 Raw Tape File (.tap),
>0x0c byte x Version:%u,
>0x10 lelong x Length:%u cycles

View file

@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
# $File: compress,v 1.63 2015/03/11 19:27:35 christos Exp $
# $File: compress,v 1.64 2015/07/27 15:41:09 christos Exp $
# compress: file(1) magic for pure-compression formats (no archives)
#
# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
@ -258,7 +258,8 @@
!:mime application/x-qpress
# Zlib https://www.ietf.org/rfc/rfc6713.txt
0 beshort%31 =0
>0 byte&0xf =8
>>0 byte&0x80 =0 zlib compressed data
0 string/b x
>0 beshort%31 =0
>>0 byte&0xf =8
>>>0 byte&0x80 =0 zlib compressed data
!:mime application/zlib

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: database,v 1.44 2015/07/02 18:25:57 christos Exp $
# $File: database,v 1.45 2015/09/09 16:25:29 christos Exp $
# database: file(1) magic for various databases
#
# extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
@ -541,3 +541,7 @@
# IDA (Interactive Disassembler) database
0 string IDA1 IDA (Interactive Disassembler) database
# Hopper (reverse engineering tool) http://www.hopperapp.com/
0 string hopperdb Hopper database

View file

@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
# $File: filesystems,v 1.109 2015/02/22 01:22:54 christos Exp $
# $File: filesystems,v 1.111 2015/09/09 16:26:54 christos Exp $
# filesystems: file(1) magic for different filesystems
#
0 name partid
@ -1721,7 +1721,7 @@
0x410 leshort 0x137f
!:strength / 2
>0x402 beshort < 100
>0x402 beshort > -1 Minix filesystem, V1, %d zones
>0x402 beshort > -1 Minix filesystem, V1, 14 char names, %d zones
>0x1e string minix \b, bootable
0x410 beshort 0x137f
!:strength / 2
@ -1740,27 +1740,26 @@
>0x1e string minix \b, bootable
0x410 leshort 0x2468
>0x402 beshort < 100
>>0x402 beshort > -1 Minix filesystem, V2, %d zones
>>0x402 beshort > -1 Minix filesystem, V2, 14 char names
>0x1e string minix \b, bootable
0x410 beshort 0x2468
>0x402 beshort < 100
>0x402 beshort > -1 Minix filesystem, V2 (big endian), %d zones
>0x1e string minix \b, bootable
0x410 leshort 0x2478
>0x402 beshort < 100
>0x402 beshort > -1 Minix filesystem, V2, 30 char names, %d zones
>0x402 beshort > -1 Minix filesystem, V2 (big endian)
>0x1e string minix \b, bootable
0x410 leshort 0x2478
>0x402 beshort < 100
>0x402 beshort > -1 Minix filesystem, V2, 30 char names, %d zones
>0x402 beshort > -1 Minix filesystem, V2, 30 char names
>0x1e string minix \b, bootable
0x410 leshort 0x2478
>0x402 beshort < 100
>0x402 beshort > -1 Minix filesystem, V2, 30 char names
>0x1e string minix \b, bootable
0x410 beshort 0x2478
>0x402 beshort !0 Minix filesystem, V2, 30 char names (big endian), %d zones
>0x1e string minix \b, bootable
0x410 leshort 0x4d5a
>0x402 beshort !0 Minix filesystem, V3, %d zones
>0x402 beshort !0 Minix filesystem, V2, 30 char names (big endian)
>0x1e string minix \b, bootable
0x418 leshort 0x4d5a
>0x402 beshort <100
>>0x402 beshort > -1 Minix filesystem, V3, 60 char names
# SGI disk labels - Nathan Scott <nathans@debian.org>
0 belong 0x0BE5A941 SGI disk label (volume header)
@ -2209,13 +2208,21 @@
>>0x10024 belong x (blocksize %d,
>>0x10060 string >\0 lockproto %s)
# BTRFS
0x10040 string _BHRfS_M BTRFS Filesystem
>0x1012b string >\0 (label "%s",
>0x10090 lelong x sectorsize %d,
>0x10094 lelong x nodesize %d,
>0x10098 lelong x leafsize %d)
# Russell Coker <russell@coker.com.au>
0x10040 string _BHRfS_M BTRFS Filesystem
>0x1012b string >\0 label "%s",
>0x10090 lelong x sectorsize %d,
>0x10094 lelong x nodesize %d,
>0x10098 lelong x leafsize %d,
>0x10020 belong x UUID=%8x-
>0x10024 beshort x \b%4x-
>0x10026 beshort x \b%4x-
>0x10028 beshort x \b%4x-
>0x1002a beshort x \b%4x
>0x1002c belong x \b%8x,
>0x10078 lequad x %lld/
>0x10070 lequad x \b%lld bytes used,
>0x10088 lequad x %lld devices
# dvdisaster's .ecc
# From: "Nelson A. de Oliveira" <naoliv@gmail.com>

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: frame,v 1.12 2009/09/19 16:28:09 christos Exp $
# $File: frame,v 1.13 2015/08/29 07:10:35 christos Exp $
# frame: file(1) magic for FrameMaker files
#
# This stuff came on a FrameMaker demo tape, most of which is
@ -41,10 +41,10 @@
>10 string 1.0 (1.0
>13 byte x %c)
# XXX - this book entry should be verified, if you find one, uncomment this
#0 string \<Book\ FrameMaker Book (ASCII) file
#0 string \<Book\040 FrameMaker Book (ASCII) file
#!:mime application/x-mif
#>6 string 3.0 (3.0)
#>6 string 2.0 (2.0)
#>6 string 1.0 (1.0)
0 string \<Maker Intermediate Print File FrameMaker IPL file
0 string \<Maker\040Intermediate\040Print\040File FrameMaker IPL file
!:mime application/x-mif

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: iff,v 1.13 2011/09/06 11:00:06 christos Exp $
# $File: iff,v 1.14 2015/09/07 10:03:21 christos Exp $
# iff: file(1) magic for Interchange File Format (see also "audio" & "images")
#
# Daniel Quinlan (quinlan@yggdrasil.com) -- IFF was designed by Electronic
@ -62,6 +62,7 @@
# These go at the end of the iff rules
#
# David Griffith <dave@661.org>
# I don't see why these might collide with anything else.
#
# Interactive Fiction related formats
@ -69,3 +70,4 @@
>8 string IFRS \b, Blorb Interactive Fiction
>>24 string Exec with executable chunk
>8 string IFZS \b, Z-machine or Glulx saved game file (Quetzal)
!:mime application/x-blorb

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: images,v 1.106 2015/02/22 01:26:05 christos Exp $
# $File: images,v 1.107 2015/07/11 14:40:10 christos Exp $
# images: file(1) magic for image formats (see also "iff", and "c-lang" for
# XPM bitmaps)
#
@ -37,7 +37,7 @@
# The next byte following the magic is always whitespace.
# strength is changed to try these patterns before "x86 boot sector"
0 name netpbm
>3 regex/s =[0-9]{1,50}\ [0-9]{1,50} Netpbm PPM image data
>3 regex/s =[0-9]{1,50}\ [0-9]{1,50} Netpbm image data
>>&0 regex =[0-9]{1,50} \b, size = %s x
>>>&0 regex =[0-9]{1,50} \b %s
@ -59,7 +59,6 @@
!:strength + 45
!:mime image/x-portable-pixmap
0 string P4
>0 use netpbm
>>0 string x \b, rawbits, bitmap

View file

@ -1,9 +1,9 @@
#------------------------------------------------------------------------------
# $File: karma,v 1.7 2014/04/30 21:41:02 christos Exp $
# $File: karma,v 1.8 2015/08/29 07:10:35 christos Exp $
# karma: file(1) magic for Karma data files
#
# From <rgooch@atnf.csiro.au>
0 string KarmaRHD Version Karma Data Structure Version
0 string KarmaRHD\040Version Karma Data Structure Version
>16 belong x %u

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: linux,v 1.62 2015/05/03 13:06:36 christos Exp $
# $File: linux,v 1.63 2015/08/24 05:16:11 christos Exp $
# linux: file(1) magic for Linux files
#
# Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com>
@ -417,6 +417,25 @@
0 lelong 0xde020109 locale archive
>24 lelong x %d strings
# Linux Software RAID (mdadm)
# Russell Coker <russell@coker.com.au>
0 name linuxraid
>16 belong x UUID=%8x:
>20 belong x \b%8x:
>24 belong x \b%8x:
>28 belong x \b%8x
>32 string x name=%s
>72 lelong x level=%d
>92 lelong x disks=%d
4096 lelong 0xa92b4efc Linux Software RAID
>4100 lelong x version 1.2 (%d)
>4096 use linuxraid
0 lelong 0xa92b4efc Linux Software RAID
>4 lelong x version 1.1 (%d)
>0 use linuxraid
# Summary: Database file for mlocate
# Description: A database file as used by mlocate, a fast implementation
# of locate/updatedb. It uses merging to reuse the existing

View file

@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
# $File: make,v 1.1 2011/12/08 12:12:46 rrt Exp $
# $File: make,v 1.2 2015/08/25 07:34:06 christos Exp $
# make: file(1) magic for makefiles
#
0 regex/100l \^CFLAGS makefile script text

View file

@ -1,7 +1,7 @@
#------------------------------------------------------------------------------
# $File: map,v 1.3 2015/07/09 15:16:41 christos Exp $
# $File: map,v 1.4 2015/08/10 05:18:27 christos Exp $
# map: file(1) magic for Map data
#
@ -25,3 +25,17 @@
>>53 byte 4 \b (Activity)
>>53 byte 8 \b (Elevations)
>>53 byte 10 \b (Totals)
# TOM TOM GPS watches ttbin files:
# http://github.com/ryanbinns/ttwatch/tree/master/ttbin
# From: Daniel Lenski
0 byte 0x20
>1 leshort 0x0007
>>0x76 byte 0x20
>>>0x77 leshort 0x0075 TomTom activity file, v7
>>>>8 leldate x (%s,
>>>>3 byte x device firmware %d.
>>>>4 byte x \b%d.
>>>>5 byte x \b%d,
>>>>6 leshort x product ID %04d)

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: msdos,v 1.100 2014/06/03 19:17:27 christos Exp $
# $File: msdos,v 1.101 2015/08/24 05:08:48 christos Exp $
# msdos: file(1) magic for MS-DOS files
#
@ -772,7 +772,7 @@
0 ulequad 0x3a000000024e4c MS Advisor help file
# HtmlHelp files (.chm)
0 string/b ITSF\003\000\000\000\x60\000\000\000\001\000\000\000 MS Windows HtmlHelp Data
0 string/b ITSF\003\000\000\000\x60\000\000\000 MS Windows HtmlHelp Data
# GFA-BASIC (Wolfram Kleff)
2 string/b GFA-BASIC3 GFA-BASIC 3 data

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: netscape,v 1.6 2009/09/19 16:28:11 christos Exp $
# $File: netscape,v 1.7 2015/08/24 05:20:52 christos Exp $
# netscape: file(1) magic for Netscape files
# "H. Nanosecond" <aldomel@ix.netcom.com>
# version 3 and 4 I think
@ -22,4 +22,5 @@
#
#This is files ending in .art, FIXME add more rules
0 string JG\004\016\0\0\0\0 ART
0 string JG\004\016\0\0\0\0 AOL ART image
0 string JG\003\016\0\0\0\0 AOL ART image

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: python,v 1.26 2014/08/04 05:58:40 christos Exp $
# $File: python,v 1.27 2015/09/08 13:59:44 christos Exp $
# python: file(1) magic for python
#
# Outlook puts """ too for urgent messages
@ -26,12 +26,16 @@
0 belong 0xee0c0d0a python 3.4 byte-compiled
0 search/1/w #!\ /usr/bin/python Python script text executable
!:strength + 10
!:mime text/x-python
0 search/1/w #!\ /usr/local/bin/python Python script text executable
!:strength + 10
!:mime text/x-python
0 search/1 #!/usr/bin/env\ python Python script text executable
!:strength + 10
!:mime text/x-python
0 search/1 #!\ /usr/bin/env\ python Python script text executable
0 search/10 #!\ /usr/bin/env\ python Python script text executable
!:strength + 10
!:mime text/x-python

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: scientific,v 1.9 2014/06/03 19:01:34 christos Exp $
# $File: scientific,v 1.10 2015/08/24 05:18:55 christos Exp $
# scientific: file(1) magic for scientific formats
#
# From: Joe Krahn <krahn@niehs.nih.gov>
@ -104,3 +104,8 @@
>>5 byte x version %d.0
>4 byte >0x00 version %d
>>5 byte x \b.%d
# Type: LXT (interLaced eXtensible Trace)
# chrysn <chrysn@fsfe.org>
0 beshort 0x0138 interLaced eXtensible Trace (LXT) file
>2 beshort >0 (Version %u)

View file

@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# $File: sgi,v 1.21 2014/04/30 21:41:02 christos Exp $
# $File: sgi,v 1.22 2015/08/29 07:10:35 christos Exp $
# sgi: file(1) magic for Silicon Graphics operating systems and applications
#
# Executable images are handled either in aout (for old-style a.out
@ -55,8 +55,8 @@
0 string WNGZWZSS Wingz spreadsheet
0 string WNGZWZHP Wingz help file
#
0 string #Inventor V IRIS Inventor 1.0 file
0 string #Inventor V2 Open Inventor 2.0 file
0 string #Inventor\040V IRIS Inventor 1.0 file
0 string #Inventor\040V2 Open Inventor 2.0 file
# GLF is OpenGL stream encoding
0 string glfHeadMagic(); GLF_TEXT
4 belong 0x7d000000 GLF_BINARY_LSB_FIRST

View file

@ -1,5 +1,4 @@
#------------------------------------------------------------------------------
# $File: sgml,v 1.31 2015/03/11 19:38:04 christos Exp $
#------------------------------------------------------------------------------ # $File: sgml,v 1.32 2015/07/11 15:08:53 christos Exp $
# Type: SVG Vectorial Graphics
# From: Noel Torres <tecnico@ejerciciosresueltos.com>
0 string \<?xml\ version="
@ -24,16 +23,16 @@
# xhtml
0 string/t \<?xml\ version="
>15 string >\0
>>19 search/4096/cWbt \<!doctype\ html XHTML document text
>19 search/4096/cWbt \<!doctype\ html XHTML document text
>>15 string >\0 (version %.3s)
!:mime text/html
0 string/t \<?xml\ version='
>15 string >\0
>>19 search/4096/cWbt \<!doctype\ html XHTML document text
>19 search/4096/cWbt \<!doctype\ html XHTML document text
>>15 string >\0 (version %.3s)
!:mime text/html
0 string/t \<?xml\ version="
>15 string >\0
>>19 search/4096/cWbt \<html broken XHTML document text
>19 search/4096/cWbt \<html broken XHTML document text
>>15 string >\0 (version %.3s)
!:mime text/html
#------------------------------------------------------------------------------
@ -106,9 +105,6 @@
>15 string/t >\0 %.3s document text
>>23 search/1 \<xsl:stylesheet (XSL stylesheet)
>>24 search/1 \<xsl:stylesheet (XSL stylesheet)
0 search/1/wbt \<?xml XML document text
!:mime application/xml
!:strength - 10
0 search/1/wt \<?XML broken XML document text
!:mime application/xml
!:strength - 10

Some files were not shown because too many files have changed in this diff Show more