17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57b209c2cSacruz  * Common Development and Distribution License (the "License").
67b209c2cSacruz  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
227b209c2cSacruz  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_CONTRACT_PROCESS_IMPL_H
277c478bd9Sstevel@tonic-gate #define	_SYS_CONTRACT_PROCESS_IMPL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/contract.h>
307c478bd9Sstevel@tonic-gate #include <sys/contract_impl.h>
317c478bd9Sstevel@tonic-gate #include <sys/contract/process.h>
327c478bd9Sstevel@tonic-gate #include <sys/time.h>
337b209c2cSacruz #include <sys/types.h>
347b209c2cSacruz #include <sys/refstr.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #define	PRCTID(pp) \
417c478bd9Sstevel@tonic-gate 	((pp)->p_ct_process ? (pp)->p_ct_process->conp_contract.ct_id : 0)
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate struct ctmpl_process {
447c478bd9Sstevel@tonic-gate 	ct_template_t	ctp_ctmpl;
457c478bd9Sstevel@tonic-gate 	contract_t	*ctp_subsume;
467c478bd9Sstevel@tonic-gate 	uint_t		ctp_params;
477c478bd9Sstevel@tonic-gate 	uint_t		ctp_ev_fatal;
487b209c2cSacruz 	refstr_t	*ctp_svc_fmri;	/* Service FMRI */
497b209c2cSacruz 	refstr_t	*ctp_svc_aux;	/* Creator Auxiliary field */
507c478bd9Sstevel@tonic-gate };
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate struct cont_process {
537c478bd9Sstevel@tonic-gate 	contract_t	conp_contract;	/* common contract data */
547c478bd9Sstevel@tonic-gate 	cred_t		*conp_cred;
557c478bd9Sstevel@tonic-gate 	list_t		conp_members;	/* member processes */
567c478bd9Sstevel@tonic-gate 	list_t		conp_inherited;	/* unclaimed child contracts */
577c478bd9Sstevel@tonic-gate 	uint_t		conp_params;	/* contract parameters */
587c478bd9Sstevel@tonic-gate 	uint_t		conp_ev_fatal;	/* events to kill on */
597c478bd9Sstevel@tonic-gate 	uint_t		conp_nmembers;
607c478bd9Sstevel@tonic-gate 	uint_t		conp_ninherited;
617b209c2cSacruz 	refstr_t	*conp_svc_fmri;		/* Service FMRI */
627b209c2cSacruz 	ctid_t		conp_svc_ctid;		/* Service FMRI creator ctid */
637b209c2cSacruz 	refstr_t	*conp_svc_creator;	/* contract creator */
647b209c2cSacruz 	refstr_t	*conp_svc_aux;		/* Creator Auxiliary field */
657b209c2cSacruz 	ctid_t		conp_svc_zone_enter;	/* zone_enter flag */
667b209c2cSacruz 						/* requires ct_lock for */
677b209c2cSacruz 						/* access */
687c478bd9Sstevel@tonic-gate };
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * Kernel APIs
727c478bd9Sstevel@tonic-gate  */
73*dea3b854SToomas Soome extern ctmpl_process_t *sys_process_tmpl;
74*dea3b854SToomas Soome extern ct_type_t *process_type;
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate struct proc;
777c478bd9Sstevel@tonic-gate void contract_process_init(void);
787c478bd9Sstevel@tonic-gate cont_process_t *contract_process_fork(ctmpl_process_t *, struct proc *,
797c478bd9Sstevel@tonic-gate     struct proc *, int);
807c478bd9Sstevel@tonic-gate void contract_process_exit(cont_process_t *, struct proc *, int);
817c478bd9Sstevel@tonic-gate void contract_process_core(cont_process_t *, struct proc *, int,
827c478bd9Sstevel@tonic-gate     const char *, const char *, const char *);
837c478bd9Sstevel@tonic-gate void contract_process_hwerr(cont_process_t *, struct proc *);
847c478bd9Sstevel@tonic-gate void contract_process_sig(cont_process_t *, struct proc *, int, pid_t, ctid_t,
857c478bd9Sstevel@tonic-gate     zoneid_t);
867c478bd9Sstevel@tonic-gate void contract_process_take(contract_t *, contract_t *);
877c478bd9Sstevel@tonic-gate int contract_process_accept(contract_t *);
887c478bd9Sstevel@tonic-gate void contract_process_adopt(contract_t *, proc_t *);
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
917c478bd9Sstevel@tonic-gate }
927c478bd9Sstevel@tonic-gate #endif
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #endif	/* _SYS_CONTRACT_PROCESS_IMPL_H */
95