aboutsummaryrefslogtreecommitdiff
path: root/cddl/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/usr.bin')
-rw-r--r--cddl/usr.bin/Makefile17
-rw-r--r--cddl/usr.bin/Makefile.inc3
-rw-r--r--cddl/usr.bin/ctfconvert/Makefile47
-rw-r--r--cddl/usr.bin/ctfconvert/Makefile.depend20
-rw-r--r--cddl/usr.bin/ctfconvert/ctfconvert.191
-rw-r--r--cddl/usr.bin/ctfconvert/tests/Makefile3
-rw-r--r--cddl/usr.bin/ctfconvert/tests/ctfconvert_test.sh61
-rw-r--r--cddl/usr.bin/ctfdump/Makefile28
-rw-r--r--cddl/usr.bin/ctfdump/Makefile.depend17
-rw-r--r--cddl/usr.bin/ctfdump/ctfdump.182
-rw-r--r--cddl/usr.bin/ctfmerge/Makefile44
-rw-r--r--cddl/usr.bin/ctfmerge/Makefile.depend19
-rw-r--r--cddl/usr.bin/ctfmerge/ctfmerge.1119
-rw-r--r--cddl/usr.bin/tests/Makefile4
-rw-r--r--cddl/usr.bin/tests/Makefile.depend10
-rw-r--r--cddl/usr.bin/zinject/Makefile28
-rw-r--r--cddl/usr.bin/zinject/Makefile.depend26
-rw-r--r--cddl/usr.bin/zstream/Makefile38
-rw-r--r--cddl/usr.bin/ztest/Makefile37
-rw-r--r--cddl/usr.bin/ztest/Makefile.depend28
-rw-r--r--cddl/usr.bin/ztest/tests/Makefile5
-rwxr-xr-xcddl/usr.bin/ztest/tests/ztest.sh51
22 files changed, 778 insertions, 0 deletions
diff --git a/cddl/usr.bin/Makefile b/cddl/usr.bin/Makefile
new file mode 100644
index 000000000000..571d1c59a544
--- /dev/null
+++ b/cddl/usr.bin/Makefile
@@ -0,0 +1,17 @@
+.include <src.opts.mk>
+
+SUBDIR.${MK_DTRACE}+= \
+ ctfconvert \
+ ctfdump \
+ ctfmerge
+
+SUBDIR.${MK_TESTS}+= tests
+
+SUBDIR.${MK_ZFS}+= \
+ zinject \
+ ztest \
+ zstream
+
+SUBDIR_PARALLEL=
+
+.include <bsd.subdir.mk>
diff --git a/cddl/usr.bin/Makefile.inc b/cddl/usr.bin/Makefile.inc
new file mode 100644
index 000000000000..b87015c546ca
--- /dev/null
+++ b/cddl/usr.bin/Makefile.inc
@@ -0,0 +1,3 @@
+BINDIR?= /usr/bin
+
+.include "../Makefile.inc"
diff --git a/cddl/usr.bin/ctfconvert/Makefile b/cddl/usr.bin/ctfconvert/Makefile
new file mode 100644
index 000000000000..cd9f850f480c
--- /dev/null
+++ b/cddl/usr.bin/ctfconvert/Makefile
@@ -0,0 +1,47 @@
+.include <src.opts.mk>
+
+.PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/common
+.PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/cvt
+
+PACKAGE= ctf-tools
+PROG= ctfconvert
+SRCS= alist.c \
+ ctf.c \
+ ctfconvert.c \
+ dwarf.c \
+ fixup_tdescs.c \
+ hash.c \
+ iidesc.c \
+ input.c \
+ list.c \
+ memory.c \
+ merge.c \
+ output.c \
+ stack.c \
+ strtab.c \
+ symbol.c \
+ tdata.c \
+ traverse.c \
+ util.c
+
+CFLAGS+= -DIN_BASE
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd
+CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
+CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris \
+ -I${SRCTOP}/cddl/compat/opensolaris/include \
+ -I${OPENSOLARIS_USR_DISTDIR} \
+ -I${OPENSOLARIS_SYS_DISTDIR} \
+ -I${OPENSOLARIS_USR_DISTDIR}/head \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+CFLAGS+= -DHAVE_ISSETUGID
+
+LIBADD= spl dwarf elf z pthread
+
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
+.include <bsd.prog.mk>
diff --git a/cddl/usr.bin/ctfconvert/Makefile.depend b/cddl/usr.bin/ctfconvert/Makefile.depend
new file mode 100644
index 000000000000..69aabda6c27e
--- /dev/null
+++ b/cddl/usr.bin/ctfconvert/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ cddl/lib/libspl \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libdwarf \
+ lib/libelf \
+ lib/libthr \
+ lib/libz \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/cddl/usr.bin/ctfconvert/ctfconvert.1 b/cddl/usr.bin/ctfconvert/ctfconvert.1
new file mode 100644
index 000000000000..8baf9895b0e1
--- /dev/null
+++ b/cddl/usr.bin/ctfconvert/ctfconvert.1
@@ -0,0 +1,91 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2010 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" This software was developed by Rui Paulo under sponsorship from the
+.\" FreeBSD Foundation.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. 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 AUTHOR 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 AUTHOR 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.
+.\"
+.Dd April 21, 2022
+.Dt CTFCONVERT 1
+.Os
+.Sh NAME
+.Nm ctfconvert
+.Nd convert debug data to Compact C Type Format data
+.Sh SYNOPSIS
+.Nm
+.Op Fl gis
+.Fl L Ar labelenv
+.Fl l Ar label
+.Op Fl o Ar outfile
+object_file
+.Sh DESCRIPTION
+The
+.Nm
+utility converts debug information from a binary file to CTF
+.Pq Compact C Type Format
+data and replaces the debug section of that file with a CTF section
+called SUNW_ctf.
+This new section is added to the input file, unless the
+.Fl o
+option is present.
+You can also opt to keep the original debugging section with the
+.Fl g
+option.
+.Pp
+The following options are available:
+.Bl -tag -width "-L labelenv"
+.It Fl g
+Don't delete the original debugging section.
+.It Fl i
+Ignore object files built from other languages than C.
+.It Fl L Ar labelenv
+Instructs
+.Nm
+to read the label from the
+.Ev labelenv
+environment variable.
+.It Fl l Ar label
+Sets the label as
+.Ar label .
+.It Fl o Ar outfile
+Write the output to file in
+.Ar outfile .
+.It Fl s
+Use the .dynsym ELF section instead of the .symtab ELF section.
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh SEE ALSO
+.Xr ctfdump 1 ,
+.Xr ctfmerge 1 ,
+.Xr ctf 5
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Fx 7.0 .
+.Sh AUTHORS
+The CTF utilities came from OpenSolaris.
diff --git a/cddl/usr.bin/ctfconvert/tests/Makefile b/cddl/usr.bin/ctfconvert/tests/Makefile
new file mode 100644
index 000000000000..d86ddbcd635f
--- /dev/null
+++ b/cddl/usr.bin/ctfconvert/tests/Makefile
@@ -0,0 +1,3 @@
+ATF_TESTS_SH+= ctfconvert_test
+
+.include <bsd.test.mk>
diff --git a/cddl/usr.bin/ctfconvert/tests/ctfconvert_test.sh b/cddl/usr.bin/ctfconvert/tests/ctfconvert_test.sh
new file mode 100644
index 000000000000..f19383cfbb4f
--- /dev/null
+++ b/cddl/usr.bin/ctfconvert/tests/ctfconvert_test.sh
@@ -0,0 +1,61 @@
+#
+# Copyright 2017 Shivansh
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. 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 AUTHOR 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 AUTHOR 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.
+#
+#
+
+usage_output='Usage: ctfconvert'
+
+atf_test_case invalid_usage
+invalid_usage_head()
+{
+ atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message"
+}
+
+invalid_usage_body()
+{
+ atf_check -s not-exit:0 -e match:"$usage_output" ctfconvert -l
+ atf_check -s not-exit:0 -e match:"$usage_output" ctfconvert -L
+ atf_check -s not-exit:0 -e match:"$usage_output" ctfconvert -g
+ atf_check -s not-exit:0 -e match:"$usage_output" ctfconvert -i
+ atf_check -s not-exit:0 -e match:"$usage_output" ctfconvert -s
+ atf_check -s not-exit:0 -e match:"$usage_output" ctfconvert -o
+}
+
+atf_test_case no_arguments
+no_arguments_head()
+{
+ atf_set "descr" "Verify that ctfconvert(1) fails and generates a valid usage message when no arguments are supplied"
+}
+
+no_arguments_body()
+{
+ atf_check -s not-exit:0 -e match:"$usage_output" ctfconvert
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case invalid_usage
+ atf_add_test_case no_arguments
+}
diff --git a/cddl/usr.bin/ctfdump/Makefile b/cddl/usr.bin/ctfdump/Makefile
new file mode 100644
index 000000000000..23ded7458bed
--- /dev/null
+++ b/cddl/usr.bin/ctfdump/Makefile
@@ -0,0 +1,28 @@
+.PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/common
+.PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/dump
+
+PACKAGE= ctf-tools
+PROG= ctfdump
+SRCS= dump.c \
+ symbol.c \
+ utils.c
+
+CFLAGS+= -DIN_BASE
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd
+CFLAGS+= -I${SRCTOP}/sys
+CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
+CFLAGS+= -I${OPENSOLARIS_USR_DISTDIR} \
+ -I${OPENSOLARIS_SYS_DISTDIR} \
+ -I${OPENSOLARIS_USR_DISTDIR}/head \
+ -I${OPENSOLARIS_USR_DISTDIR}/cmd/mdb/tools/common \
+ -I${SRCTOP}/sys/cddl/compat/opensolaris \
+ -I${SRCTOP}/cddl/compat/opensolaris/include \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+CFLAGS+= -DHAVE_ISSETUGID
+
+LIBADD= elf z
+
+.include <bsd.prog.mk>
diff --git a/cddl/usr.bin/ctfdump/Makefile.depend b/cddl/usr.bin/ctfdump/Makefile.depend
new file mode 100644
index 000000000000..edb476e399d9
--- /dev/null
+++ b/cddl/usr.bin/ctfdump/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libelf \
+ lib/libz \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/cddl/usr.bin/ctfdump/ctfdump.1 b/cddl/usr.bin/ctfdump/ctfdump.1
new file mode 100644
index 000000000000..27dfe6563645
--- /dev/null
+++ b/cddl/usr.bin/ctfdump/ctfdump.1
@@ -0,0 +1,82 @@
+.\"
+.\" Copyright (c) 2010 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" This software was developed by Rui Paulo under sponsorship from the
+.\" FreeBSD Foundation.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. 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 AUTHOR 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 AUTHOR 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.
+.\"
+.Dd April 21, 2022
+.Dt CTFDUMP 1
+.Os
+.Sh NAME
+.Nm ctfdump
+.Nd dump the SUNW_ctf section of an ELF file
+.Sh SYNOPSIS
+.Nm
+.Op Fl dfhlsSt
+.Fl u Ar file
+file
+.Sh DESCRIPTION
+The
+.Nm
+utility dumps the contents of the CTF (Compact C Type Format) data section
+(SUNW_ctf) present in an ELF binary file.
+This section was previously created with
+.Xr ctfconvert 1
+or
+.Xr ctfmerge 1 .
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl d
+Show the data object section.
+.It Fl f
+Show the function section.
+.It Fl h
+Show the header.
+.It Fl l
+Show the label section.
+.It Fl s
+Show the string table.
+.It Fl S
+Show statistics.
+.It Fl t
+Show the type section.
+.It Fl u Ar ufile
+Write the uncompressed CTF data to a raw CTF file called
+.Ar ufile .
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh SEE ALSO
+.Xr ctfconvert 1 ,
+.Xr ctfmerge 1 ,
+.Xr ctf 5
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Fx 7.0 .
+.Sh AUTHORS
+The CTF utilities came from OpenSolaris.
diff --git a/cddl/usr.bin/ctfmerge/Makefile b/cddl/usr.bin/ctfmerge/Makefile
new file mode 100644
index 000000000000..4cd9511f911c
--- /dev/null
+++ b/cddl/usr.bin/ctfmerge/Makefile
@@ -0,0 +1,44 @@
+.PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/common
+.PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/cvt
+
+PACKAGE= ctf-tools
+PROG= ctfmerge
+SRCS= alist.c \
+ barrier.c \
+ ctf.c \
+ ctfmerge.c \
+ fifo.c \
+ hash.c \
+ iidesc.c \
+ input.c \
+ list.c \
+ memory.c \
+ merge.c \
+ output.c \
+ strtab.c \
+ symbol.c \
+ tdata.c \
+ traverse.c \
+ util.c
+
+WARNS?= 1
+
+
+CFLAGS+= -DIN_BASE
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd
+CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
+CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris \
+ -I${SRCTOP}/cddl/compat/opensolaris/include \
+ -I${OPENSOLARIS_USR_DISTDIR} \
+ -I${OPENSOLARIS_SYS_DISTDIR} \
+ -I${OPENSOLARIS_USR_DISTDIR}/head \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+CFLAGS+= -DHAVE_ISSETUGID
+
+LIBADD= spl elf z pthread
+
+.include <bsd.prog.mk>
diff --git a/cddl/usr.bin/ctfmerge/Makefile.depend b/cddl/usr.bin/ctfmerge/Makefile.depend
new file mode 100644
index 000000000000..e724f22559ff
--- /dev/null
+++ b/cddl/usr.bin/ctfmerge/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ cddl/lib/libspl \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libelf \
+ lib/libthr \
+ lib/libz \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/cddl/usr.bin/ctfmerge/ctfmerge.1 b/cddl/usr.bin/ctfmerge/ctfmerge.1
new file mode 100644
index 000000000000..2bc70db82dc9
--- /dev/null
+++ b/cddl/usr.bin/ctfmerge/ctfmerge.1
@@ -0,0 +1,119 @@
+.\"
+.\" Copyright (c) 2010 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" This software was developed by Rui Paulo under sponsorship from the
+.\" FreeBSD Foundation.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. 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 AUTHOR 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 AUTHOR 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.
+.\"
+.Dd April 21, 2022
+.Dt CTFMERGE 1
+.Os
+.Sh NAME
+.Nm ctfmerge
+.Nd merge several CTF data sections into one
+.Sh SYNOPSIS
+.Nm
+.Op Fl fgstv
+.Fl l Ar label
+.Fl L Ar labelenv
+.Fl o Ar outfile
+file ...
+.Nm
+.Op Fl fgstv
+.Fl l Ar label
+.Fl L Ar labelenv
+.Fl o Ar outfile
+.Fl d Ar uniqfile
+.Op Fl g
+.Op Fl D Ar uniqlabel
+file ...
+.Nm
+.Op Fl fgstv
+.Fl l Ar label
+.Fl L Ar labelenv
+.Fl o Ar outfile
+.Fl w Ar withfile
+file ...
+.Nm
+.Op Fl g
+.Fl c Ar srcfile
+.Ar destfile
+.Sh DESCRIPTION
+The
+.Nm
+utility merges several CTF (Compact C Type Format) data sections from several
+files into one output file, unifying common data.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl f
+Match global symbols to global CTF data.
+.It Fl g
+Don't delete the original debugging sections.
+.It Fl s
+Use the .dynsym ELF section instead of the .symtab ELF section.
+.It Fl t
+Make sure that all object files have a CTF section.
+.It Fl v
+Enable verbose mode.
+.It Fl l Ar label
+Sets the label as
+.Ar label .
+.It Fl L Ar labelenv
+Instructs
+.Nm
+to read the label from the environment variable
+.Ar labelenv .
+.It Fl o Ar outfile
+Use
+.Ar outfile
+to store the merged CTF data.
+.It Fl d Ar uniqfile
+Uniquify against
+.Ar uniqfile .
+.It Fl d Ar uniqlabel
+Uniquify against label
+.Ar uniqlabel
+.It Fl w Ar withfile
+Additive merge with
+.Ar withfile .
+.It Fl c Ar srcfile Ar destfile
+Copy CTF data from
+.Ar srcfile
+into
+.Ar destfile .
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh SEE ALSO
+.Xr ctfconvert 1 ,
+.Xr ctfdump 1 ,
+.Xr ctf 5
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Fx 7.0 .
+.Sh AUTHORS
+The CTF utilities came from OpenSolaris.
diff --git a/cddl/usr.bin/tests/Makefile b/cddl/usr.bin/tests/Makefile
new file mode 100644
index 000000000000..29b1b564beca
--- /dev/null
+++ b/cddl/usr.bin/tests/Makefile
@@ -0,0 +1,4 @@
+.PATH: ${SRCTOP}/tests
+KYUAFILE= yes
+
+.include <bsd.test.mk>
diff --git a/cddl/usr.bin/tests/Makefile.depend b/cddl/usr.bin/tests/Makefile.depend
new file mode 100644
index 000000000000..11aba52f82cf
--- /dev/null
+++ b/cddl/usr.bin/tests/Makefile.depend
@@ -0,0 +1,10 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/cddl/usr.bin/zinject/Makefile b/cddl/usr.bin/zinject/Makefile
new file mode 100644
index 000000000000..921d4df7a651
--- /dev/null
+++ b/cddl/usr.bin/zinject/Makefile
@@ -0,0 +1,28 @@
+ZFSTOP= ${SRCTOP}/sys/contrib/openzfs
+
+.PATH: ${ZFSTOP}/cmd/zinject
+.PATH: ${ZFSTOP}/man/man8
+
+PACKAGE= zfs
+PROG= zinject
+INCS= zinject.h
+SRCS= zinject.c translate.c
+MAN= zinject.8
+
+WARNS?= 2
+CFLAGS+= \
+ -DIN_BASE \
+ -I${ZFSTOP}/include \
+ -I${ZFSTOP}/lib/libspl/include \
+ -I${ZFSTOP}/lib/libspl/include/os/freebsd \
+ -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include \
+ -I${SRCTOP}/sys \
+ -I${SRCTOP}/cddl/compat/opensolaris/include \
+ -I${ZFSTOP}/module/icp/include \
+ -include ${ZFSTOP}/include/os/freebsd/spl/sys/ccompile.h \
+ -DHAVE_ISSETUGID \
+ -include ${SRCTOP}/sys/modules/zfs/zfs_config.h
+
+LIBADD= geom m nvpair umem uutil avl spl zfs_core zfs zutil zpool
+
+.include <bsd.prog.mk>
diff --git a/cddl/usr.bin/zinject/Makefile.depend b/cddl/usr.bin/zinject/Makefile.depend
new file mode 100644
index 000000000000..c36e0e5ad2e7
--- /dev/null
+++ b/cddl/usr.bin/zinject/Makefile.depend
@@ -0,0 +1,26 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ cddl/lib/libavl \
+ cddl/lib/libnvpair \
+ cddl/lib/libspl \
+ cddl/lib/libumem \
+ cddl/lib/libuutil \
+ cddl/lib/libzfs \
+ cddl/lib/libzfs_core \
+ cddl/lib/libzpool \
+ cddl/lib/libzutil \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libgeom \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/cddl/usr.bin/zstream/Makefile b/cddl/usr.bin/zstream/Makefile
new file mode 100644
index 000000000000..b131901cb6a9
--- /dev/null
+++ b/cddl/usr.bin/zstream/Makefile
@@ -0,0 +1,38 @@
+ZFSTOP= ${SRCTOP}/sys/contrib/openzfs
+
+.PATH: ${ZFSTOP}/cmd/zstream
+.PATH: ${ZFSTOP}/man/man8
+
+PACKAGE= zfs
+PROG= zstream
+MAN= zstream.8
+MLINKS= zstream.8 zstreamdump.8
+INCS= zstream.h
+SRCS= \
+ zstream.c \
+ zstream_decompress.c \
+ zstream_dump.c \
+ zstream_recompress.c \
+ zstream_redup.c \
+ zstream_token.c
+
+SYMLINKS= zstream ${BINDIR}/zstreamdump
+
+WARNS?= 2
+CFLAGS+= \
+ -DIN_BASE \
+ -DZFS_DEBUG \
+ -I${ZFSTOP}/include \
+ -I${ZFSTOP}/lib/libspl/include \
+ -I${ZFSTOP}/lib/libspl/include/os/freebsd \
+ -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include \
+ -I${SRCTOP}/sys \
+ -I${SRCTOP}/cddl/compat/opensolaris/include \
+ -I${ZFSTOP}/module/icp/include \
+ -include ${ZFSTOP}/include/os/freebsd/spl/sys/ccompile.h \
+ -DHAVE_ISSETUGID \
+ -include ${SRCTOP}/sys/modules/zfs/zfs_config.h
+
+LIBADD= geom m nvpair umem uutil avl spl zfs_core zfs zutil zpool
+
+.include <bsd.prog.mk>
diff --git a/cddl/usr.bin/ztest/Makefile b/cddl/usr.bin/ztest/Makefile
new file mode 100644
index 000000000000..ef4bd561b41a
--- /dev/null
+++ b/cddl/usr.bin/ztest/Makefile
@@ -0,0 +1,37 @@
+.include <src.opts.mk>
+
+ZFSTOP= ${SRCTOP}/sys/contrib/openzfs
+
+.PATH: ${ZFSTOP}/cmd
+.PATH: ${ZFSTOP}/man/man1
+
+PACKAGE= zfs
+PROG= ztest
+MAN= ztest.1
+
+WARNS?= 2
+CFLAGS+= \
+ -DIN_BASE \
+ -I${ZFSTOP}/include \
+ -I${ZFSTOP}/lib/libspl/include \
+ -I${ZFSTOP}/lib/libspl/include/os/freebsd \
+ -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include \
+ -I${SRCTOP}/cddl/compat/opensolaris/include \
+ -I${ZFSTOP}/module/icp/include \
+ -include ${ZFSTOP}/include/os/freebsd/spl/sys/ccompile.h \
+ -DHAVE_ISSETUGID \
+ -include ${SRCTOP}/sys/modules/zfs/zfs_config.h
+
+LIBADD= geom m nvpair umem zpool pthread avl zfs_core spl zutil zfs uutil icp
+
+CSTD= c99
+
+# Since there are many asserts in this program, it makes no sense to compile
+# it without debugging.
+CFLAGS+= -g -DDEBUG=1 -Wno-format -DZFS_DEBUG=1
+CFLAGS.gcc+= -fms-extensions
+
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
+.include <bsd.prog.mk>
diff --git a/cddl/usr.bin/ztest/Makefile.depend b/cddl/usr.bin/ztest/Makefile.depend
new file mode 100644
index 000000000000..dd387951fe20
--- /dev/null
+++ b/cddl/usr.bin/ztest/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ cddl/lib/libavl \
+ cddl/lib/libicp \
+ cddl/lib/libnvpair \
+ cddl/lib/libspl \
+ cddl/lib/libumem \
+ cddl/lib/libuutil \
+ cddl/lib/libzfs \
+ cddl/lib/libzfs_core \
+ cddl/lib/libzpool \
+ cddl/lib/libzutil \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libgeom \
+ lib/libthr \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/cddl/usr.bin/ztest/tests/Makefile b/cddl/usr.bin/ztest/tests/Makefile
new file mode 100644
index 000000000000..88bcfc3ccf72
--- /dev/null
+++ b/cddl/usr.bin/ztest/tests/Makefile
@@ -0,0 +1,5 @@
+.include <bsd.own.mk>
+
+ATF_TESTS_SH+= ztest
+
+.include <bsd.test.mk>
diff --git a/cddl/usr.bin/ztest/tests/ztest.sh b/cddl/usr.bin/ztest/tests/ztest.sh
new file mode 100755
index 000000000000..8bc377917992
--- /dev/null
+++ b/cddl/usr.bin/ztest/tests/ztest.sh
@@ -0,0 +1,51 @@
+#
+# Test Case: ztest
+#
+atf_test_case ztest
+ztest_head()
+{
+ atf_set "descr" "Run ztest"
+ atf_set "timeout" 900
+ atf_set "require.config" "rt_long"
+}
+
+ztest_body()
+{
+ ARGS="-VVVVV -f ${TMPDIR:-/tmp}"
+ if atf_config_has ztest_extra_args; then
+ ARGS="${ARGS} $(atf_config_get ztest_extra_args)"
+ fi
+ ztest ${ARGS}
+ if [ $? != 0 ]; then
+ echo "failing"
+ save_ztest_artifacts
+ atf_fail "Testcase failed"
+ else
+ echo "passing"
+ atf_pass
+ fi
+}
+
+#
+# ATF Test Program Init Function
+#
+atf_init_test_cases()
+{
+ atf_add_test_case ztest
+}
+
+save_ztest_artifacts()
+{
+ # If artifacts_dir is defined, save test artifacts for
+ # post-mortem analysis
+ if atf_config_has artifacts_dir; then
+ TC_ARTIFACTS_DIR=`atf_config_get artifacts_dir`/cddl/usr.bin/ztest/$(atf_get ident)
+ mkdir -p $TC_ARTIFACTS_DIR
+ TC_CORE_DIR=/var/crash
+ if atf_config_has core_dir; then
+ TC_CORE_DIR=`atf_config_get core_dir`
+ fi
+ mv *ztest*.core* $TC_ARTIFACTS_DIR || true
+ mv ${TC_CORE_DIR}/*ztest*.core* $TC_ARTIFACTS_DIR || true
+ fi
+}