xref: /onnv-gate/usr/src/uts/common/sys/contract_impl.h (revision 4845:357e8e7542af)
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
5*4845Svikram  * Common Development and Distribution License (the "License").
6*4845Svikram  * 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 /*
22*4845Svikram  * Copyright 2007 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/types.h>
320Sstevel@tonic-gate #include <sys/list.h>
330Sstevel@tonic-gate #include <sys/poll.h>
340Sstevel@tonic-gate #include <sys/condvar.h>
350Sstevel@tonic-gate #include <sys/contract.h>
360Sstevel@tonic-gate #include <sys/model.h>
370Sstevel@tonic-gate #include <sys/cred.h>
380Sstevel@tonic-gate #include <sys/mutex.h>
390Sstevel@tonic-gate #include <sys/list.h>
400Sstevel@tonic-gate #include <sys/avl.h>
410Sstevel@tonic-gate #include <sys/nvpair.h>
420Sstevel@tonic-gate #include <sys/time.h>
430Sstevel@tonic-gate #include <sys/vnode.h>
440Sstevel@tonic-gate #include <sys/vfs.h>
450Sstevel@tonic-gate #include <sys/zone.h>
460Sstevel@tonic-gate #include <sys/project.h>
470Sstevel@tonic-gate 
480Sstevel@tonic-gate #ifdef	__cplusplus
490Sstevel@tonic-gate extern "C" {
500Sstevel@tonic-gate #endif
510Sstevel@tonic-gate 
52*4845Svikram extern int ct_debug;
53*4845Svikram 
54*4845Svikram #define	CT_DEBUG(args)	if (ct_debug) cmn_err args
55*4845Svikram 
560Sstevel@tonic-gate #ifdef _SYSCALL32
570Sstevel@tonic-gate 
580Sstevel@tonic-gate /*
590Sstevel@tonic-gate  * 32-bit versions of the event and status structures, for use (only)
600Sstevel@tonic-gate  * by the 64-bit kernel.  See sys/contract.h for the normal versions.
610Sstevel@tonic-gate  * Use pack(4) to get offsets and structure size correct on amd64.
620Sstevel@tonic-gate  */
630Sstevel@tonic-gate 
640Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
650Sstevel@tonic-gate #pragma pack(4)
660Sstevel@tonic-gate #endif
670Sstevel@tonic-gate 
680Sstevel@tonic-gate typedef struct ct_event32 {
690Sstevel@tonic-gate 	ctid_t	ctev_id;
700Sstevel@tonic-gate 	uint32_t ctev_pad1;
710Sstevel@tonic-gate 	ctevid_t ctev_evid;
720Sstevel@tonic-gate 	ct_typeid_t ctev_cttype;
730Sstevel@tonic-gate 	uint32_t ctev_flags;
740Sstevel@tonic-gate 	uint32_t ctev_type;
750Sstevel@tonic-gate 	uint32_t ctev_nbytes;
760Sstevel@tonic-gate 	uint32_t ctev_goffset;
770Sstevel@tonic-gate 	uint32_t ctev_pad2;
780Sstevel@tonic-gate 	caddr32_t ctev_buffer;
790Sstevel@tonic-gate } ct_event32_t;
800Sstevel@tonic-gate 
810Sstevel@tonic-gate typedef struct ct_status32 {
820Sstevel@tonic-gate 	ctid_t	ctst_id;
830Sstevel@tonic-gate 	zoneid_t ctst_zoneid;
840Sstevel@tonic-gate 	ct_typeid_t ctst_type;
850Sstevel@tonic-gate 	pid_t	ctst_holder;
860Sstevel@tonic-gate 	ctstate_t ctst_state;
870Sstevel@tonic-gate 	int	ctst_nevents;
880Sstevel@tonic-gate 	int	ctst_ntime;
890Sstevel@tonic-gate 	int	ctst_qtime;
900Sstevel@tonic-gate 	uint64_t ctst_nevid;
910Sstevel@tonic-gate 	uint_t	ctst_detail;
920Sstevel@tonic-gate 	uint_t	ctst_nbytes;
930Sstevel@tonic-gate 	uint_t	ctst_critical;
940Sstevel@tonic-gate 	uint_t	ctst_informative;
950Sstevel@tonic-gate 	uint64_t ctst_cookie;
960Sstevel@tonic-gate 	caddr32_t ctst_buffer;
970Sstevel@tonic-gate } ct_status32_t;
980Sstevel@tonic-gate 
990Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1000Sstevel@tonic-gate #pragma pack()
1010Sstevel@tonic-gate #endif
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate #endif /* _SYSCALL32 */
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate struct proc;
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate /*
1080Sstevel@tonic-gate  * Contract template ops vector
1090Sstevel@tonic-gate  */
1100Sstevel@tonic-gate typedef struct ctmplops {
1110Sstevel@tonic-gate 	struct ct_template	*(*ctop_dup)(struct ct_template *);
1120Sstevel@tonic-gate 	void		(*ctop_free)(struct ct_template *);
1130Sstevel@tonic-gate 	int		(*ctop_set)(struct ct_template *, ct_param_t *,
1140Sstevel@tonic-gate 			const cred_t *);
1150Sstevel@tonic-gate 	int		(*ctop_get)(struct ct_template *, ct_param_t *);
116*4845Svikram 	int		(*ctop_create)(struct ct_template *, ctid_t *);
1170Sstevel@tonic-gate 	uint_t		allevents;
1180Sstevel@tonic-gate } ctmplops_t;
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate /*
1210Sstevel@tonic-gate  * Contract template
1220Sstevel@tonic-gate  */
1230Sstevel@tonic-gate typedef struct ct_template {
1240Sstevel@tonic-gate 	kmutex_t	ctmpl_lock;
1250Sstevel@tonic-gate 	ctmplops_t	*ctmpl_ops;
1260Sstevel@tonic-gate 	struct ct_type	*ctmpl_type;
1270Sstevel@tonic-gate 	void		*ctmpl_data;
1280Sstevel@tonic-gate 	uint64_t	ctmpl_cookie;	/* term: contract cookie */
1290Sstevel@tonic-gate 	uint_t		ctmpl_ev_crit;	/* term: critical events */
1300Sstevel@tonic-gate 	uint_t		ctmpl_ev_info;	/* term: informative events */
1310Sstevel@tonic-gate } ct_template_t;
1320Sstevel@tonic-gate 
133*4845Svikram 
1340Sstevel@tonic-gate typedef enum ct_listnum {
1350Sstevel@tonic-gate 	CTEL_CONTRACT,			/* ../contracts/type/<id>/events */
1360Sstevel@tonic-gate 	CTEL_BUNDLE,			/* ../contracts/type/bundle */
1370Sstevel@tonic-gate 	CTEL_PBUNDLE,			/* ../contracts/type/pbundle */
1380Sstevel@tonic-gate 	CTEL_MAX
1390Sstevel@tonic-gate } ct_listnum_t;
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate typedef enum ctqflags {
1420Sstevel@tonic-gate 	CTQ_DEAD = 1,	/* contract explicitly cancelled */
1430Sstevel@tonic-gate 	CTQ_REFFED = 2	/* queue is reference counted */
1440Sstevel@tonic-gate } ctqflags_t;
1450Sstevel@tonic-gate 
146*4845Svikram typedef enum ct_ack {
147*4845Svikram 	CT_ACK = 1,	/* accept break */
148*4845Svikram 	CT_NACK,	/* disallow break */
149*4845Svikram 	CT_NONE		/* no matching contracts */
150*4845Svikram } ct_ack_t;
151*4845Svikram 
1520Sstevel@tonic-gate /*
1530Sstevel@tonic-gate  * Contract event queue
1540Sstevel@tonic-gate  */
1550Sstevel@tonic-gate typedef struct ct_equeue {
1560Sstevel@tonic-gate 	kmutex_t ctq_lock;
1570Sstevel@tonic-gate 	timespec_t ctq_atime;		/* access time */
1580Sstevel@tonic-gate 	ct_listnum_t ctq_listno;	/* which list node */
1590Sstevel@tonic-gate 	list_t	ctq_events;		/* list of events */
1600Sstevel@tonic-gate 	list_t	ctq_listeners;		/* list of all listeners */
1610Sstevel@tonic-gate 	list_t	ctq_tail;		/* list of tail listeners */
1620Sstevel@tonic-gate 	int	ctq_nlisteners;		/* number of listeners */
1630Sstevel@tonic-gate 	int	ctq_nreliable;		/* number of reliable listeners */
1640Sstevel@tonic-gate 	int	ctq_ninf;		/* number of informative events */
1650Sstevel@tonic-gate 	int	ctq_max;		/* max informative events */
1660Sstevel@tonic-gate 	ctqflags_t ctq_flags;		/* queue flags */
1670Sstevel@tonic-gate } ct_equeue_t;
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate typedef struct ct_member {
1700Sstevel@tonic-gate 	list_node_t	ctm_node;	/* list membership */
1710Sstevel@tonic-gate 	int		ctm_refs;	/* number of references per list */
1720Sstevel@tonic-gate 	int		ctm_trimmed;	/* membership has been trimmed */
1730Sstevel@tonic-gate 	int		ctm_nreliable;	/* reliable listeners */
1740Sstevel@tonic-gate } ct_member_t;
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate typedef struct ct_kevent {
1770Sstevel@tonic-gate 	kmutex_t	cte_lock;
1780Sstevel@tonic-gate 	uint64_t	cte_id;		/* event id */
1790Sstevel@tonic-gate 	uint_t		cte_type;	/* event type */
1800Sstevel@tonic-gate 	int		cte_refs;
1810Sstevel@tonic-gate 	ct_member_t	cte_nodes[CTEL_MAX]; /* event queue membership */
1820Sstevel@tonic-gate 	int		cte_flags;	/* see above */
1830Sstevel@tonic-gate 	nvlist_t 	*cte_data;	/* event data */
1840Sstevel@tonic-gate 	nvlist_t 	*cte_gdata;	/* global-zone only data */
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate 	struct contract	*cte_contract;	/* contract */
1870Sstevel@tonic-gate } ct_kevent_t;
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate /*
1900Sstevel@tonic-gate  * Contract vnode linkage.
1910Sstevel@tonic-gate  * Avoid having too much knowledge about the FS.
1920Sstevel@tonic-gate  */
1930Sstevel@tonic-gate typedef struct contract_vnode {
1940Sstevel@tonic-gate 	list_node_t	ctv_node;
1950Sstevel@tonic-gate 	vnode_t		*ctv_vnode;
1960Sstevel@tonic-gate } contract_vnode_t;
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate /*
1990Sstevel@tonic-gate  * Contract ops vector
2000Sstevel@tonic-gate  *   free - when reference count drops to zero
2010Sstevel@tonic-gate  *   abandon - when holding process dies or relinquishes interest
2020Sstevel@tonic-gate  *   destroy - when contract is to be completely destroyed
2030Sstevel@tonic-gate  *   status - when contractfs needs to return detailed status information
2040Sstevel@tonic-gate  */
2050Sstevel@tonic-gate typedef struct contops {
2060Sstevel@tonic-gate 	void	(*contop_free)(struct contract *);
2070Sstevel@tonic-gate 	void	(*contop_abandon)(struct contract *);
2080Sstevel@tonic-gate 	void	(*contop_destroy)(struct contract *);
2090Sstevel@tonic-gate 	void	(*contop_status)(struct contract *, zone_t *, int, nvlist_t *,
2100Sstevel@tonic-gate 	    void *, model_t);
211*4845Svikram 	int	(*contop_ack)(struct contract *, uint_t evtype,
212*4845Svikram 	    uint64_t evid);
213*4845Svikram 	int	(*contop_nack)(struct contract *, uint_t evtype,
214*4845Svikram 	    uint64_t evid);
215*4845Svikram 	int	(*contop_qack)(struct contract *, uint_t, uint64_t);
216*4845Svikram 	int	(*contop_newct)(struct contract *);
2170Sstevel@tonic-gate } contops_t;
2180Sstevel@tonic-gate 
2190Sstevel@tonic-gate typedef ct_template_t *(ct_f_default_t)(void);
2200Sstevel@tonic-gate 
2210Sstevel@tonic-gate /*
2220Sstevel@tonic-gate  * Contract type information.
2230Sstevel@tonic-gate  */
2240Sstevel@tonic-gate typedef struct ct_type {
2250Sstevel@tonic-gate 	uint64_t	ct_type_evid;	/* last event id */
2260Sstevel@tonic-gate 	ct_typeid_t	ct_type_index;	/* index in ct_types array */
2270Sstevel@tonic-gate 	const char	*ct_type_name;	/* type as a string */
2280Sstevel@tonic-gate 	kmutex_t	ct_type_lock;	/* protects ct_type_avl */
2290Sstevel@tonic-gate 	avl_tree_t	ct_type_avl;	/* ordered list of type contracts */
2300Sstevel@tonic-gate 	timestruc_t	ct_type_timestruc; /* time last contract was written */
2310Sstevel@tonic-gate 	ct_equeue_t	ct_type_events;	/* bundle queue */
2320Sstevel@tonic-gate 	contops_t	*ct_type_ops;
2330Sstevel@tonic-gate 	ct_f_default_t	*ct_type_default; /* creates a fresh template */
2340Sstevel@tonic-gate } ct_type_t;
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate typedef enum ctflags {
2370Sstevel@tonic-gate 	CTF_INHERIT = 0x1
2380Sstevel@tonic-gate } ctflags_t;
2390Sstevel@tonic-gate 
240*4845Svikram typedef struct ct_time {
241*4845Svikram 	long	ctm_total;	/* Total time allowed for event */
242*4845Svikram 	clock_t	ctm_start;	/* starting lbolt for event */
243*4845Svikram } ct_time_t;
244*4845Svikram 
2450Sstevel@tonic-gate /*
2460Sstevel@tonic-gate  * Contract
2470Sstevel@tonic-gate  */
2480Sstevel@tonic-gate typedef struct contract {
2490Sstevel@tonic-gate 	uint64_t	ct_ref;		/* reference count */
2500Sstevel@tonic-gate 	kmutex_t	ct_reflock;	/* reference count lock */
2510Sstevel@tonic-gate 	kmutex_t	ct_evtlock;	/* event dispatch lock */
2520Sstevel@tonic-gate 
2530Sstevel@tonic-gate 					/* Static data */
2540Sstevel@tonic-gate 	kproject_t	*ct_proj;	/* project of creator */
2550Sstevel@tonic-gate 	uid_t		ct_cuid;	/* uid of contract author */
2560Sstevel@tonic-gate 	zoneid_t	ct_zoneid;	/* zoneid of creator */
2570Sstevel@tonic-gate 	uint64_t	ct_czuniqid;	/* unique id of creator's zone */
2580Sstevel@tonic-gate 	timespec_t	ct_ctime;	/* creation time */
2590Sstevel@tonic-gate 	ct_type_t	*ct_type;	/* contract type information */
2600Sstevel@tonic-gate 	void		*ct_data;	/* contract type data */
2610Sstevel@tonic-gate 	ctid_t		ct_id;		/* contract ID */
2620Sstevel@tonic-gate 	uint64_t	ct_cookie;	/* term: contract cookie */
2630Sstevel@tonic-gate 	uint_t		ct_ev_crit;	/* term: critical events */
2640Sstevel@tonic-gate 	uint_t		ct_ev_info;	/* term: informative events */
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate 					/* Protected by other locks */
2670Sstevel@tonic-gate 	uint64_t	ct_mzuniqid;	/* unique id of members' zone */
2680Sstevel@tonic-gate 	avl_node_t	ct_ctavl;	/* avl membership */
2690Sstevel@tonic-gate 	avl_node_t	ct_cttavl;	/* type avl membership */
2700Sstevel@tonic-gate 	avl_node_t	ct_ctlist;	/* position in holder's list */
2710Sstevel@tonic-gate 
2720Sstevel@tonic-gate 	kmutex_t	ct_lock;	/* lock for everything below */
2730Sstevel@tonic-gate 	ctstate_t	ct_state;	/* contract's state */
2740Sstevel@tonic-gate 	list_t		ct_vnodes;	/* vnodes list */
2750Sstevel@tonic-gate 	ctflags_t	ct_flags;	/* contract flags */
2760Sstevel@tonic-gate 	ct_equeue_t	ct_events;	/* contract event queue */
2770Sstevel@tonic-gate 	struct proc	*ct_owner;	/* contract owner (if owned) */
2780Sstevel@tonic-gate 	struct contract	*ct_regent;	/* [prospective] regent contract */
2790Sstevel@tonic-gate 	int		ct_evcnt;	/* number of critical events */
2800Sstevel@tonic-gate 	ct_kevent_t	*ct_nevent;	/* negotiation event */
281*4845Svikram 	ct_time_t	ct_ntime;	/* negotiation time tracker */
282*4845Svikram 	ct_time_t	ct_qtime;	/* quantum time tracker */
2830Sstevel@tonic-gate } contract_t;
2840Sstevel@tonic-gate 
2850Sstevel@tonic-gate #define	CTLF_COPYOUT	0x1		/* performing copyout */
2860Sstevel@tonic-gate #define	CTLF_RESET	0x2		/* event pointer reset or moved */
2870Sstevel@tonic-gate #define	CTLF_DEAD	0x4		/* dead listener */
2880Sstevel@tonic-gate #define	CTLF_RELIABLE	0x8		/* reliable listener */
2890Sstevel@tonic-gate #define	CTLF_CRITICAL	0x10		/* waiting for critical event */
2900Sstevel@tonic-gate 
2910Sstevel@tonic-gate typedef struct ct_listener {
2920Sstevel@tonic-gate 	list_node_t	ctl_allnode;	/* entry in list of all listeners */
2930Sstevel@tonic-gate 	list_node_t	ctl_tailnode;	/* entry in list of tail listeners */
2940Sstevel@tonic-gate 	ct_equeue_t	*ctl_equeue;	/* queue */
2950Sstevel@tonic-gate 	ct_kevent_t	*ctl_position;	/* position in queue */
2960Sstevel@tonic-gate 	int		ctl_flags;	/* state flags */
2970Sstevel@tonic-gate 	kcondvar_t	ctl_cv;		/* for waiting for an event */
2980Sstevel@tonic-gate 	pollhead_t	ctl_pollhead;	/* so we can poll(2) */
2990Sstevel@tonic-gate } ct_listener_t;
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate /*
3020Sstevel@tonic-gate  * Contract template interfaces
3030Sstevel@tonic-gate  */
3040Sstevel@tonic-gate void ctmpl_free(ct_template_t *);
3050Sstevel@tonic-gate int ctmpl_set(ct_template_t *, ct_param_t *, const cred_t *);
3060Sstevel@tonic-gate int ctmpl_get(ct_template_t *, ct_param_t *);
3070Sstevel@tonic-gate ct_template_t *ctmpl_dup(ct_template_t *);
3080Sstevel@tonic-gate void ctmpl_activate(ct_template_t *);
3090Sstevel@tonic-gate void ctmpl_clear(ct_template_t *);
310*4845Svikram int ctmpl_create(ct_template_t *, ctid_t *);
3110Sstevel@tonic-gate 
3120Sstevel@tonic-gate /*
3130Sstevel@tonic-gate  * Contract functions
3140Sstevel@tonic-gate  */
3150Sstevel@tonic-gate void contract_init(void);
3160Sstevel@tonic-gate int contract_abandon(contract_t *, struct proc *, int);
3170Sstevel@tonic-gate int contract_adopt(contract_t *, struct proc *);
3180Sstevel@tonic-gate void contract_destroy(contract_t *);
3190Sstevel@tonic-gate void contract_exit(struct proc *);
320*4845Svikram int contract_ack(contract_t *ct, uint64_t evid, int cmd);
321*4845Svikram int contract_qack(contract_t *ct, uint64_t evid);
322*4845Svikram int contract_newct(contract_t *ct);
3230Sstevel@tonic-gate 
3240Sstevel@tonic-gate /*
3250Sstevel@tonic-gate  * Event interfaces
3260Sstevel@tonic-gate  */
327*4845Svikram uint64_t cte_publish_all(contract_t *, ct_kevent_t *, nvlist_t *, nvlist_t *);
3280Sstevel@tonic-gate void cte_add_listener(ct_equeue_t *, ct_listener_t *);
3290Sstevel@tonic-gate void cte_remove_listener(ct_listener_t *);
3300Sstevel@tonic-gate void cte_reset_listener(ct_listener_t *);
3310Sstevel@tonic-gate int cte_get_event(ct_listener_t *, int, void *, const cred_t *, uint64_t, int);
3320Sstevel@tonic-gate int cte_next_event(ct_listener_t *, uint64_t);
3330Sstevel@tonic-gate int cte_set_reliable(ct_listener_t *, const cred_t *);
3340Sstevel@tonic-gate 
3350Sstevel@tonic-gate /*
3360Sstevel@tonic-gate  * Contract implementation interfaces
3370Sstevel@tonic-gate  */
3380Sstevel@tonic-gate int contract_compar(const void *, const void *);
3390Sstevel@tonic-gate void ctmpl_init(ct_template_t *, ctmplops_t *, ct_type_t *, void *);
3400Sstevel@tonic-gate void ctmpl_copy(ct_template_t *, ct_template_t *);
341*4845Svikram int ctmpl_create_inval(ct_template_t *, ctid_t *);
3420Sstevel@tonic-gate int contract_ctor(contract_t *, ct_type_t *, ct_template_t *, void *, ctflags_t,
3430Sstevel@tonic-gate     struct proc *, int);
3440Sstevel@tonic-gate void contract_hold(contract_t *);
3450Sstevel@tonic-gate void contract_rele(contract_t *);
3460Sstevel@tonic-gate uint64_t contract_getzuniqid(contract_t *);
3470Sstevel@tonic-gate void contract_setzuniqid(contract_t *, uint64_t);
3480Sstevel@tonic-gate void contract_rele_unlocked(contract_t *);
3490Sstevel@tonic-gate void contract_status_common(contract_t *, zone_t *, void *, model_t);
3500Sstevel@tonic-gate void contract_orphan(contract_t *);
3510Sstevel@tonic-gate ctid_t contract_lookup(uint64_t, ctid_t);
3520Sstevel@tonic-gate ctid_t contract_plookup(struct proc *, ctid_t, uint64_t);
3530Sstevel@tonic-gate contract_t *contract_ptr(id_t, uint64_t);
3540Sstevel@tonic-gate ctid_t contract_max(void);
3550Sstevel@tonic-gate int contract_owned(contract_t *, const cred_t *, int);
3560Sstevel@tonic-gate 
3570Sstevel@tonic-gate /*
3580Sstevel@tonic-gate  * Type interfaces
3590Sstevel@tonic-gate  */
3600Sstevel@tonic-gate extern int ct_ntypes;
3610Sstevel@tonic-gate extern ct_type_t **ct_types;
3620Sstevel@tonic-gate 
3630Sstevel@tonic-gate ct_type_t *contract_type_init(ct_typeid_t, const char *, contops_t *,
3640Sstevel@tonic-gate     ct_f_default_t *);
3650Sstevel@tonic-gate int contract_type_count(ct_type_t *);
3660Sstevel@tonic-gate ctid_t contract_type_max(ct_type_t *);
3670Sstevel@tonic-gate ctid_t contract_type_lookup(ct_type_t *, uint64_t, ctid_t);
3680Sstevel@tonic-gate contract_t *contract_type_ptr(ct_type_t *, ctid_t, uint64_t);
3690Sstevel@tonic-gate void contract_type_time(ct_type_t *, timestruc_t *);
3700Sstevel@tonic-gate ct_equeue_t *contract_type_bundle(ct_type_t *);
3710Sstevel@tonic-gate ct_equeue_t *contract_type_pbundle(ct_type_t *, struct proc *);
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate /*
3740Sstevel@tonic-gate  * FS interfaces
3750Sstevel@tonic-gate  */
3760Sstevel@tonic-gate vnode_t *contract_vnode_get(contract_t *, vfs_t *);
3770Sstevel@tonic-gate void contract_vnode_set(contract_t *, contract_vnode_t *, vnode_t *);
3780Sstevel@tonic-gate int contract_vnode_clear(contract_t *, contract_vnode_t *);
3790Sstevel@tonic-gate 
380*4845Svikram /*
381*4845Svikram  * Negotiation stubs
382*4845Svikram  */
383*4845Svikram int contract_ack_inval(contract_t *, uint_t, uint64_t);
384*4845Svikram int contract_qack_inval(contract_t *, uint_t, uint64_t);
385*4845Svikram int contract_qack_notsup(contract_t *, uint_t, uint64_t);
386*4845Svikram 
3870Sstevel@tonic-gate #ifdef	__cplusplus
3880Sstevel@tonic-gate }
3890Sstevel@tonic-gate #endif
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate #endif	/* _SYS_CONTRACT_IMPL_H */
392