2 .\" Copyright (c) 2004, 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 CONTRACT 4 "Nov 26, 2017"
8 contract \- the contract file system
12 \fB/system/contract\fR
17 The \fB/system/contract\fR file system acts as the primary interface to the
18 contract subsystem. There is a subdirectory of \fB/system/contract\fR for each
19 available contract type.
22 \fB/system/contract\fR can be mounted on any mount point, in addition to the
23 standard \fB/system/contract\fR mount point, and can be mounted several places
24 at once. Such additional mounts are allowed in order to facilitate the
25 confinement of processes to subtrees of the file system using \fBchroot\fR(8)
26 and yet allow such processes to continue to use contract commands and
30 A combination of standard system calls (for example, \fBopen\fR(2),
31 \fBclose\fR(2), and \fBpoll\fR(2)) and calls to \fBlibcontract\fR(3LIB) access
32 \fB/system/contract\fR files.
33 .SS "DIRECTORY STRUCTURE"
35 At the top level, the \fB/system/contract\fR directory contains subdirectories
36 named with each available contract type, and one special directory, \fBall\fR.
37 Each of these directories is world-readable and world-searchable.
38 .SS "STRUCTURE OF \fB/system/contract/\fItype\fR\fR"
40 Each \fB/system/contract/\fItype\fR\fR directory contains a fixed number of
41 files. It also contains a variable number of subdirectories corresponding to
42 existing contracts of type \fItype\fR and named with the decimal representation
43 of the contracts' IDs.
46 The following files are in a \fB/system/contract/\fItype\fR\fR directory:
53 Opening this file returns a file descriptor for a new \fItype\fR contract
56 You can use the following \fBlibcontract\fR(3LIB) calls on a template file
63 ct_tmpl_activate(3contract)
64 ct_tmpl_clear(3contract)
65 ct_tmpl_create(3contract)
70 See TERMS for additional template functions.
79 Opening this file returns a file descriptor for the status file of the last
80 \fItype\fR contract written by the opening LWP. See \fBSTRUCTURE OF
81 /system/contract/\fItype\fR/\fIid\fR\fR. If the opening LWP has not created a
82 \fItype\fR contract, opening latest fails with \fBESRCH\fR.
91 Opening this file returns a file descriptor for an event endpoint which
92 receives events from all \fItype\fR contracts on the system. No privileges are
93 required to open a type bundle event endpoint. Events sent by contracts owned
94 and written by users other than the reader's effective user id are invisible,
95 that is, they are silently skipped, unless the reader has
96 \fB{PRIV_CONTRACT_OBSERVER}\fR in its effective set. See \fBEVENTS\fR.
105 Opening this file returns a file descriptor for an event endpoint which
106 receives events from all \fItype\fR contracts held by the opening process. See
110 .SS "STRUCTURE OF /system/contract/all"
112 The \fB/system/contract/all\fR directory contains a numerically named file for
113 each contract in the system. Each file is a symbolic link to the type-specific
114 directory for that contract, that is \fB/system/contract/all/\fIid\fR\fR points
115 to \fB/system/contract/\fItype\fR/\fIid\fR\fR.
116 .SS "STRUCTURE OF /system/contract/\fItype\fR/\fIid\fR"
118 Each \fB/system/contract/\fItype\fR/\fIid\fR\fR directory contains the
126 Opening this file returns a file descriptor for contract \fIid\fR's control
127 file. The open fails if the opening process does not hold contract \fIid\fR and
128 the contract has not been inherited by the process contract of which the
129 opening process is a member. See \fBprocess\fR(4).
131 The following \fBlibcontract\fR(3LIB) calls can be made on a \fBctl\fR file
132 descriptor if the contract is owned by the caller:
136 ct_ctl_abandon(3contract)
137 ct_ctl_newct(3contract)
138 ct_ctl_ack(3contract)
139 ct_ctl_qack(3contract)
144 The following \fBlibcontract\fR(3LIB) call can be made on a ctl file descriptor
145 if the contract doesn't have an owner:
149 ct_ctl_adopt(3contract)
162 Opening this file returns a file descriptor for contract \fIid\fR's status
163 file. The following \fBlibcontract\fR(3LIB) calls can be made on a status file
167 ct_status_read(3contract)
179 Opening this file returns a file descriptor for an event endpoint which
180 receives events from contract \fIid\fR. See \fBEVENTS\fR.
182 Only a process which has the same effective user ID as the process owning the
183 contract, the same effective user ID as the contract's author, or has
184 \fB{PRIV_CONTRACT_OBSERVER}\fR in its effective set can open the event endpoint
190 The following terms are defined for all contracts:
197 Specifies a 64-bit quantity that the contract author can use to identify the
198 contract. Use \fBct_tmpl_set_cookie\fR(3CONTRACT) to set this term.
204 \fBinformative event set\fR
207 Selects which events are delivered as informative events. Use
208 \fBct_tmpl_set_informative\fR(3CONTRACT) to set this term.
214 \fBcritical event set\fR
217 Selects which events are delivered as critical events. Use
218 \fBct_tmpl_set_critical\fR(3CONTRACT) to set this term.
223 A status object returned by \fBct_status_read\fR(3CONTRACT) contains the
224 following pieces of information:
232 The numeric ID of the contract. Use \fBct_status_get_id\fR(3CONTRACT) to obtain
243 The type of the contract, specified as a string. Obtained using
244 \fBct_status_get_type\fR(3CONTRACT). The contract type is the same as its
245 subdirectory name under \fB/system/contract\fR.
251 \fBcreator's zone ID\fR
255 The zone ID of the process which created the contract. Obtained using
256 \fBct_status_get_zoneid\fR(3CONTRACT).
262 \fBownership state\fR
266 The state of the contract, specified as \fBCTS_OWNED\fR, \fBCTS_INHERITED\fR,
267 \fBCTS_ORPHAN\fR, or \fBCTS_DEAD\fR. Use \fBct_status_get_state\fR(3CONTRACT)
268 to obtain this information.
274 \fBcontract holder\fR
278 If the contract's state is \fBCTS_OWNED\fR, the ID of the process which owns
279 the contract. If the contract's state is \fBCTS_INHERITED\fR, the ID of the
280 contract which is acting as regent. If the contract's state is \fBCTS_ORPHAN\fR
281 or \fBCTS_DEAD\fR, this is undefined. Use \fBct_status_get_holder\fR(3CONTRACT)
282 to obtain this information.
288 \fBnumber of critical events\fR
292 The number of unacknowledged critical events pending on the contract's event
293 queue. Use \fBct_status_get_nevents\fR(3CONTRACT) to obtain this information.
299 \fBnegotiation time\fR
303 The time remaining before the current synchronous negotiation times out. Use
304 \fBct_status_get_ntime\fR(3CONTRACT) to obtain this information.
310 \fBnegotiation quantum time\fR
314 The time remaining before the current negotiation quantum runs out. Use
315 \fBct_status_get_qtime\fR(3CONTRACT) to obtain this information.
321 \fBnegotiation event ID\fR
325 The ID of the event which initiated the negotiation timeout. Use
326 \fBct_status_get_nevid\fR(3CONTRACT) to obtain this information.
336 The contract's cookie term. Use \fBct_status_get_cookie\fR(3CONTRACT) to obtain
343 \fBInformative event set (term)\fR
347 The contract's informative event set. Use
348 \fBct_status_get_informative\fR(3CONTRACT) to obtain this information.
354 \fBCritical event set (term)\fR
358 The contract's critical event set. Use \fBct_status_get_critical\fR(3CONTRACT)
359 to obtain this information.
364 All three event endpoints, \fB/system/contract/\fItype\fR/bundle\fR,
365 \fB/system/contract/\fItype\fR/pbundle\fR, and
366 \fB/system/contract/\fItype\fR/\fIid\fR/events\fR, are accessed in the same
370 The following \fBlibcontract\fR(3LIB) interfaces are used with an event
371 endpoint file descriptor:
375 ct_event_read(3contract)
376 ct_event_read_critical(3contract)
377 ct_event_reset(3contract)
384 To facilitate processes watching multiple event endpoints, it is possible to
385 poll(2) on event endpoints. When it is possible to receive on an endpoint file
386 descriptor, POLLIN is set for that descriptor.
389 An event object returned by \fBct_event_read\fR(3CONTRACT) contains the
390 following information:
397 The ID of the contract that generated the event. Use
398 \fBct_event_read\fR(3CONTRACT) to obtain this information.
407 The ID of the contract event.Use \fBct_event_get_evid\fR(3CONTRACT).
416 A bit vector possibly including \fBCT_ACK\fR and \fBCTE_INFO\fR. Use
417 \fBct_event_get_flags\fR(3CONTRACT) to obtain this information.
426 The type of event, equal to one of the constants specified in the contract
427 type's manual page or \fBCT_EV_NEGEND\fR. Use
428 \fBct_event_get_type\fR(3CONTRACT) to obtain this information.
433 The following event types are defined:
437 \fB\fBCT_EV_NEGEND\fR\fR
440 Some time after an exit negotiation is initiated, the \fBCT_EV_NEGEND\fR event
441 is sent. This indicates that the negotiation ended. This might be because the
442 operation was cancelled, or because the operation was successful. If
443 successful, and the owner requested that a new contract be written, this
444 contains the ID of that contract.
446 \fBCT_EV_NEGEND\fR cannot be included in a contract's informative or critical
447 event set. It is always delivered and always critical. If \fBCT_EV_NEGEND\fR
448 indicates that the operation was successful, no further events are sent. The
449 contract's owner should use \fBct_ctl_abandon\fR(3CONTRACT) to abandon the
452 A \fBCT_EV_NEGEND\fR event contains:
459 The ID of the negotiation which ended. Use \fBct_event_get_nevid\fR(3CONTRACT)
460 to obain this information.
466 \fBnew contract ID\fR
469 The ID of the newly created contract. This value is 0 if no contract was
470 created, or the ID of the existing contract if the operation was not completed.
471 Use \fBct_event_get_newct\fR(3CONTRACT) to obtain this information.
479 \fB\fB/system/contract\fR\fR
483 List of all contract types
489 \fB\fB/system/contract/all\fR\fR
493 Directory of all contract IDs
499 \fB\fB/system/contract/all/\fIid\fR\fR\fR
503 Symbolic link to the type-specific directory of contract \fIid\fR
509 \fB\fB/system/contract/\fItype\fR\fR\fR
513 Specific type directory
519 \fB\fB/system/contract/\fItype\fR/template\fR\fR
523 Template for the contract type
529 \fB\fB/system/contract/\fItype\fR/bundle\fR\fR
533 Listening point for all contracts of that type
539 \fB\fB/system/contract/\fItype\fR/pbundle\fR\fR
543 Listening point for all contracts of that type for the opening process
549 \fB\fB/system/contract/\fItype\fR /latest\fR\fR
553 Status of most recent \fItype\fR contract created by the opening LWP
559 \fB\fB/system/contract/\fItype\fR/\fIID\fR\fR\fR
563 Directory for contract id
569 \fB\fB/system/contract/\fItype\fR/\fIID\fR/events\fR\fR
573 Listening point for contract id's events
579 \fB\fB/system/contract/\fItype\fR/\fIID\fR/ctl\fR\fR
583 Control file for contract ID
589 \fB\fB/system/contract/\fItype\fR/\fIID\fR/status\fR\fR
593 Status info for contract ID
598 \fBctrun\fR(1), \fBctstat\fR(1), \fBctwatch\fR(1), \fBchroot\fR(8),
599 \fBclose\fR(2), \fBioctl\fR(2), \fBopen\fR(2), \fBpoll\fR(2),
600 \fBct_ctl_abandon\fR(3CONTRACT), \fBct_event_read\fR(3CONTRACT),
601 \fBct_event_get_evid\fR(3CONTRACT), \fBct_event_get_flags\fR(3CONTRACT),
602 \fBct_event_get_nevid\fR(3CONTRACT), \fBct_event_get_newct\fR(3CONTRACT),
603 \fBct_event_get_type\fR(3CONTRACT),
604 \fBct_status_read\fR(3CONTRACT), \fBct_status_get_cookie\fR(3CONTRACT),
605 \fBct_status_get_critical\fR(3CONTRACT), \fBct_status_get_holder\fR(3CONTRACT),
606 \fBct_status_get_id\fR(3CONTRACT), \fBct_status_get_informative\fR(3CONTRACT),
607 \fBct_status_get_nevid\fR(3CONTRACT), \fBct_status_get_nevents\fR(3CONTRACT),
608 \fBct_status_get_ntime\fR(3CONTRACT), \fBct_status_get_qtime\fR(3CONTRACT),
609 \fBct_status_get_state\fR(3CONTRACT), \fBct_status_get_type\fR(3CONTRACT),
610 \fBct_tmpl_set_cookie\fR(3CONTRACT), \fBct_tmpl_set_critical\fR(3CONTRACT),
611 \fBct_tmpl_set_informative\fR(3CONTRACT), \fBlibcontract\fR(3LIB),
612 \fBprocess\fR(4), \fBprivileges\fR(5)