2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" 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.
5 .\" 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]
6 .TH CT_PR_TMPL_SET_TRANSFER 3CONTRACT "Feb 25, 2008"
8 ct_pr_tmpl_set_transfer, ct_pr_tmpl_set_fatal, ct_pr_tmpl_set_param,
9 ct_pr_tmpl_set_svc_fmri, ct_pr_tmpl_set_svc_aux, ct_pr_tmpl_get_transfer,
10 ct_pr_tmpl_get_fatal, ct_pr_tmpl_get_param, ct_pr_tmpl_get_svc_fmri,
11 ct_pr_tmpl_get_svc_aux \- process contract template functions
15 cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB -lcontract \fR [ \fIlibrary\fR\&.\|.\|. ]
16 #include <libcontract.h>
17 #include <sys/contract/process.h>
19 \fBint\fR \fBct_pr_tmpl_set_transfer\fR(\fBint\fR \fIfd\fR, \fBctid_t\fR \fIctid\fR);
24 \fBint\fR \fBct_pr_tmpl_set_fatal\fR(\fBint\fR \fIfd\fR, \fBuint_t\fR \fIevents\fR);
29 \fBint\fR \fBct_pr_tmpl_set_param\fR(\fBint\fR \fIfd\fR, \fBuint_t\fR \fIparams\fR);
34 \fBint\fR \fBct_pr_tmpl_set_svc_fmri\fR(\fBint\fR \fIfd\fR, \fBconst char *\fR\fIfmri\fR);
39 \fBint\fR \fBct_pr_tmpl_set_svc_aux\fR(\fBint\fR \fIfd\fR, \fBconst char *\fR\fIaux\fR);
44 \fBint\fR \fBct_pr_tmpl_get_transfer\fR(\fBint\fR \fIfd\fR, \fBctid_t *\fR\fIctidp\fR);
49 \fBint\fR \fBct_pr_tmpl_get_fatal\fR(\fBint\fR \fIfd\fR, \fBuint_t *\fR\fIeventsp\fR);
54 \fBint\fR \fBct_pr_tmpl_get_param\fR(\fBint\fR \fIfd\fR, \fBuint_t *\fR\fIparamsp\fR);
59 \fBint\fR \fBct_pr_tmpl_get_svc_fmri\fR(\fBint\fR \fIfd\fR, \fBchar *\fR\fIfmri\fR, \fBsize_t\fR \fIsize\fR);
64 \fBint\fR \fBct_pr_tmpl_get_svc_aux\fR(\fBint\fR \fIfd\fR, \fBchar *\fR\fIaux\fR, \fBsize_t\fR \fIsize\fR);
70 These functions read and write process contract terms and operate on process
71 contract template file descriptors obtained from the \fBcontract\fR(4) file
75 The \fBct_pr_tmpl_set_transfer()\fR and \fBct_pr_tmpl_get_transfer()\fR
76 functions write and read the transfer contract term. The value is the ID of an
77 empty regent process contract owned by the caller whose inherited contracts are
78 to be transferred to a newly created contract.
81 The \fBct_pr_tmpl_set_fatal()\fR and \fBct_pr_tmpl_get_fatal()\fR functions
82 write and read the fatal event set term. The value is a collection of bits as
83 described in \fBprocess\fR(4).
86 The \fBct_pr_tmpl_set_param()\fR and \fBct_pr_tmpl_get_param()\fR functions
87 write and read the parameter set term. The value is a collection of bits as
88 described in \fBprocess\fR(4).
91 The \fBct_pr_tmpl_set_svc_fmri()\fR and \fBct_pr_tmpl_get_svc_fmri()\fR
92 functions write and read the service FMRI value of a process contract template.
93 The \fBct_pr_tmpl_set_svc_fmri()\fR function requires the caller to have the
94 {\fBPRIV_CONTRACT_IDENTITY\fR} privilege in its effective set.
97 The \fBct_pr_tmpl_set_svc_aux()\fR and \fBct_pr_tmpl_get_svc_aux()\fR functions
98 write and read the creator's auxiliary value of a process contract template.
102 Upon successful completion, \fBct_pr_tmpl_set_transfer()\fR,
103 \fBct_pr_tmpl_set_fatal()\fR, \fBct_pr_tmpl_set_param()\fR,
104 \fBct_pr_tmpl_set_svc_fmri()\fR, \fBct_pr_tmpl_set_svc_aux()\fR,
105 \fBct_pr_tmpl_get_transfer()\fR, \fBct_pr_tmpl_get_fatal()\fR, and
106 \fBct_pr_tmpl_get_param()\fR return 0. Otherwise, they return a non-zero error
110 Upon successful completion, \fBct_pr_tmpl_get_svc_fmri()\fR and
111 \fBct_pr_tmpl_get_svc_aux()\fR return the size required to store the value,
112 which is the same value return by \fBstrcpy\fR(3C) + 1. Insufficient buffer
113 size can be checked by:
117 if (ct_pr_tmpl_get_svc_fmri(fd, fmri, size) > size)
118 /* buffer is too small */
124 Otherwise, \fBct_pr_tmpl_get_svc_fmri()\fR and \fBct_pr_tmpl_get_svc_aux()\fR
125 return -1 and set \fBerrno\fR to indicate the error.
129 The \fBct_pr_tmpl_set_param()\fR, \fBct_pr_tmpl_set_svc_fmri()\fR,
130 \fBct_pr_tmpl_set_svc_aux()\fR, \fBct_pr_tmpl_get_svc_fmri()\fR and
131 \fBct_pr_tmpl_get_svc_aux()\fR functions will fail if:
138 An invalid parameter was specified.
143 The \fBct_pr_tmpl_set_fatal()\fR function will fail if:
150 An invalid event was specified.
155 The \fBct_pr_tmpl_set_transfer()\fR function will fail if:
162 The ID specified by \fIctid\fR does not correspond to a process contract.
171 The ID specified by \fIctid\fR does not correspond to a process contract owned
172 by the calling process.
178 \fB\fBENOTEMPTY\fR\fR
181 The ID specified by \fIctid\fR does not correspond to an empty process
187 The \fBct_pr_tmpl_set_svc_fmri()\fR function will fail if:
194 The calling process does not have {\fBPRIV_CONTRACT_IDENTITY\fR} in its
200 \fBExample 1 \fRCreate and activate a process contract template.
203 The following example opens a new template, makes hardware errors and signals
204 fatal events, makes hardware errors critical events, and activates the
205 template. It then forks a process in the new contract using the requested
211 #include <libcontract.h>
218 fd = open("/system/contract/process/template", O_RDWR);
219 (void) ct_pr_tmpl_set_fatal(fd, CT_PR_EV_HWERR|CT_PR_EV_SIGNAL);
220 (void) ct_tmpl_set_critical(fd, CT_PR_EV_HWERR);
221 (void) ct_tmpl_activate(fd);
225 /* parent - owns new process contract */
228 /* child - in new process contract */
236 \fBExample 2 \fRClear the process contract template.
239 The following example opens the template file and requests that the active
245 #include <libcontract.h>
251 fd = open("/system/contract/process/template", O_RDWR);
252 (void) ct_tmpl_clear(fd);
261 See \fBattributes\fR(5) for descriptions of the following attributes:
269 ATTRIBUTE TYPE ATTRIBUTE VALUE
271 Interface Stability Committed
279 \fBlibcontract\fR(3LIB), \fBstrcpy\fR(3C), \fBcontract\fR(4), \fBprocess\fR(4),