summaryrefslogtreecommitdiffstats
path: root/cddl/lib
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/lib')
-rw-r--r--cddl/lib/Makefile30
-rw-r--r--cddl/lib/Makefile.inc6
-rw-r--r--cddl/lib/drti/Makefile21
-rw-r--r--cddl/lib/libavl/Makefile11
-rw-r--r--cddl/lib/libctf/Makefile31
-rw-r--r--cddl/lib/libdtrace/Makefile113
-rw-r--r--cddl/lib/libdtrace/errno.d228
-rw-r--r--cddl/lib/libdtrace/io.d110
-rw-r--r--cddl/lib/libdtrace/libproc_compat.h62
-rw-r--r--cddl/lib/libdtrace/net.d43
-rw-r--r--cddl/lib/libdtrace/nfs.d96
-rw-r--r--cddl/lib/libdtrace/psinfo.d97
-rw-r--r--cddl/lib/libdtrace/regs_x86.d121
-rw-r--r--cddl/lib/libdtrace/sched.d86
-rw-r--r--cddl/lib/libdtrace/signal.d101
-rw-r--r--cddl/lib/libdtrace/unistd.d56
-rw-r--r--cddl/lib/libnvpair/Makefile24
-rw-r--r--cddl/lib/libumem/Makefile10
-rw-r--r--cddl/lib/libuutil/Makefile26
-rw-r--r--cddl/lib/libzfs/Makefile61
-rw-r--r--cddl/lib/libzfs_core/Makefile37
-rw-r--r--cddl/lib/libzpool/Makefile70
22 files changed, 1440 insertions, 0 deletions
diff --git a/cddl/lib/Makefile b/cddl/lib/Makefile
new file mode 100644
index 0000000..53d402a
--- /dev/null
+++ b/cddl/lib/Makefile
@@ -0,0 +1,30 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+SUBDIR= ${_drti} \
+ libavl \
+ libctf \
+ ${_libdtrace} \
+ libnvpair \
+ libumem \
+ libuutil \
+ ${_libzfs_core} \
+ ${_libzfs} \
+ ${_libzpool}
+
+.if ${MK_ZFS} != "no"
+_libzfs_core= libzfs_core
+_libzfs= libzfs
+.if ${MK_LIBTHR} != "no"
+_libzpool= libzpool
+.endif
+.endif
+
+.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || \
+ ${MACHINE_CPUARCH} == "mips" || ${MACHINE_CPUARCH} == "powerpc"
+_drti= drti
+_libdtrace= libdtrace
+.endif
+
+.include <bsd.subdir.mk>
diff --git a/cddl/lib/Makefile.inc b/cddl/lib/Makefile.inc
new file mode 100644
index 0000000..8f9af1d
--- /dev/null
+++ b/cddl/lib/Makefile.inc
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+SHLIBDIR?= /lib
+SHLIB_MAJOR?= 2
+
+.include "../Makefile.inc"
diff --git a/cddl/lib/drti/Makefile b/cddl/lib/drti/Makefile
new file mode 100644
index 0000000..6e3d3a6
--- /dev/null
+++ b/cddl/lib/drti/Makefile
@@ -0,0 +1,21 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libdtrace/common
+
+SRCS= drti.c
+FILES= ${SRCS:R:S/$/.o/g}
+FILESOWN= ${LIBOWN}
+FILESGRP= ${LIBGRP}
+FILESMODE= ${LIBMODE}
+FILESDIR= ${LIBDIR}/dtrace
+CLEANFILES= ${FILES}
+
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+ -I${.CURDIR}/../../../cddl/compat/opensolaris/include \
+ -I${OPENSOLARIS_USR_DISTDIR}/head \
+ -I${OPENSOLARIS_USR_DISTDIR}/lib/libctf/common \
+ -I${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common \
+ -DPIC ${PICFLAG}
+
+.include <bsd.lib.mk>
diff --git a/cddl/lib/libavl/Makefile b/cddl/lib/libavl/Makefile
new file mode 100644
index 0000000..f4db92f
--- /dev/null
+++ b/cddl/lib/libavl/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/avl
+
+LIB= avl
+SRCS= avl.c
+WARNS?= 0
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+
+.include <bsd.lib.mk>
diff --git a/cddl/lib/libctf/Makefile b/cddl/lib/libctf/Makefile
new file mode 100644
index 0000000..5829111
--- /dev/null
+++ b/cddl/lib/libctf/Makefile
@@ -0,0 +1,31 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/common/ctf
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libctf/common
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/ctf
+
+LIB= ctf
+SRCS= ctf_create.c \
+ ctf_decl.c \
+ ctf_error.c \
+ ctf_hash.c \
+ ctf_labels.c \
+ ctf_lib.c \
+ ctf_lookup.c \
+ ctf_open.c \
+ ctf_subr.c \
+ ctf_types.c \
+ ctf_util.c
+
+WARNS?= 0
+CFLAGS+= -DCTF_OLD_VERSIONS
+
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+ -I${.CURDIR}/../../../cddl/compat/opensolaris/include \
+ -I${OPENSOLARIS_USR_DISTDIR}/head \
+ -I${OPENSOLARIS_USR_DISTDIR}/common/ctf \
+ -I${OPENSOLARIS_USR_DISTDIR}/lib/libctf/common \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
+.include <bsd.lib.mk>
+
diff --git a/cddl/lib/libdtrace/Makefile b/cddl/lib/libdtrace/Makefile
new file mode 100644
index 0000000..7dd0afd
--- /dev/null
+++ b/cddl/lib/libdtrace/Makefile
@@ -0,0 +1,113 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libdtrace/common
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libgen/common
+
+LIB= dtrace
+SRCS= dt_aggregate.c \
+ dt_as.c \
+ dt_buf.c \
+ dt_cc.c \
+ dt_cg.c \
+ dt_consume.c \
+ dt_decl.c \
+ dt_dis.c \
+ dt_dof.c \
+ dt_error.c \
+ dt_errtags.c \
+ dt_grammar.y \
+ dt_handle.c \
+ dt_ident.c \
+ dt_isadep.c \
+ dt_inttab.c \
+ dt_lex.l \
+ dt_link.c \
+ dt_list.c \
+ dt_map.c \
+ dt_module.c \
+ dt_names.c \
+ dt_open.c \
+ dt_options.c \
+ dt_parser.c \
+ dt_pcb.c \
+ dt_pid.c \
+ dt_pragma.c \
+ dt_print.c \
+ dt_printf.c \
+ dt_proc.c \
+ dt_program.c \
+ dt_provider.c \
+ dt_regset.c \
+ dt_string.c \
+ dt_strtab.c \
+ dt_subr.c \
+ dt_work.c \
+ dt_xlator.c \
+ gmatch.c
+
+DSRCS= errno.d \
+ io.d \
+ psinfo.d \
+ signal.d \
+ unistd.d
+
+WARNS?= 1
+
+CFLAGS+= -I${.OBJDIR} -I${.CURDIR} \
+ -I${.CURDIR}/../../../sys/cddl/dev/dtrace/${MACHINE_ARCH} \
+ -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+ -I${.CURDIR}/../../../cddl/compat/opensolaris/include \
+ -I${OPENSOLARIS_USR_DISTDIR}/head \
+ -I${OPENSOLARIS_USR_DISTDIR}/lib/libctf/common \
+ -I${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
+#CFLAGS+= -DYYDEBUG
+
+.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
+CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel -DDIS_MEM
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libdtrace/i386
+.PATH: ${.CURDIR}/../../../sys/cddl/dev/dtrace/${MACHINE_ARCH}
+.elif ${MACHINE_CPUARCH} == "sparc64"
+CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/sparc
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libdtrace/sparc
+.elif ${MACHINE_CPUARCH} == "mips"
+CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/mips
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libdtrace/mips
+.PATH: ${.CURDIR}/../../../sys/cddl/dev/dtrace/mips
+.elif ${MACHINE_CPUARCH} == "powerpc"
+CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/powerpc
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libdtrace/powerpc
+.PATH: ${.CURDIR}/../../../sys/cddl/dev/dtrace/powerpc
+.else
+# temporary hack
+CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel
+.endif
+
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
+SRCS+= dis_tables.c
+DSRCS+= regs_x86.d
+.endif
+
+LFLAGS+=-l
+
+YFLAGS+=-d
+
+CLEANFILES= dt_errtags.c dt_names.c
+
+dt_errtags.c:
+ sh ${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common/mkerrtags.sh < ${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common/dt_errtags.h > dt_errtags.c
+
+dt_names.c:
+ sh ${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common/mknames.sh < ${OPENSOLARIS_SYS_DISTDIR}/uts/common/sys/dtrace.h > 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>
diff --git a/cddl/lib/libdtrace/errno.d b/cddl/lib/libdtrace/errno.d
new file mode 100644
index 0000000..b9a25e0
--- /dev/null
+++ b/cddl/lib/libdtrace/errno.d
@@ -0,0 +1,228 @@
+/*
+ * 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
+ *
+ * Portions Copyright 2006-2008 John Birrell jb@freebsd.org
+ *
+ * $FreeBSD$
+ */
+/*
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+inline int EPERM = 1;
+#pragma D binding "1.0" EPERM
+inline int ENOENT = 2;
+#pragma D binding "1.0" ENOENT
+inline int ESRCH = 3;
+#pragma D binding "1.0" ESRCH
+inline int EINTR = 4;
+#pragma D binding "1.0" EINTR
+inline int EIO = 5;
+#pragma D binding "1.0" EIO
+inline int ENXIO = 6;
+#pragma D binding "1.0" ENXIO
+inline int E2BIG = 7;
+#pragma D binding "1.0" E2BIG
+inline int ENOEXEC = 8;
+#pragma D binding "1.0" ENOEXEC
+inline int EBADF = 9;
+#pragma D binding "1.0" EBADF
+inline int ECHILD = 10;
+#pragma D binding "1.0" ECHILD
+inline int EDEADLK = 11;
+#pragma D binding "1.0" EDEADLK
+inline int ENOMEM = 12;
+#pragma D binding "1.0" ENOMEM
+inline int EACCES = 13;
+#pragma D binding "1.0" EACCES
+inline int EFAULT = 14;
+#pragma D binding "1.0" EFAULT
+inline int ENOTBLK = 15;
+#pragma D binding "1.0" ENOTBLK
+inline int EBUSY = 16;
+#pragma D binding "1.0" EBUSY
+inline int EEXIST = 17;
+#pragma D binding "1.0" EEXIST
+inline int EXDEV = 18;
+#pragma D binding "1.0" EXDEV
+inline int ENODEV = 19;
+#pragma D binding "1.0" ENODEV
+inline int ENOTDIR = 20;
+#pragma D binding "1.0" ENOTDIR
+inline int EISDIR = 21;
+#pragma D binding "1.0" EISDIR
+inline int EINVAL = 22;
+#pragma D binding "1.0" EINVAL
+inline int ENFILE = 23;
+#pragma D binding "1.0" ENFILE
+inline int EMFILE = 24;
+#pragma D binding "1.0" EMFILE
+inline int ENOTTY = 25;
+#pragma D binding "1.0" ENOTTY
+inline int ETXTBSY = 26;
+#pragma D binding "1.0" ETXTBSY
+inline int EFBIG = 27;
+#pragma D binding "1.0" EFBIG
+inline int ENOSPC = 28;
+#pragma D binding "1.0" ENOSPC
+inline int ESPIPE = 29;
+#pragma D binding "1.0" ESPIPE
+inline int EROFS = 30;
+#pragma D binding "1.0" EROFS
+inline int EMLINK = 31;
+#pragma D binding "1.0" EMLINK
+inline int EPIPE = 32;
+#pragma D binding "1.0" EPIPE
+inline int EDOM = 33;
+#pragma D binding "1.0" EDOM
+inline int ERANGE = 34;
+#pragma D binding "1.0" ERANGE
+inline int EAGAIN = 35;
+#pragma D binding "1.0" EAGAIN
+inline int EWOULDBLOCK = EAGAIN;
+#pragma D binding "1.0" EWOULDBLOCK
+inline int EINPROGRESS = 36;
+#pragma D binding "1.0" EINPROGRESS
+inline int EALREADY = 37;
+#pragma D binding "1.0" EALREADY
+inline int ENOTSOCK = 38;
+#pragma D binding "1.0" ENOTSOCK
+inline int EDESTADDRREQ = 39;
+#pragma D binding "1.0" EDESTADDRREQ
+inline int EMSGSIZE = 40;
+#pragma D binding "1.0" EMSGSIZE
+inline int EPROTOTYPE = 41;
+#pragma D binding "1.0" EPROTOTYPE
+inline int ENOPROTOOPT = 42;
+#pragma D binding "1.0" ENOPROTOOPT
+inline int EPROTONOSUPPORT = 43;
+#pragma D binding "1.0" EPROTONOSUPPORT
+inline int ESOCKTNOSUPPORT = 44;
+#pragma D binding "1.0" ESOCKTNOSUPPORT
+inline int EOPNOTSUPP = 45;
+#pragma D binding "1.0" EOPNOTSUPP
+inline int ENOTSUP = EOPNOTSUPP;
+#pragma D binding "1.0" ENOTSUP
+inline int EPFNOSUPPORT = 46;
+#pragma D binding "1.0" EPFNOSUPPORT
+inline int EAFNOSUPPORT = 47;
+#pragma D binding "1.0" EAFNOSUPPORT
+inline int EADDRINUSE = 48;
+#pragma D binding "1.0" EADDRINUSE
+inline int EADDRNOTAVAIL = 49;
+#pragma D binding "1.0" EADDRNOTAVAIL
+inline int ENETDOWN = 50;
+#pragma D binding "1.0" ENETDOWN
+inline int ENETUNREACH = 51;
+#pragma D binding "1.0" ENETUNREACH
+inline int ENETRESET = 52;
+#pragma D binding "1.0" ENETRESET
+inline int ECONNABORTED = 53;
+#pragma D binding "1.0" ECONNABORTED
+inline int ECONNRESET = 54;
+#pragma D binding "1.0" ECONNRESET
+inline int ENOBUFS = 55;
+#pragma D binding "1.0" ENOBUFS
+inline int EISCONN = 56;
+#pragma D binding "1.0" EISCONN
+inline int ENOTCONN = 57;
+#pragma D binding "1.0" ENOTCONN
+inline int ESHUTDOWN = 58;
+#pragma D binding "1.0" ESHUTDOWN
+inline int ETOOMANYREFS = 59;
+#pragma D binding "1.0" ETOOMANYREFS
+inline int ETIMEDOUT = 60;
+#pragma D binding "1.0" ETIMEDOUT
+inline int ECONNREFUSED = 61;
+#pragma D binding "1.0" ECONNREFUSED
+inline int ELOOP = 62;
+#pragma D binding "1.0" ELOOP
+inline int ENAMETOOLONG = 63;
+#pragma D binding "1.0" ENAMETOOLONG
+inline int EHOSTDOWN = 64;
+#pragma D binding "1.0" EHOSTDOWN
+inline int EHOSTUNREACH = 65;
+#pragma D binding "1.0" EHOSTUNREACH
+inline int ENOTEMPTY = 66;
+#pragma D binding "1.0" ENOTEMPTY
+inline int EPROCLIM = 67;
+#pragma D binding "1.0" EPROCLIM
+inline int EUSERS = 68;
+#pragma D binding "1.0" EUSERS
+inline int EDQUOT = 69;
+#pragma D binding "1.0" EDQUOT
+inline int ESTALE = 70;
+#pragma D binding "1.0" ESTALE
+inline int EREMOTE = 71;
+#pragma D binding "1.0" EREMOTE
+inline int EBADRPC = 72;
+#pragma D binding "1.0" EBADRPC
+inline int ERPCMISMATCH = 73;
+#pragma D binding "1.0" ERPCMISMATCH
+inline int EPROGUNAVAIL = 74;
+#pragma D binding "1.0" EPROGUNAVAIL
+inline int EPROGMISMATCH = 75;
+#pragma D binding "1.0" EPROGMISMATCH
+inline int EPROCUNAVAIL = 76;
+#pragma D binding "1.0" EPROCUNAVAIL
+inline int ENOLCK = 77;
+#pragma D binding "1.0" ENOLCK
+inline int ENOSYS = 78;
+#pragma D binding "1.0" ENOSYS
+inline int EFTYPE = 79;
+#pragma D binding "1.0" EFTYPE
+inline int EAUTH = 80;
+#pragma D binding "1.0" EAUTH
+inline int ENEEDAUTH = 81;
+#pragma D binding "1.0" ENEEDAUTH
+inline int EIDRM = 82;
+#pragma D binding "1.0" EIDRM
+inline int ENOMSG = 83;
+#pragma D binding "1.0" ENOMSG
+inline int EOVERFLOW = 84;
+#pragma D binding "1.0" EOVERFLOW
+inline int ECANCELED = 85;
+#pragma D binding "1.0" ECANCELED
+inline int EILSEQ = 86;
+#pragma D binding "1.0" EILSEQ
+inline int ENOATTR = 87;
+#pragma D binding "1.0" ENOATTR
+inline int EDOOFUS = 88;
+#pragma D binding "1.0" EDOOFUS
+inline int EBADMSG = 89;
+#pragma D binding "1.0" EBADMSG
+inline int EMULTIHOP = 90;
+#pragma D binding "1.0" EMULTIHOP
+inline int ENOLINK = 91;
+#pragma D binding "1.0" ENOLINK
+inline int EPROTO = 92;
+#pragma D binding "1.0" EPROTO
+inline int ELAST = 92;
+#pragma D binding "1.0" ELAST
+inline int ERESTART = -1;
+#pragma D binding "1.0" ERESTART
+inline int EJUSTRETURN = -2;
+#pragma D binding "1.0" EJUSTRETURN
+inline int ENOIOCTL = -3;
+#pragma D binding "1.0" ENOIOCTL
+inline int EDIRIOCTL = -4;
+#pragma D binding "1.0" EDIRIOCTL
diff --git a/cddl/lib/libdtrace/io.d b/cddl/lib/libdtrace/io.d
new file mode 100644
index 0000000..18a54af
--- /dev/null
+++ b/cddl/lib/libdtrace/io.d
@@ -0,0 +1,110 @@
+/*
+ * 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
+ *
+ * $FreeBSD$
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D depends_on provider io
+
+typedef struct devinfo {
+ int dev_major; /* major number */
+ int dev_minor; /* minor number */
+ int dev_instance; /* instance number */
+ string dev_name; /* name of device */
+ string dev_statname; /* name of device + instance/minor */
+ string dev_pathname; /* pathname of device */
+} devinfo_t;
+
+#pragma D binding "1.0" translator
+translator devinfo_t < struct devstat *D > {
+ dev_major = D->device_number;
+ dev_minor = D->unit_number;
+ dev_instance = 0;
+ dev_name = stringof(D->device_name);
+ dev_statname = stringof(D->device_name);
+ dev_pathname = stringof(D->device_name);
+};
+
+typedef struct bufinfo {
+ int b_flags; /* flags */
+ long b_bcount; /* number of bytes */
+ caddr_t b_addr; /* buffer address */
+ uint64_t b_blkno; /* expanded block # on device */
+ uint64_t b_lblkno; /* block # on device */
+ size_t b_resid; /* # of bytes not transferred */
+ size_t b_bufsize; /* size of allocated buffer */
+/* caddr_t b_iodone; I/O completion routine */
+ int b_error; /* expanded error field */
+/* dev_t b_edev; extended device */
+} bufinfo_t;
+
+#pragma D binding "1.0" translator
+translator bufinfo_t < struct bio *B > {
+ b_flags = B->bio_flags;
+ b_bcount = B->bio_bcount;
+ b_addr = B->bio_data;
+ b_blkno = 0;
+ b_lblkno = 0;
+ b_resid = B->bio_resid;
+ b_bufsize = 0; /* XXX gnn */
+ b_error = B->bio_error;
+};
+
+/*
+ * The following inline constants can be used to examine fi_oflags when using
+ * the fds[] array or a translated fileinfo_t. Note that the various open
+ * flags behave as a bit-field *except* for O_RDONLY, O_WRONLY, and O_RDWR.
+ * To test the open mode, you write code similar to that used with the fcntl(2)
+ * F_GET[X]FL command, such as: if ((fi_oflags & O_ACCMODE) == O_WRONLY).
+ */
+inline int O_ACCMODE = 0x0003;
+#pragma D binding "1.1" O_ACCMODE
+
+inline int O_RDONLY = 0x0000;
+#pragma D binding "1.1" O_RDONLY
+inline int O_WRONLY = 0x0001;
+#pragma D binding "1.1" O_WRONLY
+inline int O_RDWR = 0x0002;
+#pragma D binding "1.1" O_RDWR
+
+inline int O_APPEND = 0x0008;
+#pragma D binding "1.1" O_APPEND
+inline int O_CREAT = 0x0200;
+#pragma D binding "1.1" O_CREAT
+inline int O_EXCL = 0x0800;
+#pragma D binding "1.1" O_EXCL
+inline int O_NOCTTY = 0x8000;
+#pragma D binding "1.1" O_NOCTTY
+inline int O_NONBLOCK = 0x0004;
+#pragma D binding "1.1" O_NONBLOCK
+inline int O_NDELAY = 0x0004;
+#pragma D binding "1.1" O_NDELAY
+inline int O_SYNC = 0x0080;
+#pragma D binding "1.1" O_SYNC
+inline int O_TRUNC = 0x0400;
+#pragma D binding "1.1" O_TRUNC
+
+
diff --git a/cddl/lib/libdtrace/libproc_compat.h b/cddl/lib/libdtrace/libproc_compat.h
new file mode 100644
index 0000000..a561157
--- /dev/null
+++ b/cddl/lib/libdtrace/libproc_compat.h
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * Compatibility functions between Solaris libproc and FreeBSD libproc.
+ * Functions sorted alphabetically.
+ */
+#define PR_LMID_EVERY 0
+#define Psetrun(p, a1, a2) proc_continue((p))
+#define Pxlookup_by_addr(p, a, n, s, sym, i) \
+ proc_addr2sym(p, a, n, s, sym)
+#define Pxlookup_by_name(p, l, s1, s2, sym, a) \
+ proc_name2sym((p), (s1), (s2), (sym))
+#define Paddr_to_map proc_addr2map
+#define Pcreate_error strerror
+#define Pdelbkpt proc_bkptdel
+#define Pgrab_error strerror
+#define Plmid_to_map(p, l, o) proc_obj2map((p), (o))
+#define Plookup_by_addr proc_addr2sym
+#define Pname_to_map proc_name2map
+#define Pobject_iter proc_iter_objs
+#define Pobjname proc_objname
+#define Pread proc_read
+#define Prd_agent proc_rdagent
+#define Prelease proc_detach
+#define Psetbkpt proc_bkptset
+#define Psetflags proc_setflags
+#define Pstate proc_state
+#define Pstate proc_state
+#define Psymbol_iter_by_addr proc_iter_symbyaddr
+#define Punsetflags proc_clearflags
+#define Pupdate_maps(p) do { } while (0)
+#define Pupdate_syms proc_updatesyms
+#define Pxecbkpt proc_bkptexec
diff --git a/cddl/lib/libdtrace/net.d b/cddl/lib/libdtrace/net.d
new file mode 100644
index 0000000..ee22c8f
--- /dev/null
+++ b/cddl/lib/libdtrace/net.d
@@ -0,0 +1,43 @@
+/*
+ * 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
+ *
+ * Portions Copyright 2006-2008 John Birrell jb@freebsd.org
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * The conninfo_t structure should be used by all application protocal
+ * providers as the first arguments to indicate some basic information
+ * about the connection. This structure may be augmented to accomodate
+ * the particularities of additional protocols in the future.
+ */
+typedef struct conninfo {
+ string ci_local; /* local host address */
+ string ci_remote; /* remote host address */
+ string ci_protocol; /* protocol (ipv4, ipv6, etc) */
+} conninfo_t;
diff --git a/cddl/lib/libdtrace/nfs.d b/cddl/lib/libdtrace/nfs.d
new file mode 100644
index 0000000..0f936c4
--- /dev/null
+++ b/cddl/lib/libdtrace/nfs.d
@@ -0,0 +1,96 @@
+/*
+ * 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
+ *
+ * Portions Copyright 2006-2008 John Birrell jb@freebsd.org
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D depends_on library ip.d
+#pragma D depends_on library net.d
+#pragma D depends_on module genunix
+
+typedef struct nfsv4opinfo {
+ uint64_t noi_xid; /* unique transation ID */
+ cred_t *noi_cred; /* credentials for operation */
+ string noi_curpath; /* current file handle path (if any) */
+} nfsv4opinfo_t;
+
+typedef struct nfsv4cbinfo {
+ string nci_curpath; /* current file handle path (if any) */
+} nfsv4cbinfo_t;
+
+#pragma D binding "1.5" translator
+translator conninfo_t < struct svc_req *P > {
+ ci_protocol = P->rq_xprt->xp_master->xp_netid == "tcp" ? "ipv4" :
+ P->rq_xprt->xp_master->xp_netid == "tcp6" ? "ipv6" :
+ "<unknown>";
+
+ ci_local = inet_ntoa6(&((conn_t *)P->rq_xprt->xp_xpc.
+ xpc_wq->q_next->q_ptr)->connua_v6addr.connua_laddr);
+
+ ci_remote = inet_ntoa6(&((conn_t *)P->rq_xprt->xp_xpc.
+ xpc_wq->q_next->q_ptr)->connua_v6addr.connua_faddr);
+};
+
+#pragma D binding "1.5" translator
+translator conninfo_t < struct compound_state *P > {
+ ci_protocol = P->req->rq_xprt->xp_master->xp_netid == "tcp" ? "ipv4" :
+ P->req->rq_xprt->xp_master->xp_netid == "tcp6" ? "ipv6" :
+ "<unknown>";
+
+ ci_local = inet_ntoa6(&((conn_t *)P->req->rq_xprt->xp_xpc.
+ xpc_wq->q_next->q_ptr)->connua_v6addr.connua_laddr);
+
+ ci_remote = inet_ntoa6(&((conn_t *)P->req->rq_xprt->xp_xpc.
+ xpc_wq->q_next->q_ptr)->connua_v6addr.connua_faddr);
+};
+
+#pragma D binding "1.5" translator
+translator nfsv4opinfo_t < struct compound_state *P > {
+ noi_xid = P->req->rq_xprt->xp_xid;
+ noi_cred = P->basecr;
+ noi_curpath = (P->vp == NULL) ? "<unknown>" : P->vp->v_path;
+};
+
+#pragma D binding "1.5" translator
+translator conninfo_t < rfs4_client_t *P > {
+ ci_protocol = (P->cl_addr.ss_family == AF_INET) ? "ipv4" : "ipv6";
+
+ ci_local = "<unknown>";
+
+ ci_remote = (P->cl_addr.ss_family == AF_INET) ?
+ inet_ntoa((ipaddr_t *)
+ &((struct sockaddr_in *)&P->cl_addr)->sin_addr) :
+ inet_ntoa6(&((struct sockaddr_in6 *)&P->cl_addr)->sin6_addr);
+};
+
+#pragma D binding "1.5" translator
+translator nfsv4cbinfo_t < rfs4_deleg_state_t *P > {
+ nci_curpath = (P->finfo->vp == NULL) ? "<unknown>" :
+ P->finfo->vp->v_path;
+};
diff --git a/cddl/lib/libdtrace/psinfo.d b/cddl/lib/libdtrace/psinfo.d
new file mode 100644
index 0000000..068e72e
--- /dev/null
+++ b/cddl/lib/libdtrace/psinfo.d
@@ -0,0 +1,97 @@
+/*
+ * 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
+ *
+ * Portions Copyright 2006 John Birrell jb@freebsd.org
+ *
+ * $FreeBSD$
+ */
+/*
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+typedef struct psinfo {
+ int pr_nlwp; /* number of threads */
+ pid_t pr_pid; /* unique process id */
+ pid_t pr_ppid; /* process id of parent */
+ pid_t pr_pgid; /* pid of process group leader */
+ pid_t pr_sid; /* session id */
+ uid_t pr_uid; /* real user id */
+ uid_t pr_euid; /* effective user id */
+ gid_t pr_gid; /* real group id */
+ gid_t pr_egid; /* effective group id */
+ uintptr_t
+ pr_addr; /* address of process */
+ string pr_psargs; /* process arguments */
+ u_int pr_arglen; /* process argument length */
+ u_int pr_jailid; /* jail id */
+} psinfo_t;
+
+#pragma D binding "1.0" translator
+translator psinfo_t < struct proc *T > {
+ pr_nlwp = T->p_numthreads;
+ pr_pid = T->p_pid;
+ pr_ppid = (T->p_pptr == 0) ? 0 : T->p_pptr->p_pid;
+ pr_pgid = (T->p_leader == 0) ? 0 : T->p_leader->p_pid;
+ pr_sid = (T->p_pgrp == 0) ? 0 : ((T->p_pgrp->pg_session == 0) ? 0 : T->p_pgrp->pg_session->s_sid);
+ pr_uid = T->p_ucred->cr_ruid;
+ pr_euid = T->p_ucred->cr_uid;
+ pr_gid = T->p_ucred->cr_rgid;
+ pr_egid = T->p_ucred->cr_groups[0];
+ pr_addr = 0;
+ pr_psargs = stringof(T->p_args->ar_args);
+ pr_arglen = T->p_args->ar_length;
+ pr_jailid = T->p_ucred->cr_prison->pr_id;
+};
+
+typedef struct lwpsinfo {
+ id_t pr_lwpid; /* thread ID. */
+ int pr_flag; /* thread flags. */
+ int pr_pri; /* thread priority. */
+ char pr_state; /* numeric lwp state */
+ char pr_sname; /* printable character for pr_state */
+ short pr_syscall; /* system call number (if in syscall) */
+ uintptr_t
+ pr_addr; /* internal address of lwp */
+ uintptr_t
+ pr_wchan; /* sleep address */
+} lwpsinfo_t;
+
+#pragma D binding "1.0" translator
+translator lwpsinfo_t < struct thread *T > {
+ pr_lwpid = T->td_tid;
+ pr_pri = T->td_priority;
+ pr_flag = T->td_flags;
+ pr_state = 0; /* XXX */
+ pr_sname = '?'; /* XXX */
+ pr_syscall = 0; /* XXX */
+ pr_addr = (uintptr_t)T;
+ pr_wchan = (uintptr_t)T->td_wchan;
+};
+
+inline psinfo_t *curpsinfo = xlate <psinfo_t *> (curthread->td_proc);
+#pragma D attributes Stable/Stable/Common curpsinfo
+#pragma D binding "1.0" curpsinfo
+
+inline lwpsinfo_t *curlwpsinfo = xlate <lwpsinfo_t *> (curthread);
+#pragma D attributes Stable/Stable/Common curlwpsinfo
+#pragma D binding "1.0" curlwpsinfo
+
diff --git a/cddl/lib/libdtrace/regs_x86.d b/cddl/lib/libdtrace/regs_x86.d
new file mode 100644
index 0000000..7dce197
--- /dev/null
+++ b/cddl/lib/libdtrace/regs_x86.d
@@ -0,0 +1,121 @@
+/*
+ * 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
+ *
+ * Portions Copyright 2009 Stacey Son sson@FreeBSD.org
+ *
+ * $FreeBSD$
+ */
+/*
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "@(#)regs.d.in 1.1 04/09/28 SMI"
+
+inline int R_GS = 0;
+#pragma D binding "1.0" R_GS
+inline int R_FS = 1;
+#pragma D binding "1.0" R_FS
+inline int R_ES = 2;
+#pragma D binding "1.0" R_ES
+inline int R_DS = 3;
+#pragma D binding "1.0" R_DS
+
+inline int R_EDI = 4;
+#pragma D binding "1.0" R_EDI
+inline int R_ESI = 5;
+#pragma D binding "1.0" R_ESI
+inline int R_EBP = 6;
+#pragma D binding "1.0" R_EBP
+inline int R_ESP = 7;
+#pragma D binding "1.0" R_ESP
+inline int R_EBX = 8;
+#pragma D binding "1.0" R_EBX
+inline int R_EDX = 9;
+#pragma D binding "1.0" R_EDX
+inline int R_ECX = 10;
+#pragma D binding "1.0" R_ECX
+inline int R_EAX = 11;
+#pragma D binding "1.0" R_EAX
+
+inline int R_TRAPNO = 12;
+#pragma D binding "1.0" R_TRAPNO
+inline int R_ERR = 13;
+#pragma D binding "1.0" R_ERR
+inline int R_EIP = 14;
+#pragma D binding "1.0" R_EIP
+inline int R_CS = 15;
+#pragma D binding "1.0" R_CS
+inline int R_EFL = 16;
+#pragma D binding "1.0" R_EFL
+inline int R_UESP = 17;
+#pragma D binding "1.0" R_UESP
+inline int R_SS = 18;
+#pragma D binding "1.0" R_SS
+
+inline int R_PC = R_EIP;
+#pragma D binding "1.0" R_PC
+inline int R_SP = R_UESP;
+#pragma D binding "1.0" R_SP
+inline int R_PS = R_EFL;
+#pragma D binding "1.0" R_PS
+inline int R_R0 = R_EAX;
+#pragma D binding "1.0" R_R0
+inline int R_R1 = R_EBX;
+#pragma D binding "1.0" R_R1
+
+inline int R_RSP = 18 + 1 + 20;
+#pragma D binding "1.0" R_RSP
+inline int R_RFL = 18 + 1 + 19;
+#pragma D binding "1.0" R_RFL
+inline int R_RIP = 18 + 1 + 17;
+#pragma D binding "1.0" R_RIP
+inline int R_RAX = 18 + 1 + 14;
+#pragma D binding "1.0" R_RAX
+inline int R_RCX = 18 + 1 + 13;
+#pragma D binding "1.0" R_RCX
+inline int R_RDX = 18 + 1 + 12;
+#pragma D binding "1.0" R_RDX
+inline int R_RBX = 18 + 1 + 11;
+#pragma D binding "1.0" R_RBX
+inline int R_RBP = 18 + 1 + 10;
+#pragma D binding "1.0" R_RBP
+inline int R_RSI = 18 + 1 + 9;
+#pragma D binding "1.0" R_RSI
+inline int R_RDI = 18 + 1 + 8;
+#pragma D binding "1.0" R_RDI
+inline int R_R8 = 18 + 1 + 7;
+#pragma D binding "1.0" R_R8
+inline int R_R9 = 18 + 1 + 6;
+#pragma D binding "1.0" R_R9
+inline int R_R10 = 18 + 1 + 5;
+#pragma D binding "1.0" R_R10
+inline int R_R11 = 18 + 1 + 4;
+#pragma D binding "1.0" R_R11
+inline int R_R12 = 18 + 1 + 3;
+#pragma D binding "1.0" R_R12
+inline int R_R13 = 18 + 1 + 2;
+#pragma D binding "1.0" R_R13
+inline int R_R14 = 18 + 1 + 1;
+#pragma D binding "1.0" R_R14
+inline int R_R15 = 18 + 1 + 0;
+#pragma D binding "1.0" R_R15
+
diff --git a/cddl/lib/libdtrace/sched.d b/cddl/lib/libdtrace/sched.d
new file mode 100644
index 0000000..d91d3c5
--- /dev/null
+++ b/cddl/lib/libdtrace/sched.d
@@ -0,0 +1,86 @@
+/*
+ * 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
+ *
+ * Portions Copyright 2006-2008 John Birrell jb@freebsd.org
+ *
+ * $FreeBSD$
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D depends_on module unix
+#pragma D depends_on provider sched
+
+struct cpuinfo {
+ processorid_t cpu_id; /* CPU identifier */
+ psetid_t cpu_pset; /* processor set identifier */
+ chipid_t cpu_chip; /* chip identifier */
+ lgrp_id_t cpu_lgrp; /* locality group identifer */
+ processor_info_t cpu_info; /* CPU information */
+};
+
+typedef struct cpuinfo cpuinfo_t;
+
+translator cpuinfo_t < cpu_t *C > {
+ cpu_id = C->cpu_id;
+ cpu_pset = C->cpu_part->cp_id;
+ cpu_chip = C->cpu_physid->cpu_chipid;
+ cpu_lgrp = C->cpu_lpl->lpl_lgrpid;
+ cpu_info = (processor_info_t)C->cpu_type_info;
+};
+
+translator cpuinfo_t < disp_t *D > {
+ cpu_id = D->disp_cpu == NULL ? -1 :
+ xlate <cpuinfo_t> (D->disp_cpu).cpu_id;
+ cpu_pset = D->disp_cpu == NULL ? -1 :
+ xlate <cpuinfo_t> (D->disp_cpu).cpu_pset;
+ cpu_chip = D->disp_cpu == NULL ? -1 :
+ xlate <cpuinfo_t> (D->disp_cpu).cpu_chip;
+ cpu_lgrp = D->disp_cpu == NULL ? -1 :
+ xlate <cpuinfo_t> (D->disp_cpu).cpu_lgrp;
+ cpu_info = D->disp_cpu == NULL ?
+ *((processor_info_t *)dtrace`dtrace_zero) :
+ (processor_info_t)xlate <cpuinfo_t> (D->disp_cpu).cpu_info;
+};
+
+inline cpuinfo_t *curcpu = xlate <cpuinfo_t *> (curthread->t_cpu);
+#pragma D attributes Stable/Stable/Common curcpu
+#pragma D binding "1.0" curcpu
+
+inline processorid_t cpu = curcpu->cpu_id;
+#pragma D attributes Stable/Stable/Common cpu
+#pragma D binding "1.0" cpu
+
+inline psetid_t pset = curcpu->cpu_pset;
+#pragma D attributes Stable/Stable/Common pset
+#pragma D binding "1.0" pset
+
+inline chipid_t chip = curcpu->cpu_chip;
+#pragma D attributes Stable/Stable/Common chip
+#pragma D binding "1.0" chip
+
+inline lgrp_id_t lgrp = curcpu->cpu_lgrp;
+#pragma D attributes Stable/Stable/Common lgrp
+#pragma D binding "1.0" lgrp
+
diff --git a/cddl/lib/libdtrace/signal.d b/cddl/lib/libdtrace/signal.d
new file mode 100644
index 0000000..5a4c2f6
--- /dev/null
+++ b/cddl/lib/libdtrace/signal.d
@@ -0,0 +1,101 @@
+/*
+ * 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
+ *
+ * Portions Copyright 2008 John Birrell jb@freebsd.org
+ *
+ * $FreeBSD$
+ */
+
+inline int SIGHUP = 1;
+#pragma D binding "1.0" SIGHUP
+inline int SIGINT = 2;
+#pragma D binding "1.0" SIGINT
+inline int SIGQUIT = 3;
+#pragma D binding "1.0" SIGQUIT
+inline int SIGILL = 4;
+#pragma D binding "1.0" SIGILL
+inline int SIGTRAP = 5;
+#pragma D binding "1.0" SIGTRAP
+inline int SIGABRT = 6;
+#pragma D binding "1.0" SIGABRT
+inline int SIGEMT = 7;
+#pragma D binding "1.0" SIGEMT
+inline int SIGFPE = 8;
+#pragma D binding "1.0" SIGFPE
+inline int SIGKILL = 9;
+#pragma D binding "1.0" SIGKILL
+inline int SIGBUS = 10;
+#pragma D binding "1.0" SIGBUS
+inline int SIGSEGV = 11;
+#pragma D binding "1.0" SIGSEGV
+inline int SIGSYS = 12;
+#pragma D binding "1.0" SIGSYS
+inline int SIGPIPE = 13;
+#pragma D binding "1.0" SIGPIPE
+inline int SIGALRM = 14;
+#pragma D binding "1.0" SIGALRM
+inline int SIGTERM = 15;
+#pragma D binding "1.0" SIGTERM
+inline int SIGURG = 16;
+#pragma D binding "1.0" SIGURG
+inline int SIGSTOP = 17;
+#pragma D binding "1.0" SIGSTOP
+inline int SIGTSTP = 18;
+#pragma D binding "1.0" SIGTSTP
+inline int SIGCONT = 19;
+#pragma D binding "1.0" SIGCONT
+inline int SIGCHLD = 20;
+#pragma D binding "1.0" SIGCHLD
+inline int SIGTTIN = 21;
+#pragma D binding "1.0" SIGTTIN
+inline int SIGTTOU = 22;
+#pragma D binding "1.0" SIGTTOU
+inline int SIGIO = 23;
+#pragma D binding "1.0" SIGIO
+inline int SIGXCPU = 24;
+#pragma D binding "1.0" SIGXCPU
+inline int SIGXFSZ = 25;
+#pragma D binding "1.0" SIGXFSZ
+inline int SIGVTALRM = 26;
+#pragma D binding "1.0" SIGVTALRM
+inline int SIGPROF = 27;
+#pragma D binding "1.0" SIGPROF
+inline int SIGWINCH = 28;
+#pragma D binding "1.0" SIGWINCH
+inline int SIGINFO = 29;
+#pragma D binding "1.0" SIGINFO
+inline int SIGUSR1 = 30;
+#pragma D binding "1.0" SIGUSR1
+inline int SIGUSR2 = 31;
+#pragma D binding "1.0" SIGUSR2
+
+inline int CLD_EXITED = 1;
+#pragma D binding "1.0" CLD_EXITED
+inline int CLD_KILLED = 2;
+#pragma D binding "1.0" CLD_KILLED
+inline int CLD_DUMPED = 3;
+#pragma D binding "1.0" CLD_DUMPED
+inline int CLD_TRAPPED = 4;
+#pragma D binding "1.0" CLD_TRAPPED
+inline int CLD_STOPPED = 5;
+#pragma D binding "1.0" CLD_STOPPED
+inline int CLD_CONTINUED = 6;
+#pragma D binding "1.0" CLD_CONTINUED
diff --git a/cddl/lib/libdtrace/unistd.d b/cddl/lib/libdtrace/unistd.d
new file mode 100644
index 0000000..1ceffef
--- /dev/null
+++ b/cddl/lib/libdtrace/unistd.d
@@ -0,0 +1,56 @@
+/*
+ * 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
+ *
+ * $FreeBSD$
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+inline int DTRACEFLT_UNKNOWN = 0; /* Unknown fault */
+#pragma D binding "1.0" DTRACEFLT_UNKNOWN
+
+inline int DTRACEFLT_BADADDR = 1; /* Bad address */
+#pragma D binding "1.0" DTRACEFLT_BADADDR
+
+inline int DTRACEFLT_BADALIGN = 2; /* Bad alignment */
+#pragma D binding "1.0" DTRACEFLT_BADALIGN
+
+inline int DTRACEFLT_ILLOP = 3; /* Illegal operation */
+#pragma D binding "1.0" DTRACEFLT_ILLOP
+
+inline int DTRACEFLT_DIVZERO = 4; /* Divide-by-zero */
+#pragma D binding "1.0" DTRACEFLT_DIVZERO
+
+inline int DTRACEFLT_NOSCRATCH = 5; /* Out of scratch space */
+#pragma D binding "1.0" DTRACEFLT_NOSCRATCH
+
+inline int DTRACEFLT_KPRIV = 6; /* Illegal kernel access */
+#pragma D binding "1.0" DTRACEFLT_KPRIV
+
+inline int DTRACEFLT_UPRIV = 7; /* Illegal user access */
+#pragma D binding "1.0" DTRACEFLT_UPRIV
+
+inline int DTRACEFLT_TUPOFLOW = 8; /* Tuple stack overflow */
+#pragma D binding "1.0" DTRACEFLT_TUPOFLOW
+
+inline int DTRACEFLT_BADSTACK = 9; /* Bad stack */
+#pragma D binding "1.4.1" DTRACEFLT_BADSTACK
diff --git a/cddl/lib/libnvpair/Makefile b/cddl/lib/libnvpair/Makefile
new file mode 100644
index 0000000..bd159fc
--- /dev/null
+++ b/cddl/lib/libnvpair/Makefile
@@ -0,0 +1,24 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/nvpair
+
+LIB= nvpair
+
+SRCS= libnvpair.c \
+ nvpair_alloc_system.c \
+ nvpair_alloc_fixed.c \
+ nvpair.c \
+ fnvpair.c
+
+WARNS?= 0
+CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+CFLAGS+= -I${.CURDIR}/../../../sys
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
+
+.include <bsd.lib.mk>
diff --git a/cddl/lib/libumem/Makefile b/cddl/lib/libumem/Makefile
new file mode 100644
index 0000000..0ce73f8
--- /dev/null
+++ b/cddl/lib/libumem/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
+
+LIB= umem
+SRCS= umem.c
+WARNS?= 0
+CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
+
+.include <bsd.lib.mk>
diff --git a/cddl/lib/libuutil/Makefile b/cddl/lib/libuutil/Makefile
new file mode 100644
index 0000000..7521747
--- /dev/null
+++ b/cddl/lib/libuutil/Makefile
@@ -0,0 +1,26 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/avl
+
+LIB= uutil
+SRCS= avl.c \
+ uu_alloc.c \
+ uu_avl.c \
+ uu_dprintf.c \
+ uu_ident.c \
+ uu_list.c \
+ uu_misc.c \
+ uu_open.c \
+ uu_pname.c \
+ uu_strtoint.c
+
+WARNS?= 0
+CFLAGS+= -DNATIVE_BUILD
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+
+.include <bsd.lib.mk>
diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile
new file mode 100644
index 0000000..5b6b47d
--- /dev/null
+++ b/cddl/lib/libzfs/Makefile
@@ -0,0 +1,61 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../cddl/compat/opensolaris/misc
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+
+LIB= zfs
+DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL} ${LIBM} ${LIBNVPAIR} \
+ ${LIBZFS_CORE}
+LDADD= -lmd -lpthread -lumem -lutil -lm -lnvpair -lzfs_core
+
+SRCS= deviceid.c \
+ fsshare.c \
+ mkdirp.c \
+ mnttab.c \
+ zmount.c \
+ zone.c
+
+SRCS+= libzfs_changelist.c \
+ libzfs_compat.c \
+ libzfs_config.c \
+ libzfs_dataset.c \
+ libzfs_diff.c \
+ libzfs_import.c \
+ libzfs_iter.c \
+ libzfs_mount.c \
+ libzfs_pool.c \
+ libzfs_sendrecv.c \
+ libzfs_status.c \
+ libzfs_util.c \
+ zfeature_common.c \
+ zfs_comutil.c \
+ zfs_deleg.c \
+ zfs_fletcher.c \
+ zfs_ioctl_compat.c \
+ zfs_namecheck.c \
+ zfs_prop.c \
+ zpool_prop.c \
+ zprop_common.c \
+
+WARNS?= 0
+CSTD= c99
+CFLAGS+= -DZFS_NO_ACL
+CFLAGS+= -I${.CURDIR}/../../../sbin/mount
+CFLAGS+= -I${.CURDIR}/../../../cddl/lib/libumem
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
+CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
+CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs_core/common
+
+.include <bsd.lib.mk>
diff --git a/cddl/lib/libzfs_core/Makefile b/cddl/lib/libzfs_core/Makefile
new file mode 100644
index 0000000..a470fbc
--- /dev/null
+++ b/cddl/lib/libzfs_core/Makefile
@@ -0,0 +1,37 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../cddl/compat/opensolaris/misc
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs_core/common
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+
+LIB= zfs_core
+DPADD= ${LIBNVPAIR}
+LDADD= -lnvpair
+
+SRCS= libzfs_core.c \
+ libzfs_core_compat.c
+
+SRCS+= libzfs_compat.c
+
+WARNS?= 0
+CSTD= c99
+CFLAGS+= -DZFS_NO_ACL
+CFLAGS+= -I${.CURDIR}/../../../sbin/mount
+CFLAGS+= -I${.CURDIR}/../../../cddl/lib/libumem
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
+CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
+CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs_core/common
+CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+
+.include <bsd.lib.mk>
diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile
new file mode 100644
index 0000000..b159d3a
--- /dev/null
+++ b/cddl/lib/libzpool/Makefile
@@ -0,0 +1,70 @@
+# $FreeBSD$
+
+.include "${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/Makefile.files"
+
+# ZFS_COMMON_SRCS
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+# ZFS_SHARED_SRCS
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+# KERNEL_SRCS
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+# LIST_SRCS
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/os
+# ATOMIC_SRCS
+.if exists(${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/atomic/${MACHINE_ARCH}/opensolaris_atomic.S)
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/atomic/${MACHINE_ARCH}
+ATOMIC_SRCS= opensolaris_atomic.S
+.if ${MACHINE_ARCH} != "ia64" && ${MACHINE_ARCH} != "sparc64"
+ACFLAGS+= -Wa,--noexecstack
+.endif
+.else
+.PATH: ${.CURDIR}/../../../sys/cddl/compat/opensolaris/kern
+ATOMIC_SRCS= opensolaris_atomic.c
+.endif
+# UNICODE_SRCS
+.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/unicode
+
+LIB= zpool
+
+ZFS_COMMON_SRCS= ${ZFS_COMMON_OBJS:C/.o$/.c/} vdev_file.c trim_map.c
+ZFS_SHARED_SRCS= ${ZFS_SHARED_OBJS:C/.o$/.c/}
+KERNEL_SRCS= kernel.c taskq.c util.c
+LIST_SRCS= list.c
+UNICODE_SRCS= u8_textprep.c
+
+SRCS= ${ZFS_COMMON_SRCS} ${ZFS_SHARED_SRCS} \
+ ${KERNEL_SRCS} ${LIST_SRCS} ${ATOMIC_SRCS} \
+ ${UNICODE_SRCS}
+
+WARNS?= 0
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
+CFLAGS+= -I${.CURDIR}/../../compat/opensolaris/include
+CFLAGS+= -I${.CURDIR}/../../compat/opensolaris/lib/libumem
+CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/lib/libzpool/common
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+CFLAGS+= -I${.CURDIR}/../../lib/libumem
+CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/lib/libnvpair
+# XXX: pthread doesn't have mutex_owned() equivalent, so we need to look
+# into libthr private structures. That's sooo evil, but it's only for
+# ZFS debugging tools needs.
+CFLAGS+= -DWANTS_MUTEX_OWNED
+CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/thread
+CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys
+CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include
+
+DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ}
+LDADD= -lmd -lpthread -lz
+
+# atomic.S doesn't like profiling.
+NO_PROFILE=
+
+CSTD= c99
+
+CFLAGS+= -DDEBUG=1
+#DEBUG_FLAGS+= -g
+
+.include <bsd.lib.mk>
OpenPOWER on IntegriCloud