summaryrefslogtreecommitdiff
path: root/usr/src/lib/libcontract
diff options
context:
space:
mode:
authorstevel@tonic-gate <none@none>2005-06-14 00:00:00 -0700
committerstevel@tonic-gate <none@none>2005-06-14 00:00:00 -0700
commit7c478bd95313f5f23a4c958a745db2134aa03244 (patch)
treec871e58545497667cbb4b0a4f2daf204743e1fe7 /usr/src/lib/libcontract
downloadillumos-joyent-7c478bd95313f5f23a4c958a745db2134aa03244.tar.gz
OpenSolaris Launch
Diffstat (limited to 'usr/src/lib/libcontract')
-rw-r--r--usr/src/lib/libcontract/Makefile65
-rw-r--r--usr/src/lib/libcontract/Makefile.com59
-rw-r--r--usr/src/lib/libcontract/amd64/Makefile32
-rw-r--r--usr/src/lib/libcontract/common/libcontract.c514
-rw-r--r--usr/src/lib/libcontract/common/libcontract.h120
-rw-r--r--usr/src/lib/libcontract/common/libcontract_impl.h65
-rw-r--r--usr/src/lib/libcontract/common/libcontract_priv.c149
-rw-r--r--usr/src/lib/libcontract/common/libcontract_priv.h50
-rw-r--r--usr/src/lib/libcontract/common/llib-lcontract33
-rw-r--r--usr/src/lib/libcontract/common/process.c249
-rw-r--r--usr/src/lib/libcontract/common/process_dump.c156
-rw-r--r--usr/src/lib/libcontract/common/process_dump.h44
-rw-r--r--usr/src/lib/libcontract/i386/Makefile31
-rw-r--r--usr/src/lib/libcontract/sparc/Makefile31
-rw-r--r--usr/src/lib/libcontract/sparcv9/Makefile32
-rw-r--r--usr/src/lib/libcontract/spec/Makefile29
-rw-r--r--usr/src/lib/libcontract/spec/Makefile.targ32
-rw-r--r--usr/src/lib/libcontract/spec/amd64/Makefile37
-rw-r--r--usr/src/lib/libcontract/spec/contract.spec374
-rw-r--r--usr/src/lib/libcontract/spec/i386/Makefile35
-rw-r--r--usr/src/lib/libcontract/spec/private.spec56
-rw-r--r--usr/src/lib/libcontract/spec/sparc/Makefile35
-rw-r--r--usr/src/lib/libcontract/spec/sparcv9/Makefile37
-rw-r--r--usr/src/lib/libcontract/spec/versions43
24 files changed, 2308 insertions, 0 deletions
diff --git a/usr/src/lib/libcontract/Makefile b/usr/src/lib/libcontract/Makefile
new file mode 100644
index 0000000000..d42faf5b9d
--- /dev/null
+++ b/usr/src/lib/libcontract/Makefile
@@ -0,0 +1,65 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.lib
+
+HDRS = libcontract.h libcontract_priv.h
+HDRDIR = common
+SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+MSGFILES = common/process_dump.c
+POFILE = libcontract.po
+
+all := TARGET = all
+clean := TARGET = clean
+clobber := TARGET = clobber
+install := TARGET = install
+lint := TARGET = lint
+
+.KEEP_STATE:
+
+all clean clobber install: spec .WAIT $(SUBDIRS)
+
+$(POFILE): pofile_MSGFILES
+
+lint: $(SUBDIRS)
+
+install_h: $(ROOTHDRS)
+
+check: $(CHECKHDRS)
+
+_msg: $(MSGDOMAINPOFILE)
+
+$(SUBDIRS) spec: FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
+include ../../Makefile.msg.targ
diff --git a/usr/src/lib/libcontract/Makefile.com b/usr/src/lib/libcontract/Makefile.com
new file mode 100644
index 0000000000..9ba9a44e9d
--- /dev/null
+++ b/usr/src/lib/libcontract/Makefile.com
@@ -0,0 +1,59 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+LIBRARY = libcontract.a
+VERS = .1
+
+OBJECTS = \
+ libcontract.o \
+ libcontract_priv.o \
+ process.o \
+ process_dump.o
+
+# include library definition
+include ../../Makefile.lib
+include ../../Makefile.rootfs
+
+LIBS = $(DYNLIB) $(LINTLIB)
+SRCDIR = ../common
+
+$(LINTLIB) := SRCS = $(SRCDIR)/llib-lcontract
+LDLIBS += -lnvpair -lc
+MAPDIR = ../spec/$(TRANSMACH)
+SPECMAPFILE = $(MAPDIR)/mapfile
+
+CPPFLAGS += -I$(SRCDIR) -D_REENTRANT
+CFLAGS += -v
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+lint: $(LINTLIB) lintcheck
+
+include ../../Makefile.targ
diff --git a/usr/src/lib/libcontract/amd64/Makefile b/usr/src/lib/libcontract/amd64/Makefile
new file mode 100644
index 0000000000..dd68231e26
--- /dev/null
+++ b/usr/src/lib/libcontract/amd64/Makefile
@@ -0,0 +1,32 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64)
diff --git a/usr/src/lib/libcontract/common/libcontract.c b/usr/src/lib/libcontract/common/libcontract.c
new file mode 100644
index 0000000000..7cb35c4cfe
--- /dev/null
+++ b/usr/src/lib/libcontract/common/libcontract.c
@@ -0,0 +1,514 @@
+/*
+ * 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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/ctfs.h>
+#include <sys/contract.h>
+#include <libnvpair.h>
+#include <assert.h>
+#include <unistd.h>
+#include <errno.h>
+#include <libcontract.h>
+#include "libcontract_impl.h"
+
+/*
+ * Common template routines
+ */
+
+int
+ct_tmpl_activate(int fd)
+{
+ if (ioctl(fd, CT_TACTIVATE) == -1)
+ return (errno);
+ return (0);
+}
+
+int
+ct_tmpl_clear(int fd)
+{
+ if (ioctl(fd, CT_TCLEAR) == -1)
+ return (errno);
+ return (0);
+}
+
+int
+ct_tmpl_create(int fd, ctid_t *ctidp)
+{
+ ctid_t ctid = ioctl(fd, CT_TCREATE);
+ if (ctid == -1)
+ return (errno);
+ *ctidp = ctid;
+ return (0);
+}
+
+int
+ct_tmpl_set_internal(int fd, uint_t id, uint_t value)
+{
+ ct_param_t param;
+ param.ctpm_id = id;
+ param.ctpm_value = value;
+ if (ioctl(fd, CT_TSET, &param) == -1)
+ return (errno);
+ return (0);
+}
+
+int
+ct_tmpl_set_critical(int fd, uint_t events)
+{
+ return (ct_tmpl_set_internal(fd, CTP_EV_CRITICAL, events));
+}
+
+int
+ct_tmpl_set_informative(int fd, uint_t events)
+{
+ return (ct_tmpl_set_internal(fd, CTP_EV_INFO, events));
+}
+
+int
+ct_tmpl_set_cookie(int fd, uint64_t cookie)
+{
+ ct_param_t param;
+ param.ctpm_id = CTP_COOKIE;
+ param.ctpm_value = cookie;
+ if (ioctl(fd, CT_TSET, &param) == -1)
+ return (errno);
+ return (0);
+}
+
+int
+ct_tmpl_get_internal(int fd, uint_t id, uint_t *value)
+{
+ ct_param_t param;
+
+ param.ctpm_id = id;
+ if (ioctl(fd, CT_TGET, &param) == -1)
+ return (errno);
+ *value = param.ctpm_value;
+ return (0);
+}
+
+int
+ct_tmpl_get_critical(int fd, uint_t *events)
+{
+ return (ct_tmpl_get_internal(fd, CTP_EV_CRITICAL, events));
+}
+
+int
+ct_tmpl_get_informative(int fd, uint_t *events)
+{
+ return (ct_tmpl_get_internal(fd, CTP_EV_INFO, events));
+}
+
+int
+ct_tmpl_get_cookie(int fd, uint64_t *cookie)
+{
+ ct_param_t param;
+
+ param.ctpm_id = CTP_COOKIE;
+ if (ioctl(fd, CT_TGET, &param) == -1)
+ return (errno);
+ *cookie = param.ctpm_value;
+ return (0);
+}
+
+/*
+ * Common ctl routines
+ */
+
+int
+ct_ctl_adopt(int fd)
+{
+ if (ioctl(fd, CT_CADOPT) == -1)
+ return (errno);
+ return (0);
+}
+
+int
+ct_ctl_abandon(int fd)
+{
+ if (ioctl(fd, CT_CABANDON) == -1)
+ return (errno);
+ return (0);
+}
+
+/*ARGSUSED*/
+int
+ct_ctl_newct(int cfd, ctevid_t evid, int tfd)
+{
+ if (ioctl(cfd, CT_CNEWCT, tfd) == -1)
+ return (errno);
+ return (0);
+}
+
+int
+ct_ctl_ack(int fd, ctevid_t event)
+{
+ if (ioctl(fd, CT_CACK, &event) == -1)
+ return (errno);
+ return (0);
+}
+
+int
+ct_ctl_qack(int fd, ctevid_t event)
+{
+ if (ioctl(fd, CT_CQREQ, &event) == -1)
+ return (errno);
+ return (0);
+}
+
+/*
+ * Common status routines
+ */
+
+int
+ct_status_read(int fd, int detail, ct_stathdl_t *stathdl)
+{
+ char *status_buffer = NULL;
+ int status_nbytes = 0;
+ struct ctlib_status_info *info;
+ int error;
+
+ info = malloc(sizeof (struct ctlib_status_info));
+ if (info == NULL)
+ return (errno);
+
+ info->status.ctst_detail = detail;
+ if (detail != CTD_COMMON) {
+ for (;;) {
+ info->status.ctst_nbytes = status_nbytes;
+ info->status.ctst_buffer = status_buffer;
+ do
+ error = ioctl(fd, CT_SSTATUS, &info->status);
+ while (error == -1 && errno == EINTR);
+ if (error == -1)
+ goto errout;
+ if (info->status.ctst_nbytes <= status_nbytes)
+ break;
+
+ if (status_buffer)
+ free(status_buffer);
+ status_nbytes = info->status.ctst_nbytes;
+ status_buffer = malloc(status_nbytes);
+ if (status_buffer == NULL)
+ goto errout;
+ }
+ if ((errno = nvlist_unpack(info->status.ctst_buffer,
+ info->status.ctst_nbytes, &info->nvl, 0)) != 0)
+ goto errout;
+
+ free(status_buffer);
+ status_buffer = NULL;
+
+ } else {
+ info->status.ctst_nbytes = 0;
+ info->nvl = NULL;
+ if (ioctl(fd, CT_SSTATUS, &info->status) == -1)
+ goto errout;
+ }
+
+ *stathdl = info;
+ return (0);
+
+errout:
+ error = errno;
+ if (status_buffer)
+ free(status_buffer);
+ if (info)
+ free(info);
+ return (error);
+}
+
+void
+ct_status_free(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+
+ if (info->nvl) {
+ assert(info->status.ctst_detail != CTD_COMMON);
+ nvlist_free(info->nvl);
+ }
+
+ free(info);
+}
+
+ctid_t
+ct_status_get_id(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_id);
+}
+
+zoneid_t
+ct_status_get_zoneid(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_zoneid);
+}
+
+const char *
+ct_status_get_type(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (types[info->status.ctst_type].type_name);
+}
+
+id_t
+ct_status_get_holder(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_holder);
+}
+
+ctstate_t
+ct_status_get_state(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_state);
+}
+
+int
+ct_status_get_nevents(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_nevents);
+}
+
+int
+ct_status_get_ntime(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_ntime);
+}
+
+int
+ct_status_get_qtime(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_qtime);
+}
+
+ctevid_t
+ct_status_get_nevid(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_nevid);
+}
+
+uint_t
+ct_status_get_informative(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_informative);
+}
+
+uint_t
+ct_status_get_critical(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_critical);
+}
+
+uint64_t
+ct_status_get_cookie(ct_stathdl_t stathdl)
+{
+ struct ctlib_status_info *info = stathdl;
+ return (info->status.ctst_cookie);
+}
+
+/*
+ * Common event routines
+ */
+
+static int
+unpack_and_merge(nvlist_t **nvl, char *buffer, size_t len)
+{
+ nvlist_t *tmpnvl;
+ int error;
+
+ if ((error = nvlist_unpack(buffer, len, &tmpnvl, 0)) != 0)
+ return (error);
+
+ if (*nvl == NULL) {
+ *nvl = tmpnvl;
+ return (0);
+ }
+
+ error = nvlist_merge(*nvl, tmpnvl, 0);
+ nvlist_free(tmpnvl);
+ return (error);
+}
+
+static int
+ct_event_read_internal(int fd, int cmd, ct_evthdl_t *evt)
+{
+ char *event_buffer = NULL;
+ int event_nbytes = 0;
+ struct ctlib_event_info *info;
+ ct_event_t *event;
+ int error;
+
+ info = malloc(sizeof (struct ctlib_event_info));
+ if (info == NULL)
+ return (errno);
+ info->nvl = NULL;
+ event = &info->event;
+
+ for (;;) {
+ event->ctev_nbytes = event_nbytes;
+ event->ctev_buffer = event_buffer;
+ do
+ error = ioctl(fd, cmd, event);
+ while (error == -1 && errno == EINTR);
+ if (error == -1) {
+ error = errno;
+ goto errout;
+ }
+ if (event->ctev_nbytes <= event_nbytes)
+ break;
+
+ if (event_buffer)
+ free(event_buffer);
+ event_nbytes = event->ctev_nbytes;
+ event_buffer = malloc(event_nbytes);
+ if (event_buffer == NULL) {
+ error = errno;
+ goto errout;
+ }
+ }
+
+ if (event->ctev_goffset > 0 && (error = unpack_and_merge(&info->nvl,
+ event->ctev_buffer, event->ctev_goffset)) != 0)
+ goto errout;
+
+ if (event->ctev_goffset < event->ctev_nbytes &&
+ (error = unpack_and_merge(&info->nvl,
+ event->ctev_buffer + event->ctev_goffset,
+ event->ctev_nbytes - event->ctev_goffset)) != 0)
+ goto errout;
+
+ free(event_buffer);
+
+ *evt = info;
+ return (0);
+
+errout:
+ if (event_buffer)
+ free(event_buffer);
+ if (info) {
+ if (info->nvl)
+ nvlist_free(info->nvl);
+ free(info);
+ }
+ return (error);
+}
+
+int
+ct_event_read(int fd, ct_evthdl_t *evthdl)
+{
+ return (ct_event_read_internal(fd, CT_ERECV, evthdl));
+}
+
+int
+ct_event_read_critical(int fd, ct_evthdl_t *evthdl)
+{
+ return (ct_event_read_internal(fd, CT_ECRECV, evthdl));
+}
+
+int
+ct_event_reset(int fd)
+{
+ if (ioctl(fd, CT_ERESET) == -1)
+ return (errno);
+ return (0);
+}
+
+int
+ct_event_reliable(int fd)
+{
+ if (ioctl(fd, CT_ERELIABLE) == -1)
+ return (errno);
+ return (0);
+}
+
+void
+ct_event_free(ct_evthdl_t evthdl)
+{
+ struct ctlib_event_info *info = evthdl;
+
+ if (info->nvl)
+ nvlist_free(info->nvl);
+ free(info);
+}
+
+
+uint_t
+ct_event_get_flags(ct_evthdl_t evthdl)
+{
+ struct ctlib_event_info *info = evthdl;
+ return (info->event.ctev_flags);
+}
+
+ctid_t
+ct_event_get_ctid(ct_evthdl_t evthdl)
+{
+ struct ctlib_event_info *info = evthdl;
+ return (info->event.ctev_id);
+}
+
+ctevid_t
+ct_event_get_evid(ct_evthdl_t evthdl)
+{
+ struct ctlib_event_info *info = evthdl;
+ return (info->event.ctev_evid);
+}
+
+uint_t
+ct_event_get_type(ct_evthdl_t evthdl)
+{
+ struct ctlib_event_info *info = evthdl;
+ return (info->event.ctev_type);
+}
+
+int
+ct_event_get_nevid(ct_evthdl_t evthdl, ctevid_t *evidp)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->nvl == NULL ||
+ nvlist_lookup_uint64(info->nvl, CTS_NEVID, evidp))
+ return (EINVAL);
+ return (0);
+}
+
+int
+ct_event_get_newct(ct_evthdl_t evthdl, ctid_t *ctidp)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->nvl == NULL ||
+ nvlist_lookup_int32(info->nvl, CTS_NEWCT, (int *)ctidp))
+ return (EINVAL);
+ return (0);
+}
diff --git a/usr/src/lib/libcontract/common/libcontract.h b/usr/src/lib/libcontract/common/libcontract.h
new file mode 100644
index 0000000000..98092b7db0
--- /dev/null
+++ b/usr/src/lib/libcontract/common/libcontract.h
@@ -0,0 +1,120 @@
+/*
+ * 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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _LIBCONTRACT_H
+#define _LIBCONTRACT_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#include <sys/contract.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *ct_stathdl_t;
+typedef void *ct_evthdl_t;
+
+/*
+ * Common routines
+ */
+extern int ct_tmpl_activate(int);
+extern int ct_tmpl_clear(int);
+extern int ct_tmpl_create(int, ctid_t *);
+extern int ct_tmpl_set_cookie(int, uint64_t);
+extern int ct_tmpl_get_cookie(int, uint64_t *);
+extern int ct_tmpl_set_critical(int, uint_t);
+extern int ct_tmpl_get_critical(int, uint_t *);
+extern int ct_tmpl_set_informative(int, uint_t);
+extern int ct_tmpl_get_informative(int, uint_t *);
+
+extern int ct_ctl_adopt(int);
+extern int ct_ctl_abandon(int);
+extern int ct_ctl_ack(int, ctevid_t);
+extern int ct_ctl_qack(int, ctevid_t);
+extern int ct_ctl_newct(int, ctevid_t, int);
+
+extern int ct_status_read(int, int, ct_stathdl_t *);
+extern void ct_status_free(ct_stathdl_t);
+
+extern ctid_t ct_status_get_id(ct_stathdl_t);
+extern zoneid_t ct_status_get_zoneid(ct_stathdl_t);
+extern const char *ct_status_get_type(ct_stathdl_t);
+extern id_t ct_status_get_holder(ct_stathdl_t);
+extern ctstate_t ct_status_get_state(ct_stathdl_t);
+extern int ct_status_get_nevents(ct_stathdl_t);
+extern int ct_status_get_ntime(ct_stathdl_t);
+extern int ct_status_get_qtime(ct_stathdl_t);
+extern ctevid_t ct_status_get_nevid(ct_stathdl_t);
+extern uint_t ct_status_get_informative(ct_stathdl_t);
+extern uint_t ct_status_get_critical(ct_stathdl_t);
+extern uint64_t ct_status_get_cookie(ct_stathdl_t);
+
+extern int ct_event_read(int, ct_evthdl_t *);
+extern int ct_event_read_critical(int, ct_evthdl_t *);
+extern int ct_event_reset(int);
+extern int ct_event_reliable(int);
+extern void ct_event_free(ct_evthdl_t);
+
+extern uint_t ct_event_get_flags(ct_evthdl_t);
+extern ctid_t ct_event_get_ctid(ct_evthdl_t);
+extern ctevid_t ct_event_get_evid(ct_evthdl_t);
+extern uint_t ct_event_get_type(ct_evthdl_t);
+extern int ct_event_get_nevid(ct_evthdl_t, ctevid_t *);
+extern int ct_event_get_newct(ct_evthdl_t, ctid_t *);
+
+/*
+ * Process contract routines
+ */
+extern int ct_pr_tmpl_set_transfer(int, ctid_t);
+extern int ct_pr_tmpl_set_fatal(int, uint_t);
+extern int ct_pr_tmpl_set_param(int, uint_t);
+
+extern int ct_pr_tmpl_get_transfer(int, ctid_t *);
+extern int ct_pr_tmpl_get_fatal(int, uint_t *);
+extern int ct_pr_tmpl_get_param(int, uint_t *);
+
+extern int ct_pr_event_get_pid(ct_evthdl_t, pid_t *);
+extern int ct_pr_event_get_ppid(ct_evthdl_t, pid_t *);
+extern int ct_pr_event_get_signal(ct_evthdl_t, int *);
+extern int ct_pr_event_get_sender(ct_evthdl_t, pid_t *);
+extern int ct_pr_event_get_senderct(ct_evthdl_t, ctid_t *);
+extern int ct_pr_event_get_exitstatus(ct_evthdl_t, int *);
+extern int ct_pr_event_get_pcorefile(ct_evthdl_t, const char **);
+extern int ct_pr_event_get_gcorefile(ct_evthdl_t, const char **);
+extern int ct_pr_event_get_zcorefile(ct_evthdl_t, const char **);
+
+extern int ct_pr_status_get_param(ct_stathdl_t, uint_t *);
+extern int ct_pr_status_get_fatal(ct_stathdl_t, uint_t *);
+extern int ct_pr_status_get_members(ct_stathdl_t, pid_t **, uint_t *);
+extern int ct_pr_status_get_contracts(ct_stathdl_t, ctid_t **, uint_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBCONTRACT_H */
diff --git a/usr/src/lib/libcontract/common/libcontract_impl.h b/usr/src/lib/libcontract/common/libcontract_impl.h
new file mode 100644
index 0000000000..d8504cb5cf
--- /dev/null
+++ b/usr/src/lib/libcontract/common/libcontract_impl.h
@@ -0,0 +1,65 @@
+/*
+ * 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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _LIBCONTRACT_IMPL_H
+#define _LIBCONTRACT_IMPL_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/contract.h>
+#include <libnvpair.h>
+#include <libcontract.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ctlib_status_info {
+ ct_status_t status;
+ nvlist_t *nvl;
+};
+
+struct ctlib_event_info {
+ ct_event_t event;
+ nvlist_t *nvl;
+};
+
+extern int ct_tmpl_set_internal(int, uint_t, uint_t);
+extern int ct_tmpl_get_internal(int, uint_t, uint_t *);
+
+typedef struct contract_type {
+ const char *type_name;
+ void (*type_event)(FILE *, ct_evthdl_t, int);
+} contract_type_t;
+
+extern contract_type_t types[CTT_MAXTYPE];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBCONTRACT_IMPL_H */
diff --git a/usr/src/lib/libcontract/common/libcontract_priv.c b/usr/src/lib/libcontract/common/libcontract_priv.c
new file mode 100644
index 0000000000..1db8ea2d95
--- /dev/null
+++ b/usr/src/lib/libcontract/common/libcontract_priv.c
@@ -0,0 +1,149 @@
+/*
+ * 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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/ctfs.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <assert.h>
+#include <libuutil.h>
+#include <string.h>
+#include <procfs.h>
+#include <libcontract.h>
+#include <libcontract_priv.h>
+#include "libcontract_impl.h"
+#include "process_dump.h"
+
+
+contract_type_t types[CTT_MAXTYPE] = {
+ { "process", event_process }
+};
+
+static int
+close_on_exec(int fd)
+{
+ int flags = fcntl(fd, F_GETFD, 0);
+ if ((flags != -1) && (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) != -1))
+ return (0);
+ return (-1);
+}
+
+int
+contract_latest(ctid_t *id)
+{
+ int cfd, r;
+ ct_stathdl_t st;
+ ctid_t result;
+
+ if ((cfd = open64(CTFS_ROOT "/process/latest", O_RDONLY)) == -1)
+ return (errno);
+
+ if ((r = ct_status_read(cfd, CTD_COMMON, &st)) != 0) {
+ (void) close(cfd);
+ return (r);
+ }
+
+ result = ct_status_get_id(st);
+ ct_status_free(st);
+ (void) close(cfd);
+
+ *id = result;
+ return (0);
+}
+
+int
+contract_open(ctid_t ctid, const char *type, const char *file, int oflag)
+{
+ char path[PATH_MAX];
+ int n, fd;
+
+ assert((oflag & O_CREAT) == 0);
+
+ if (type == NULL)
+ type = "all";
+
+ n = snprintf(path, PATH_MAX, CTFS_ROOT "/%s/%ld/%s", type, ctid, file);
+ if (n >= PATH_MAX) {
+ errno = ENAMETOOLONG;
+ return (-1);
+ }
+
+ fd = open64(path, oflag);
+ if (fd != -1) {
+ if (close_on_exec(fd) == -1) {
+ int err = errno;
+ (void) close(fd);
+ errno = err;
+ return (-1);
+ }
+ }
+ return (fd);
+}
+
+int
+contract_abandon_id(ctid_t ctid)
+{
+ int fd, err;
+
+ fd = contract_open(ctid, "all", "ctl", O_WRONLY);
+ if (fd == -1)
+ return (errno);
+
+ err = ct_ctl_abandon(fd);
+ (void) close(fd);
+
+ return (err);
+}
+
+ctid_t
+getctid(void)
+{
+ int fd;
+ psinfo_t ps;
+
+ if ((fd = open("/proc/self/psinfo", O_RDONLY)) == -1)
+ return (-1);
+ if (read(fd, &ps, sizeof (ps)) != sizeof (ps)) {
+ (void) close(fd);
+ return (-1);
+ }
+ (void) close(fd);
+ return (ps.pr_contract);
+}
+
+void
+contract_event_dump(FILE *file, ct_evthdl_t hdl, int verbose)
+{
+ ct_typeid_t type;
+ struct ctlib_event_info *info = hdl;
+
+ type = info->event.ctev_cttype;
+ types[type].type_event(file, hdl, verbose);
+}
diff --git a/usr/src/lib/libcontract/common/libcontract_priv.h b/usr/src/lib/libcontract/common/libcontract_priv.h
new file mode 100644
index 0000000000..a1069efb35
--- /dev/null
+++ b/usr/src/lib/libcontract/common/libcontract_priv.h
@@ -0,0 +1,50 @@
+/*
+ * 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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _LIBCONTRACT_PRIV_H
+#define _LIBCONTRACT_PRIV_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/contract.h>
+#include <libcontract.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int contract_latest(ctid_t *);
+extern int contract_open(ctid_t, const char *, const char *, int);
+extern int contract_abandon_id(ctid_t);
+extern ctid_t getctid(void);
+extern void contract_event_dump(FILE *, ct_evthdl_t, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBCONTRACT_PRIV_H */
diff --git a/usr/src/lib/libcontract/common/llib-lcontract b/usr/src/lib/libcontract/common/llib-lcontract
new file mode 100644
index 0000000000..a93b64367e
--- /dev/null
+++ b/usr/src/lib/libcontract/common/llib-lcontract
@@ -0,0 +1,33 @@
+/*
+ * 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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/* LINTLIBRARY */
+/* PROTOLIB1 */
+
+#include <libcontract.h>
+#include <libcontract_priv.h>
diff --git a/usr/src/lib/libcontract/common/process.c b/usr/src/lib/libcontract/common/process.c
new file mode 100644
index 0000000000..b012c4f5bc
--- /dev/null
+++ b/usr/src/lib/libcontract/common/process.c
@@ -0,0 +1,249 @@
+/*
+ * 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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/ctfs.h>
+#include <sys/contract.h>
+#include <sys/contract/process.h>
+#include <errno.h>
+#include <unistd.h>
+#include <libnvpair.h>
+#include <libcontract.h>
+#include "libcontract_impl.h"
+
+/*
+ * Process contract template routines
+ */
+
+int
+ct_pr_tmpl_set_transfer(int fd, ctid_t ctid)
+{
+ return (ct_tmpl_set_internal(fd, CTPP_SUBSUME, ctid));
+}
+
+int
+ct_pr_tmpl_set_fatal(int fd, uint_t events)
+{
+ return (ct_tmpl_set_internal(fd, CTPP_EV_FATAL, events));
+}
+
+int
+ct_pr_tmpl_set_param(int fd, uint_t param)
+{
+ return (ct_tmpl_set_internal(fd, CTPP_PARAMS, param));
+}
+
+int
+ct_pr_tmpl_get_transfer(int fd, ctid_t *ctid)
+{
+ return (ct_tmpl_get_internal(fd, CTPP_SUBSUME, (uint_t *)ctid));
+}
+
+int
+ct_pr_tmpl_get_fatal(int fd, uint_t *events)
+{
+ return (ct_tmpl_get_internal(fd, CTPP_EV_FATAL, events));
+}
+
+int
+ct_pr_tmpl_get_param(int fd, uint_t *param)
+{
+ return (ct_tmpl_get_internal(fd, CTPP_PARAMS, param));
+}
+
+/*
+ * Process contract event routines
+ */
+
+int
+ct_pr_event_get_pid(ct_evthdl_t evthdl, pid_t *pid)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->event.ctev_cttype != CTT_PROCESS)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_uint32(info->nvl, CTPE_PID, (uint_t *)pid));
+}
+
+int
+ct_pr_event_get_ppid(ct_evthdl_t evthdl, pid_t *ppid)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->event.ctev_cttype != CTT_PROCESS)
+ return (EINVAL);
+ if (info->event.ctev_type != CT_PR_EV_FORK)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_uint32(info->nvl, CTPE_PPID, (uint_t *)ppid));
+}
+
+int
+ct_pr_event_get_signal(ct_evthdl_t evthdl, int *signal)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->event.ctev_cttype != CTT_PROCESS)
+ return (EINVAL);
+ if (info->event.ctev_type != CT_PR_EV_SIGNAL)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_uint32(info->nvl, CTPE_SIGNAL, (uint_t *)signal));
+}
+
+int
+ct_pr_event_get_sender(ct_evthdl_t evthdl, pid_t *sender)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->event.ctev_cttype != CTT_PROCESS)
+ return (EINVAL);
+ if (info->event.ctev_type != CT_PR_EV_SIGNAL)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_uint32(info->nvl, CTPE_SENDER, (uint_t *)sender));
+}
+
+int
+ct_pr_event_get_senderct(ct_evthdl_t evthdl, ctid_t *sendct)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->event.ctev_cttype != CTT_PROCESS)
+ return (EINVAL);
+ if (info->event.ctev_type != CT_PR_EV_SIGNAL)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_uint32(info->nvl, CTPE_SENDCT, (uint_t *)sendct));
+}
+
+int
+ct_pr_event_get_exitstatus(ct_evthdl_t evthdl, int *exitstatus)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->event.ctev_cttype != CTT_PROCESS)
+ return (EINVAL);
+ if (info->event.ctev_type != CT_PR_EV_EXIT)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_int32(info->nvl, CTPE_EXITSTATUS, exitstatus));
+}
+
+int
+ct_pr_event_get_pcorefile(ct_evthdl_t evthdl, const char **pcorefile)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->event.ctev_cttype != CTT_PROCESS)
+ return (EINVAL);
+ if (info->event.ctev_type != CT_PR_EV_CORE)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_string(info->nvl, CTPE_PCOREFILE,
+ (char **)pcorefile));
+}
+
+int
+ct_pr_event_get_gcorefile(ct_evthdl_t evthdl, const char **gcorefile)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->event.ctev_cttype != CTT_PROCESS)
+ return (EINVAL);
+ if (info->event.ctev_type != CT_PR_EV_CORE)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_string(info->nvl, CTPE_GCOREFILE,
+ (char **)gcorefile));
+}
+
+int
+ct_pr_event_get_zcorefile(ct_evthdl_t evthdl, const char **zcorefile)
+{
+ struct ctlib_event_info *info = evthdl;
+ if (info->event.ctev_cttype != CTT_PROCESS)
+ return (EINVAL);
+ if (info->event.ctev_type != CT_PR_EV_CORE)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_string(info->nvl, CTPE_ZCOREFILE,
+ (char **)zcorefile));
+}
+
+/*
+ * Process contract status routines
+ */
+
+int
+ct_pr_status_get_param(ct_stathdl_t stathdl, uint_t *param)
+{
+ struct ctlib_status_info *info = stathdl;
+ if (info->status.ctst_type != CTT_PROCESS)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_uint32(info->nvl, CTPS_PARAMS, param));
+}
+
+int
+ct_pr_status_get_fatal(ct_stathdl_t stathdl, uint_t *fatal)
+{
+ struct ctlib_status_info *info = stathdl;
+ if (info->status.ctst_type != CTT_PROCESS)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_uint32(info->nvl, CTPS_EV_FATAL, fatal));
+}
+
+int
+ct_pr_status_get_members(ct_stathdl_t stathdl, pid_t **members, uint_t *n)
+{
+ struct ctlib_status_info *info = stathdl;
+ if (info->status.ctst_type != CTT_PROCESS)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_uint32_array(info->nvl, CTPS_MEMBERS,
+ (uint_t **)members, n));
+}
+
+int
+ct_pr_status_get_contracts(ct_stathdl_t stathdl, ctid_t **contracts,
+ uint_t *n)
+{
+ struct ctlib_status_info *info = stathdl;
+ if (info->status.ctst_type != CTT_PROCESS)
+ return (EINVAL);
+ if (info->nvl == NULL)
+ return (ENOENT);
+ return (nvlist_lookup_uint32_array(info->nvl, CTPS_CONTRACTS,
+ (uint_t **)contracts, n));
+}
diff --git a/usr/src/lib/libcontract/common/process_dump.c b/usr/src/lib/libcontract/common/process_dump.c
new file mode 100644
index 0000000000..a43169fc65
--- /dev/null
+++ b/usr/src/lib/libcontract/common/process_dump.c
@@ -0,0 +1,156 @@
+/*
+ * 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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/contract/process.h>
+#include <sys/wait.h>
+#include <sys/ctfs.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <limits.h>
+#include <stdio.h>
+#include <assert.h>
+#include <signal.h>
+#include <libuutil.h>
+#include <libintl.h>
+#include <libcontract.h>
+#include <libcontract_priv.h>
+#include "libcontract_impl.h"
+
+void
+event_process(FILE *file, ct_evthdl_t ev, int verbose)
+{
+ uint_t type;
+ pid_t pid;
+ char *s;
+
+ type = ct_event_get_type(ev);
+ if (ct_pr_event_get_pid(ev, &pid) != 0) {
+ (void) fprintf(file, dgettext(TEXT_DOMAIN, "[bad event]\n"));
+ return;
+ }
+
+ switch (type) {
+ case CT_PR_EV_EMPTY:
+ s = dgettext(TEXT_DOMAIN, "contract empty\n");
+ break;
+ case CT_PR_EV_FORK:
+ s = dgettext(TEXT_DOMAIN, "process %d was created\n");
+ break;
+ case CT_PR_EV_EXIT:
+ s = dgettext(TEXT_DOMAIN, "process %d exited\n");
+ break;
+ case CT_PR_EV_CORE:
+ s = dgettext(TEXT_DOMAIN, "process %d dumped core\n");
+ break;
+ case CT_PR_EV_SIGNAL:
+ s = dgettext(TEXT_DOMAIN,
+ "process %d received a fatal signal\n");
+ break;
+ case CT_PR_EV_HWERR:
+ s = dgettext(TEXT_DOMAIN,
+ "process %d was killed by a hardware error\n");
+ break;
+ default:
+ s = dgettext(TEXT_DOMAIN, "process %d sent an unknown event\n");
+ break;
+ }
+
+ /*LINTED*/
+ (void) fprintf(file, s, pid);
+ if (!verbose)
+ return;
+
+ switch (type) {
+ int i;
+ const char *c;
+ char buf[SIG2STR_MAX];
+ ctid_t ctid;
+ case CT_PR_EV_FORK:
+ if (ct_pr_event_get_ppid(ev, &pid) == 0)
+ (void) fprintf(file, dgettext(TEXT_DOMAIN,
+ "\tparent pid: %d\n"), pid);
+ break;
+ case CT_PR_EV_EXIT:
+ if (ct_pr_event_get_exitstatus(ev, &i) != 0)
+ break;
+ (void) fprintf(file,
+ dgettext(TEXT_DOMAIN, "\twait status: 0x%x"), i);
+ if (WIFEXITED(i)) {
+ (void) fprintf(file, dgettext(TEXT_DOMAIN,
+ " (exited, code %d)\n"), WEXITSTATUS(i));
+ } else if (WIFSIGNALED(i)) {
+ int sig = WTERMSIG(i);
+ (void) fprintf(file,
+ dgettext(TEXT_DOMAIN, " (signal %d"), sig);
+ if (sig2str(sig, buf) == 0)
+ (void) fprintf(file,
+ dgettext(TEXT_DOMAIN, " (SIG%s)"), buf);
+ if (WCOREDUMP(i))
+ (void) fprintf(file,
+ dgettext(TEXT_DOMAIN, ", core dumped)\n"));
+ else
+ (void) fprintf(file,
+ dgettext(TEXT_DOMAIN, ")\n"));
+ } else {
+ /*
+ * We really shouldn't get here.
+ */
+ (void) fprintf(file, dgettext(TEXT_DOMAIN, "\n"));
+ }
+ break;
+ case CT_PR_EV_CORE:
+ if (ct_pr_event_get_pcorefile(ev, &c) == 0)
+ (void) fprintf(file, dgettext(TEXT_DOMAIN,
+ "\tprocess core: %s\n"), c);
+ if (ct_pr_event_get_gcorefile(ev, &c) == 0)
+ (void) fprintf(file, dgettext(TEXT_DOMAIN,
+ "\tglobal core: %s\n"), c);
+ if (ct_pr_event_get_zcorefile(ev, &c) == 0)
+ (void) fprintf(file, dgettext(TEXT_DOMAIN,
+ "\tglobal zone core: %s\n"), c);
+ break;
+ case CT_PR_EV_SIGNAL:
+ if (ct_pr_event_get_signal(ev, &i) == 0) {
+ if (sig2str(i, buf) == -1)
+ (void) fprintf(file, dgettext(TEXT_DOMAIN,
+ "\tsignal: %d\n"), i);
+ else
+ (void) fprintf(file, dgettext(TEXT_DOMAIN,
+ "\tsignal: %d (SIG%s)\n"), i, buf);
+ }
+ if (ct_pr_event_get_sender(ev, &pid) == 0)
+ (void) fprintf(file, dgettext(TEXT_DOMAIN,
+ "\tsender pid: %d\n"), pid);
+ if (ct_pr_event_get_senderct(ev, &ctid) == 0)
+ (void) fprintf(file, dgettext(TEXT_DOMAIN,
+ "\tsender ctid: %d\n"), ctid);
+ break;
+ }
+}
diff --git a/usr/src/lib/libcontract/common/process_dump.h b/usr/src/lib/libcontract/common/process_dump.h
new file mode 100644
index 0000000000..b5dce8f98b
--- /dev/null
+++ b/usr/src/lib/libcontract/common/process_dump.h
@@ -0,0 +1,44 @@
+/*
+ * 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 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _PROCESS_DUMP_H
+#define _PROCESS_DUMP_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include "libcontract_impl.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void event_process(FILE *, ct_evthdl_t, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PROCESS_DUMP_H */
diff --git a/usr/src/lib/libcontract/i386/Makefile b/usr/src/lib/libcontract/i386/Makefile
new file mode 100644
index 0000000000..af76f5ab90
--- /dev/null
+++ b/usr/src/lib/libcontract/i386/Makefile
@@ -0,0 +1,31 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libcontract/sparc/Makefile b/usr/src/lib/libcontract/sparc/Makefile
new file mode 100644
index 0000000000..af76f5ab90
--- /dev/null
+++ b/usr/src/lib/libcontract/sparc/Makefile
@@ -0,0 +1,31 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libcontract/sparcv9/Makefile b/usr/src/lib/libcontract/sparcv9/Makefile
new file mode 100644
index 0000000000..cb39a2beff
--- /dev/null
+++ b/usr/src/lib/libcontract/sparcv9/Makefile
@@ -0,0 +1,32 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libcontract/spec/Makefile b/usr/src/lib/libcontract/spec/Makefile
new file mode 100644
index 0000000000..ecee1572a9
--- /dev/null
+++ b/usr/src/lib/libcontract/spec/Makefile
@@ -0,0 +1,29 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include $(SRC)/lib/Makefile.spec.arch
diff --git a/usr/src/lib/libcontract/spec/Makefile.targ b/usr/src/lib/libcontract/spec/Makefile.targ
new file mode 100644
index 0000000000..5280075a79
--- /dev/null
+++ b/usr/src/lib/libcontract/spec/Makefile.targ
@@ -0,0 +1,32 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+LIBRARY= libcontract.a
+VERS= .1
+OBJECTS= contract.o private.o
+SPECCPP= -I../../common
diff --git a/usr/src/lib/libcontract/spec/amd64/Makefile b/usr/src/lib/libcontract/spec/amd64/Makefile
new file mode 100644
index 0000000000..6b587843c7
--- /dev/null
+++ b/usr/src/lib/libcontract/spec/amd64/Makefile
@@ -0,0 +1,37 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+.KEEP_STATE:
+
+include ../Makefile.targ
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.lib.64
+
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB)
diff --git a/usr/src/lib/libcontract/spec/contract.spec b/usr/src/lib/libcontract/spec/contract.spec
new file mode 100644
index 0000000000..60b4925d11
--- /dev/null
+++ b/usr/src/lib/libcontract/spec/contract.spec
@@ -0,0 +1,374 @@
+#
+# Copyright 2005 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, 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
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+function ct_tmpl_activate
+include <libcontract.h>
+declaration int ct_tmpl_activate(int)
+version SUNW_1.1
+end
+
+function ct_tmpl_clear
+include <libcontract.h>
+declaration int ct_tmpl_clear(int)
+version SUNW_1.1
+end
+
+function ct_tmpl_create
+include <libcontract.h>
+declaration int ct_tmpl_create(int, ctid_t *)
+version SUNW_1.1
+end
+
+function ct_tmpl_set_cookie
+include <libcontract.h>
+declaration int ct_tmpl_set_cookie(int, uint64_t)
+version SUNW_1.1
+end
+
+function ct_tmpl_get_cookie
+include <libcontract.h>
+declaration int ct_tmpl_get_cookie(int, uint64_t *)
+version SUNW_1.1
+end
+
+function ct_tmpl_set_critical
+include <libcontract.h>
+declaration int ct_tmpl_set_critical(int, uint_t)
+version SUNW_1.1
+end
+
+function ct_tmpl_get_critical
+include <libcontract.h>
+declaration int ct_tmpl_get_critical(int, uint_t *)
+version SUNW_1.1
+end
+
+function ct_tmpl_set_informative
+include <libcontract.h>
+declaration int ct_tmpl_set_informative(int, uint_t)
+version SUNW_1.1
+end
+
+function ct_tmpl_get_informative
+include <libcontract.h>
+declaration int ct_tmpl_get_informative(int, uint_t *)
+version SUNW_1.1
+end
+
+function ct_ctl_adopt
+include <libcontract.h>
+declaration int ct_ctl_adopt(int)
+version SUNW_1.1
+end
+
+function ct_ctl_abandon
+include <libcontract.h>
+declaration int ct_ctl_abandon(int)
+version SUNW_1.1
+end
+
+function ct_ctl_ack
+include <libcontract.h>
+declaration int ct_ctl_ack(int, ctevid_t)
+version SUNW_1.1
+end
+
+function ct_ctl_qack
+include <libcontract.h>
+declaration int ct_ctl_qack(int, ctevid_t)
+version SUNW_1.1
+end
+
+function ct_ctl_newct
+include <libcontract.h>
+declaration int ct_ctl_newct(int, ctevid_t, int)
+version SUNW_1.1
+end
+
+function ct_status_read
+include <libcontract.h>
+declaration int ct_status_read(int, int, ct_stathdl_t *)
+version SUNW_1.1
+end
+
+function ct_status_free
+include <libcontract.h>
+declaration void ct_status_free(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_id
+include <libcontract.h>
+declaration ctid_t ct_status_get_id(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_zoneid
+include <libcontract.h>
+declaration zoneid_t ct_status_get_zoneid(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_type
+include <libcontract.h>
+declaration const char *ct_status_get_type(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_holder
+include <libcontract.h>
+declaration id_t ct_status_get_holder(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_state
+include <libcontract.h>
+declaration ctstate_t ct_status_get_state(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_nevents
+include <libcontract.h>
+declaration int ct_status_get_nevents(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_ntime
+include <libcontract.h>
+declaration int ct_status_get_ntime(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_qtime
+include <libcontract.h>
+declaration int ct_status_get_qtime(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_nevid
+include <libcontract.h>
+declaration ctevid_t ct_status_get_nevid(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_informative
+include <libcontract.h>
+declaration uint_t ct_status_get_informative(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_critical
+include <libcontract.h>
+declaration uint_t ct_status_get_critical(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_status_get_cookie
+include <libcontract.h>
+declaration uint64_t ct_status_get_cookie(ct_stathdl_t)
+version SUNW_1.1
+end
+
+function ct_event_read
+include <libcontract.h>
+declaration int ct_event_read(int, ct_evthdl_t *)
+version SUNW_1.1
+end
+
+function ct_event_read_critical
+include <libcontract.h>
+declaration int ct_event_read_critical(int, ct_evthdl_t *)
+version SUNW_1.1
+end
+
+function ct_event_reset
+include <libcontract.h>
+declaration int ct_event_reset(int)
+version SUNW_1.1
+end
+
+function ct_event_reliable
+include <libcontract.h>
+declaration int ct_event_reliable(int)
+version SUNW_1.1
+end
+
+function ct_event_free
+include <libcontract.h>
+declaration void ct_event_free(ct_evthdl_t)
+version SUNW_1.1
+end
+
+function ct_event_get_flags
+include <libcontract.h>
+declaration uint_t ct_event_get_flags(ct_evthdl_t)
+version SUNW_1.1
+end
+
+function ct_event_get_ctid
+include <libcontract.h>
+declaration ctid_t ct_event_get_ctid(ct_evthdl_t)
+version SUNW_1.1
+end
+
+function ct_event_get_evid
+include <libcontract.h>
+declaration ctevid_t ct_event_get_evid(ct_evthdl_t)
+version SUNW_1.1
+end
+
+function ct_event_get_type
+include <libcontract.h>
+declaration uint_t ct_event_get_type(ct_evthdl_t)
+version SUNW_1.1
+end
+
+function ct_event_get_nevid
+include <libcontract.h>
+declaration int ct_event_get_nevid(ct_evthdl_t, ctevid_t *)
+version SUNW_1.1
+end
+
+function ct_event_get_newct
+include <libcontract.h>
+declaration int ct_event_get_newct(ct_evthdl_t, ctid_t *)
+version SUNW_1.1
+end
+
+function ct_pr_tmpl_set_transfer
+include <libcontract.h>
+declaration int ct_pr_tmpl_set_transfer(int, ctid_t)
+version SUNW_1.1
+end
+
+function ct_pr_tmpl_set_fatal
+include <libcontract.h>
+declaration int ct_pr_tmpl_set_fatal(int, uint_t)
+version SUNW_1.1
+end
+
+function ct_pr_tmpl_set_param
+include <libcontract.h>
+declaration int ct_pr_tmpl_set_param(int, uint_t)
+version SUNW_1.1
+end
+
+function ct_pr_tmpl_get_transfer
+include <libcontract.h>
+declaration int ct_pr_tmpl_get_transfer(int, ctid_t *)
+version SUNW_1.1
+end
+
+function ct_pr_tmpl_get_fatal
+include <libcontract.h>
+declaration int ct_pr_tmpl_get_fatal(int, uint_t *)
+version SUNW_1.1
+end
+
+function ct_pr_tmpl_get_param
+include <libcontract.h>
+declaration int ct_pr_tmpl_get_param(int, uint_t *)
+version SUNW_1.1
+end
+
+function ct_pr_event_get_pid
+include <libcontract.h>
+declaration int ct_pr_event_get_pid(ct_evthdl_t, pid_t *)
+version SUNW_1.1
+end
+
+function ct_pr_event_get_ppid
+include <libcontract.h>
+declaration int ct_pr_event_get_ppid(ct_evthdl_t, pid_t *)
+version SUNW_1.1
+end
+
+function ct_pr_event_get_signal
+include <libcontract.h>
+declaration int ct_pr_event_get_signal(ct_evthdl_t, int *)
+version SUNW_1.1
+end
+
+function ct_pr_event_get_sender
+include <libcontract.h>
+declaration int ct_pr_event_get_sender(ct_evthdl_t, pid_t *)
+version SUNW_1.1
+end
+
+function ct_pr_event_get_senderct
+include <libcontract.h>
+declaration int ct_pr_event_get_senderct(ct_evthdl_t, ctid_t *)
+version SUNW_1.1
+end
+
+function ct_pr_event_get_exitstatus
+include <libcontract.h>
+declaration int ct_pr_event_get_exitstatus(ct_evthdl_t, int *)
+version SUNW_1.1
+end
+
+function ct_pr_event_get_pcorefile
+include <libcontract.h>
+declaration int ct_pr_event_get_pcorefile(ct_evthdl_t, const char **)
+version SUNW_1.1
+end
+
+function ct_pr_event_get_gcorefile
+include <libcontract.h>
+declaration int ct_pr_event_get_gcorefile(ct_evthdl_t, const char **)
+version SUNW_1.1
+end
+
+function ct_pr_event_get_zcorefile
+include <libcontract.h>
+declaration int ct_pr_event_get_zcorefile(ct_evthdl_t, const char **)
+version SUNW_1.1
+end
+
+function ct_pr_status_get_param
+include <libcontract.h>
+declaration int ct_pr_status_get_param(ct_stathdl_t, uint_t *)
+version SUNW_1.1
+end
+
+function ct_pr_status_get_fatal
+include <libcontract.h>
+declaration int ct_pr_status_get_fatal(ct_stathdl_t, uint_t *)
+version SUNW_1.1
+end
+
+function ct_pr_status_get_members
+include <libcontract.h>
+declaration int ct_pr_status_get_members(ct_stathdl_t, pid_t **, uint_t *)
+version SUNW_1.1
+end
+
+function ct_pr_status_get_contracts
+include <libcontract.h>
+declaration int ct_pr_status_get_contracts(ct_stathdl_t, ctid_t **, uint_t *)
+version SUNW_1.1
+end
diff --git a/usr/src/lib/libcontract/spec/i386/Makefile b/usr/src/lib/libcontract/spec/i386/Makefile
new file mode 100644
index 0000000000..027b13f5af
--- /dev/null
+++ b/usr/src/lib/libcontract/spec/i386/Makefile
@@ -0,0 +1,35 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+.KEEP_STATE:
+
+include ../Makefile.targ
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB)
diff --git a/usr/src/lib/libcontract/spec/private.spec b/usr/src/lib/libcontract/spec/private.spec
new file mode 100644
index 0000000000..65413dbb58
--- /dev/null
+++ b/usr/src/lib/libcontract/spec/private.spec
@@ -0,0 +1,56 @@
+#
+# Copyright 2005 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, 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
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+function contract_latest
+include <libcontract_priv.h>
+declaration int contract_latest(ctid_t *)
+version SUNWprivate_1.1
+end
+
+function contract_open
+include <libcontract_priv.h>
+declaration int contract_open(ctid_t, const char *, const char *, int)
+version SUNWprivate_1.1
+end
+
+function contract_abandon_id
+include <libcontract_priv.h>
+declaration int contract_abandon_id(ctid_t)
+version SUNWprivate_1.1
+end
+
+function getctid
+include <libcontract_priv.h>
+declaration ctid_t getctid(void)
+version SUNWprivate_1.1
+end
+
+function contract_event_dump
+include <libcontract_priv.h>
+declaration void contract_event_dump(FILE *, ct_evthdl_t, int)
+version SUNWprivate_1.1
+end
diff --git a/usr/src/lib/libcontract/spec/sparc/Makefile b/usr/src/lib/libcontract/spec/sparc/Makefile
new file mode 100644
index 0000000000..027b13f5af
--- /dev/null
+++ b/usr/src/lib/libcontract/spec/sparc/Makefile
@@ -0,0 +1,35 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+.KEEP_STATE:
+
+include ../Makefile.targ
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB)
diff --git a/usr/src/lib/libcontract/spec/sparcv9/Makefile b/usr/src/lib/libcontract/spec/sparcv9/Makefile
new file mode 100644
index 0000000000..751257f818
--- /dev/null
+++ b/usr/src/lib/libcontract/spec/sparcv9/Makefile
@@ -0,0 +1,37 @@
+#
+# 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 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+.KEEP_STATE:
+
+include ../Makefile.targ
+
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.lib.64
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB64)
diff --git a/usr/src/lib/libcontract/spec/versions b/usr/src/lib/libcontract/spec/versions
new file mode 100644
index 0000000000..1081ac6057
--- /dev/null
+++ b/usr/src/lib/libcontract/spec/versions
@@ -0,0 +1,43 @@
+#
+# Copyright 2005 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, 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
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+i386 {
+ SUNW_1.1;
+ SUNWprivate_1.1;
+}
+amd64 {
+ SUNW_1.1;
+ SUNWprivate_1.1;
+}
+sparc {
+ SUNW_1.1;
+ SUNWprivate_1.1;
+}
+sparcv9 {
+ SUNW_1.1;
+ SUNWprivate_1.1;
+}