xref: /onnv-gate/usr/src/uts/common/sys/contract_impl.h (revision 7937:3160250b7dc5)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
54845Svikram  * Common Development and Distribution License (the "License").
64845Svikram  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
226073Sacruz  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_CONTRACT_IMPL_H
270Sstevel@tonic-gate #define	_SYS_CONTRACT_IMPL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/list.h>
310Sstevel@tonic-gate #include <sys/poll.h>
320Sstevel@tonic-gate #include <sys/condvar.h>
330Sstevel@tonic-gate #include <sys/contract.h>
340Sstevel@tonic-gate #include <sys/model.h>
350Sstevel@tonic-gate #include <sys/cred.h>
360Sstevel@tonic-gate #include <sys/mutex.h>
370Sstevel@tonic-gate #include <sys/list.h>
380Sstevel@tonic-gate #include <sys/avl.h>
390Sstevel@tonic-gate #include <sys/nvpair.h>
400Sstevel@tonic-gate #include <sys/time.h>
410Sstevel@tonic-gate #include <sys/vnode.h>
420Sstevel@tonic-gate #include <sys/vfs.h>
430Sstevel@tonic-gate #include <sys/zone.h>
440Sstevel@tonic-gate #include <sys/project.h>
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #ifdef	__cplusplus
470Sstevel@tonic-gate extern "C" {
480Sstevel@tonic-gate #endif
490Sstevel@tonic-gate 
504845Svikram extern int ct_debug;
514845Svikram 
524845Svikram #define	CT_DEBUG(args)	if (ct_debug) cmn_err args
534845Svikram 
540Sstevel@tonic-gate #ifdef _SYSCALL32
550Sstevel@tonic-gate 
560Sstevel@tonic-gate /*
576073Sacruz  * 32-bit versions of the event, status and parameter structures, for use
586073Sacruz  * (only) by the 64-bit kernel.  See sys/contract.h for the normal versions.
590Sstevel@tonic-gate  * Use pack(4) to get offsets and structure size correct on amd64.
600Sstevel@tonic-gate  */
610Sstevel@tonic-gate 
620Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
630Sstevel@tonic-gate #pragma pack(4)
640Sstevel@tonic-gate #endif
650Sstevel@tonic-gate 
660Sstevel@tonic-gate typedef struct ct_event32 {
670Sstevel@tonic-gate 	ctid_t	ctev_id;
680Sstevel@tonic-gate 	uint32_t ctev_pad1;
690Sstevel@tonic-gate 	ctevid_t ctev_evid;
700Sstevel@tonic-gate 	ct_typeid_t ctev_cttype;
710Sstevel@tonic-gate 	uint32_t ctev_flags;
720Sstevel@tonic-gate 	uint32_t ctev_type;
730Sstevel@tonic-gate 	uint32_t ctev_nbytes;
740Sstevel@tonic-gate 	uint32_t ctev_goffset;
750Sstevel@tonic-gate 	uint32_t ctev_pad2;
760Sstevel@tonic-gate 	caddr32_t ctev_buffer;
770Sstevel@tonic-gate } ct_event32_t;
780Sstevel@tonic-gate 
790Sstevel@tonic-gate typedef struct ct_status32 {
800Sstevel@tonic-gate 	ctid_t	ctst_id;
810Sstevel@tonic-gate 	zoneid_t ctst_zoneid;
820Sstevel@tonic-gate 	ct_typeid_t ctst_type;
830Sstevel@tonic-gate 	pid_t	ctst_holder;
840Sstevel@tonic-gate 	ctstate_t ctst_state;
850Sstevel@tonic-gate 	int	ctst_nevents;
860Sstevel@tonic-gate 	int	ctst_ntime;
870Sstevel@tonic-gate 	int	ctst_qtime;
880Sstevel@tonic-gate 	uint64_t ctst_nevid;
890Sstevel@tonic-gate 	uint_t	ctst_detail;
900Sstevel@tonic-gate 	uint_t	ctst_nbytes;
910Sstevel@tonic-gate 	uint_t	ctst_critical;
920Sstevel@tonic-gate 	uint_t	ctst_informative;
930Sstevel@tonic-gate 	uint64_t ctst_cookie;
940Sstevel@tonic-gate 	caddr32_t ctst_buffer;
950Sstevel@tonic-gate } ct_status32_t;
960Sstevel@tonic-gate 
976073Sacruz typedef struct ct_param32 {
986073Sacruz 	uint32_t  ctpm_id;
996073Sacruz 	uint32_t  ctpm_size;
1006073Sacruz 	caddr32_t ctpm_value;
1016073Sacruz } ct_param32_t;
1026073Sacruz 
1030Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1040Sstevel@tonic-gate #pragma pack()
1050Sstevel@tonic-gate #endif
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate #endif /* _SYSCALL32 */
1080Sstevel@tonic-gate 
109*7937SAntonello.Cruz@Sun.COM /*
110*7937SAntonello.Cruz@Sun.COM  * in kernel version of parameter structure.
111*7937SAntonello.Cruz@Sun.COM  */
112*7937SAntonello.Cruz@Sun.COM typedef struct ct_kparam {
113*7937SAntonello.Cruz@Sun.COM 	ct_param_t	param;		/* copy of user ct_param_t */
114*7937SAntonello.Cruz@Sun.COM 	void		*ctpm_kbuf;	/* kernel buffer for parameter value */
115*7937SAntonello.Cruz@Sun.COM 	uint32_t	ret_size;	/* parameter value size for copyout */
116*7937SAntonello.Cruz@Sun.COM } ct_kparam_t;
117*7937SAntonello.Cruz@Sun.COM 
1180Sstevel@tonic-gate struct proc;
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate /*
1210Sstevel@tonic-gate  * Contract template ops vector
1220Sstevel@tonic-gate  */
1230Sstevel@tonic-gate typedef struct ctmplops {
1240Sstevel@tonic-gate 	struct ct_template	*(*ctop_dup)(struct ct_template *);
1250Sstevel@tonic-gate 	void		(*ctop_free)(struct ct_template *);
126*7937SAntonello.Cruz@Sun.COM 	int		(*ctop_set)(struct ct_template *, ct_kparam_t *,
1270Sstevel@tonic-gate 			const cred_t *);
128*7937SAntonello.Cruz@Sun.COM 	int		(*ctop_get)(struct ct_template *, ct_kparam_t *);
1294845Svikram 	int		(*ctop_create)(struct ct_template *, ctid_t *);
1300Sstevel@tonic-gate 	uint_t		allevents;
1310Sstevel@tonic-gate } ctmplops_t;
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate /*
1340Sstevel@tonic-gate  * Contract template
1350Sstevel@tonic-gate  */
1360Sstevel@tonic-gate typedef struct ct_template {
1370Sstevel@tonic-gate 	kmutex_t	ctmpl_lock;
1380Sstevel@tonic-gate 	ctmplops_t	*ctmpl_ops;
1390Sstevel@tonic-gate 	struct ct_type	*ctmpl_type;
1400Sstevel@tonic-gate 	void		*ctmpl_data;
1410Sstevel@tonic-gate 	uint64_t	ctmpl_cookie;	/* term: contract cookie */
1420Sstevel@tonic-gate 	uint_t		ctmpl_ev_crit;	/* term: critical events */
1430Sstevel@tonic-gate 	uint_t		ctmpl_ev_info;	/* term: informative events */
1440Sstevel@tonic-gate } ct_template_t;
1450Sstevel@tonic-gate 
1464845Svikram 
1470Sstevel@tonic-gate typedef enum ct_listnum {
1480Sstevel@tonic-gate 	CTEL_CONTRACT,			/* ../contracts/type/<id>/events */
1490Sstevel@tonic-gate 	CTEL_BUNDLE,			/* ../contracts/type/bundle */
1500Sstevel@tonic-gate 	CTEL_PBUNDLE,			/* ../contracts/type/pbundle */
1510Sstevel@tonic-gate 	CTEL_MAX
1520Sstevel@tonic-gate } ct_listnum_t;
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate typedef enum ctqflags {
1550Sstevel@tonic-gate 	CTQ_DEAD = 1,	/* contract explicitly cancelled */
1560Sstevel@tonic-gate 	CTQ_REFFED = 2	/* queue is reference counted */
1570Sstevel@tonic-gate } ctqflags_t;
1580Sstevel@tonic-gate 
1594845Svikram typedef enum ct_ack {
1604845Svikram 	CT_ACK = 1,	/* accept break */
1614845Svikram 	CT_NACK,	/* disallow break */
1624845Svikram 	CT_NONE		/* no matching contracts */
1634845Svikram } ct_ack_t;
1644845Svikram 
1650Sstevel@tonic-gate /*
1660Sstevel@tonic-gate  * Contract event queue
1670Sstevel@tonic-gate  */
1680Sstevel@tonic-gate typedef struct ct_equeue {
1690Sstevel@tonic-gate 	kmutex_t ctq_lock;
1700Sstevel@tonic-gate 	timespec_t ctq_atime;		/* access time */
1710Sstevel@tonic-gate 	ct_listnum_t ctq_listno;	/* which list node */
1720Sstevel@tonic-gate 	list_t	ctq_events;		/* list of events */
1730Sstevel@tonic-gate 	list_t	ctq_listeners;		/* list of all listeners */
1740Sstevel@tonic-gate 	list_t	ctq_tail;		/* list of tail listeners */
1750Sstevel@tonic-gate 	int	ctq_nlisteners;		/* number of listeners */
1760Sstevel@tonic-gate 	int	ctq_nreliable;		/* number of reliable listeners */
1770Sstevel@tonic-gate 	int	ctq_ninf;		/* number of informative events */
1780Sstevel@tonic-gate 	int	ctq_max;		/* max informative events */
1790Sstevel@tonic-gate 	ctqflags_t ctq_flags;		/* queue flags */
1800Sstevel@tonic-gate } ct_equeue_t;
1810Sstevel@tonic-gate 
1820Sstevel@tonic-gate typedef struct ct_member {
1830Sstevel@tonic-gate 	list_node_t	ctm_node;	/* list membership */
1840Sstevel@tonic-gate 	int		ctm_refs;	/* number of references per list */
1850Sstevel@tonic-gate 	int		ctm_trimmed;	/* membership has been trimmed */
1860Sstevel@tonic-gate 	int		ctm_nreliable;	/* reliable listeners */
1870Sstevel@tonic-gate } ct_member_t;
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate typedef struct ct_kevent {
1900Sstevel@tonic-gate 	kmutex_t	cte_lock;
1910Sstevel@tonic-gate 	uint64_t	cte_id;		/* event id */
1920Sstevel@tonic-gate 	uint_t		cte_type;	/* event type */
1930Sstevel@tonic-gate 	int		cte_refs;
1940Sstevel@tonic-gate 	ct_member_t	cte_nodes[CTEL_MAX]; /* event queue membership */
1950Sstevel@tonic-gate 	int		cte_flags;	/* see above */
1960Sstevel@tonic-gate 	nvlist_t 	*cte_data;	/* event data */
1970Sstevel@tonic-gate 	nvlist_t 	*cte_gdata;	/* global-zone only data */
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate 	struct contract	*cte_contract;	/* contract */
2000Sstevel@tonic-gate } ct_kevent_t;
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate /*
2030Sstevel@tonic-gate  * Contract vnode linkage.
2040Sstevel@tonic-gate  * Avoid having too much knowledge about the FS.
2050Sstevel@tonic-gate  */
2060Sstevel@tonic-gate typedef struct contract_vnode {
2070Sstevel@tonic-gate 	list_node_t	ctv_node;
2080Sstevel@tonic-gate 	vnode_t		*ctv_vnode;
2090Sstevel@tonic-gate } contract_vnode_t;
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate /*
2120Sstevel@tonic-gate  * Contract ops vector
2130Sstevel@tonic-gate  *   free - when reference count drops to zero
2140Sstevel@tonic-gate  *   abandon - when holding process dies or relinquishes interest
2150Sstevel@tonic-gate  *   destroy - when contract is to be completely destroyed
2160Sstevel@tonic-gate  *   status - when contractfs needs to return detailed status information
2170Sstevel@tonic-gate  */
2180Sstevel@tonic-gate typedef struct contops {
2190Sstevel@tonic-gate 	void	(*contop_free)(struct contract *);
2200Sstevel@tonic-gate 	void	(*contop_abandon)(struct contract *);
2210Sstevel@tonic-gate 	void	(*contop_destroy)(struct contract *);
2220Sstevel@tonic-gate 	void	(*contop_status)(struct contract *, zone_t *, int, nvlist_t *,
2230Sstevel@tonic-gate 	    void *, model_t);
2244845Svikram 	int	(*contop_ack)(struct contract *, uint_t evtype,
2254845Svikram 	    uint64_t evid);
2264845Svikram 	int	(*contop_nack)(struct contract *, uint_t evtype,
2274845Svikram 	    uint64_t evid);
2284845Svikram 	int	(*contop_qack)(struct contract *, uint_t, uint64_t);
2294845Svikram 	int	(*contop_newct)(struct contract *);
2300Sstevel@tonic-gate } contops_t;
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate typedef ct_template_t *(ct_f_default_t)(void);
2330Sstevel@tonic-gate 
2340Sstevel@tonic-gate /*
2350Sstevel@tonic-gate  * Contract type information.
2360Sstevel@tonic-gate  */
2370Sstevel@tonic-gate typedef struct ct_type {
2380Sstevel@tonic-gate 	uint64_t	ct_type_evid;	/* last event id */
2390Sstevel@tonic-gate 	ct_typeid_t	ct_type_index;	/* index in ct_types array */
2400Sstevel@tonic-gate 	const char	*ct_type_name;	/* type as a string */
2410Sstevel@tonic-gate 	kmutex_t	ct_type_lock;	/* protects ct_type_avl */
2420Sstevel@tonic-gate 	avl_tree_t	ct_type_avl;	/* ordered list of type contracts */
2430Sstevel@tonic-gate 	timestruc_t	ct_type_timestruc; /* time last contract was written */
2440Sstevel@tonic-gate 	ct_equeue_t	ct_type_events;	/* bundle queue */
2450Sstevel@tonic-gate 	contops_t	*ct_type_ops;
2460Sstevel@tonic-gate 	ct_f_default_t	*ct_type_default; /* creates a fresh template */
2470Sstevel@tonic-gate } ct_type_t;
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate typedef enum ctflags {
2500Sstevel@tonic-gate 	CTF_INHERIT = 0x1
2510Sstevel@tonic-gate } ctflags_t;
2520Sstevel@tonic-gate 
2534845Svikram typedef struct ct_time {
2544845Svikram 	long	ctm_total;	/* Total time allowed for event */
2554845Svikram 	clock_t	ctm_start;	/* starting lbolt for event */
2564845Svikram } ct_time_t;
2574845Svikram 
2580Sstevel@tonic-gate /*
2590Sstevel@tonic-gate  * Contract
2600Sstevel@tonic-gate  */
2610Sstevel@tonic-gate typedef struct contract {
2620Sstevel@tonic-gate 	uint64_t	ct_ref;		/* reference count */
2630Sstevel@tonic-gate 	kmutex_t	ct_reflock;	/* reference count lock */
2640Sstevel@tonic-gate 	kmutex_t	ct_evtlock;	/* event dispatch lock */
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate 					/* Static data */
2670Sstevel@tonic-gate 	kproject_t	*ct_proj;	/* project of creator */
2680Sstevel@tonic-gate 	uid_t		ct_cuid;	/* uid of contract author */
2690Sstevel@tonic-gate 	zoneid_t	ct_zoneid;	/* zoneid of creator */
2700Sstevel@tonic-gate 	uint64_t	ct_czuniqid;	/* unique id of creator's zone */
2710Sstevel@tonic-gate 	timespec_t	ct_ctime;	/* creation time */
2720Sstevel@tonic-gate 	ct_type_t	*ct_type;	/* contract type information */
2730Sstevel@tonic-gate 	void		*ct_data;	/* contract type data */
2740Sstevel@tonic-gate 	ctid_t		ct_id;		/* contract ID */
2750Sstevel@tonic-gate 	uint64_t	ct_cookie;	/* term: contract cookie */
2760Sstevel@tonic-gate 	uint_t		ct_ev_crit;	/* term: critical events */
2770Sstevel@tonic-gate 	uint_t		ct_ev_info;	/* term: informative events */
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate 					/* Protected by other locks */
2800Sstevel@tonic-gate 	uint64_t	ct_mzuniqid;	/* unique id of members' zone */
2810Sstevel@tonic-gate 	avl_node_t	ct_ctavl;	/* avl membership */
2820Sstevel@tonic-gate 	avl_node_t	ct_cttavl;	/* type avl membership */
2830Sstevel@tonic-gate 	avl_node_t	ct_ctlist;	/* position in holder's list */
2840Sstevel@tonic-gate 
2850Sstevel@tonic-gate 	kmutex_t	ct_lock;	/* lock for everything below */
2860Sstevel@tonic-gate 	ctstate_t	ct_state;	/* contract's state */
2870Sstevel@tonic-gate 	list_t		ct_vnodes;	/* vnodes list */
2880Sstevel@tonic-gate 	ctflags_t	ct_flags;	/* contract flags */
2890Sstevel@tonic-gate 	ct_equeue_t	ct_events;	/* contract event queue */
2900Sstevel@tonic-gate 	struct proc	*ct_owner;	/* contract owner (if owned) */
2910Sstevel@tonic-gate 	struct contract	*ct_regent;	/* [prospective] regent contract */
2920Sstevel@tonic-gate 	int		ct_evcnt;	/* number of critical events */
2930Sstevel@tonic-gate 	ct_kevent_t	*ct_nevent;	/* negotiation event */
2944845Svikram 	ct_time_t	ct_ntime;	/* negotiation time tracker */
2954845Svikram 	ct_time_t	ct_qtime;	/* quantum time tracker */
2960Sstevel@tonic-gate } contract_t;
2970Sstevel@tonic-gate 
2980Sstevel@tonic-gate #define	CTLF_COPYOUT	0x1		/* performing copyout */
2990Sstevel@tonic-gate #define	CTLF_RESET	0x2		/* event pointer reset or moved */
3000Sstevel@tonic-gate #define	CTLF_DEAD	0x4		/* dead listener */
3010Sstevel@tonic-gate #define	CTLF_RELIABLE	0x8		/* reliable listener */
3020Sstevel@tonic-gate #define	CTLF_CRITICAL	0x10		/* waiting for critical event */
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate typedef struct ct_listener {
3050Sstevel@tonic-gate 	list_node_t	ctl_allnode;	/* entry in list of all listeners */
3060Sstevel@tonic-gate 	list_node_t	ctl_tailnode;	/* entry in list of tail listeners */
3070Sstevel@tonic-gate 	ct_equeue_t	*ctl_equeue;	/* queue */
3080Sstevel@tonic-gate 	ct_kevent_t	*ctl_position;	/* position in queue */
3090Sstevel@tonic-gate 	int		ctl_flags;	/* state flags */
3100Sstevel@tonic-gate 	kcondvar_t	ctl_cv;		/* for waiting for an event */
3110Sstevel@tonic-gate 	pollhead_t	ctl_pollhead;	/* so we can poll(2) */
3120Sstevel@tonic-gate } ct_listener_t;
3130Sstevel@tonic-gate 
3140Sstevel@tonic-gate /*
3150Sstevel@tonic-gate  * Contract template interfaces
3160Sstevel@tonic-gate  */
3170Sstevel@tonic-gate void ctmpl_free(ct_template_t *);
318*7937SAntonello.Cruz@Sun.COM int ctmpl_set(ct_template_t *, ct_kparam_t *, const cred_t *);
319*7937SAntonello.Cruz@Sun.COM int ctmpl_get(ct_template_t *, ct_kparam_t *);
3200Sstevel@tonic-gate ct_template_t *ctmpl_dup(ct_template_t *);
3210Sstevel@tonic-gate void ctmpl_activate(ct_template_t *);
3220Sstevel@tonic-gate void ctmpl_clear(ct_template_t *);
3234845Svikram int ctmpl_create(ct_template_t *, ctid_t *);
3240Sstevel@tonic-gate 
3250Sstevel@tonic-gate /*
326*7937SAntonello.Cruz@Sun.COM  * Contract parameter functions
327*7937SAntonello.Cruz@Sun.COM  */
328*7937SAntonello.Cruz@Sun.COM int ctparam_copyin(const void *, ct_kparam_t *, int, int);
329*7937SAntonello.Cruz@Sun.COM int ctparam_copyout(ct_kparam_t *, void *, int);
330*7937SAntonello.Cruz@Sun.COM 
331*7937SAntonello.Cruz@Sun.COM /*
3320Sstevel@tonic-gate  * Contract functions
3330Sstevel@tonic-gate  */
3340Sstevel@tonic-gate void contract_init(void);
3350Sstevel@tonic-gate int contract_abandon(contract_t *, struct proc *, int);
3360Sstevel@tonic-gate int contract_adopt(contract_t *, struct proc *);
3370Sstevel@tonic-gate void contract_destroy(contract_t *);
3380Sstevel@tonic-gate void contract_exit(struct proc *);
3394845Svikram int contract_ack(contract_t *ct, uint64_t evid, int cmd);
3404845Svikram int contract_qack(contract_t *ct, uint64_t evid);
3414845Svikram int contract_newct(contract_t *ct);
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate /*
3440Sstevel@tonic-gate  * Event interfaces
3450Sstevel@tonic-gate  */
3464845Svikram uint64_t cte_publish_all(contract_t *, ct_kevent_t *, nvlist_t *, nvlist_t *);
3470Sstevel@tonic-gate void cte_add_listener(ct_equeue_t *, ct_listener_t *);
3480Sstevel@tonic-gate void cte_remove_listener(ct_listener_t *);
3490Sstevel@tonic-gate void cte_reset_listener(ct_listener_t *);
3500Sstevel@tonic-gate int cte_get_event(ct_listener_t *, int, void *, const cred_t *, uint64_t, int);
3510Sstevel@tonic-gate int cte_next_event(ct_listener_t *, uint64_t);
3520Sstevel@tonic-gate int cte_set_reliable(ct_listener_t *, const cred_t *);
3530Sstevel@tonic-gate 
3540Sstevel@tonic-gate /*
3550Sstevel@tonic-gate  * Contract implementation interfaces
3560Sstevel@tonic-gate  */
3570Sstevel@tonic-gate int contract_compar(const void *, const void *);
3580Sstevel@tonic-gate void ctmpl_init(ct_template_t *, ctmplops_t *, ct_type_t *, void *);
3590Sstevel@tonic-gate void ctmpl_copy(ct_template_t *, ct_template_t *);
3604845Svikram int ctmpl_create_inval(ct_template_t *, ctid_t *);
3610Sstevel@tonic-gate int contract_ctor(contract_t *, ct_type_t *, ct_template_t *, void *, ctflags_t,
3620Sstevel@tonic-gate     struct proc *, int);
3630Sstevel@tonic-gate void contract_hold(contract_t *);
3640Sstevel@tonic-gate void contract_rele(contract_t *);
3650Sstevel@tonic-gate uint64_t contract_getzuniqid(contract_t *);
3660Sstevel@tonic-gate void contract_setzuniqid(contract_t *, uint64_t);
3670Sstevel@tonic-gate void contract_rele_unlocked(contract_t *);
3680Sstevel@tonic-gate void contract_status_common(contract_t *, zone_t *, void *, model_t);
3690Sstevel@tonic-gate void contract_orphan(contract_t *);
3700Sstevel@tonic-gate ctid_t contract_lookup(uint64_t, ctid_t);
3710Sstevel@tonic-gate ctid_t contract_plookup(struct proc *, ctid_t, uint64_t);
3720Sstevel@tonic-gate contract_t *contract_ptr(id_t, uint64_t);
3730Sstevel@tonic-gate ctid_t contract_max(void);
3740Sstevel@tonic-gate int contract_owned(contract_t *, const cred_t *, int);
3750Sstevel@tonic-gate 
3760Sstevel@tonic-gate /*
3770Sstevel@tonic-gate  * Type interfaces
3780Sstevel@tonic-gate  */
3790Sstevel@tonic-gate extern int ct_ntypes;
3800Sstevel@tonic-gate extern ct_type_t **ct_types;
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate ct_type_t *contract_type_init(ct_typeid_t, const char *, contops_t *,
3830Sstevel@tonic-gate     ct_f_default_t *);
3840Sstevel@tonic-gate int contract_type_count(ct_type_t *);
3850Sstevel@tonic-gate ctid_t contract_type_max(ct_type_t *);
3860Sstevel@tonic-gate ctid_t contract_type_lookup(ct_type_t *, uint64_t, ctid_t);
3870Sstevel@tonic-gate contract_t *contract_type_ptr(ct_type_t *, ctid_t, uint64_t);
3880Sstevel@tonic-gate void contract_type_time(ct_type_t *, timestruc_t *);
3890Sstevel@tonic-gate ct_equeue_t *contract_type_bundle(ct_type_t *);
3900Sstevel@tonic-gate ct_equeue_t *contract_type_pbundle(ct_type_t *, struct proc *);
3910Sstevel@tonic-gate 
3920Sstevel@tonic-gate /*
3930Sstevel@tonic-gate  * FS interfaces
3940Sstevel@tonic-gate  */
3950Sstevel@tonic-gate vnode_t *contract_vnode_get(contract_t *, vfs_t *);
3960Sstevel@tonic-gate void contract_vnode_set(contract_t *, contract_vnode_t *, vnode_t *);
3970Sstevel@tonic-gate int contract_vnode_clear(contract_t *, contract_vnode_t *);
3980Sstevel@tonic-gate 
3994845Svikram /*
4004845Svikram  * Negotiation stubs
4014845Svikram  */
4024845Svikram int contract_ack_inval(contract_t *, uint_t, uint64_t);
4034845Svikram int contract_qack_inval(contract_t *, uint_t, uint64_t);
4044845Svikram int contract_qack_notsup(contract_t *, uint_t, uint64_t);
4054845Svikram 
4060Sstevel@tonic-gate #ifdef	__cplusplus
4070Sstevel@tonic-gate }
4080Sstevel@tonic-gate #endif
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate #endif	/* _SYS_CONTRACT_IMPL_H */
411