1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
|
'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
.\" 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.
.\" 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.
.\" 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]
.TH CONTRACT 5 "Nov 26, 2017"
.SH NAME
contract \- the contract file system
.SH SYNOPSIS
.LP
.nf
\fB/system/contract\fR
.fi
.SH DESCRIPTION
.LP
The \fB/system/contract\fR file system acts as the primary interface to the
contract subsystem. There is a subdirectory of \fB/system/contract\fR for each
available contract type.
.sp
.LP
\fB/system/contract\fR can be mounted on any mount point, in addition to the
standard \fB/system/contract\fR mount point, and can be mounted several places
at once. Such additional mounts are allowed in order to facilitate the
confinement of processes to subtrees of the file system using \fBchroot\fR(8)
and yet allow such processes to continue to use contract commands and
interfaces.
.sp
.LP
A combination of standard system calls (for example, \fBopen\fR(2),
\fBclose\fR(2), and \fBpoll\fR(2)) and calls to \fBlibcontract\fR(3LIB) access
\fB/system/contract\fR files.
.sp
.LP
Consumers of the contract file system must be large file aware. See
\fBlargefile\fR(7) and \fBlfcompile64\fR(7).
.SS "DIRECTORY STRUCTURE"
.LP
At the top level, the \fB/system/contract\fR directory contains subdirectories
named with each available contract type, and one special directory, \fBall\fR.
Each of these directories is world-readable and world-searchable.
.SS "STRUCTURE OF \fB/system/contract/\fItype\fR\fR"
.LP
Each \fB/system/contract/\fItype\fR\fR directory contains a fixed number of
files. It also contains a variable number of subdirectories corresponding to
existing contracts of type \fItype\fR and named with the decimal representation
of the contracts' IDs.
.sp
.LP
The following files are in a \fB/system/contract/\fItype\fR\fR directory:
.sp
.ne 2
.na
\fB\fBtemplate\fR\fR
.ad
.RS 12n
Opening this file returns a file descriptor for a new \fItype\fR contract
template.
.sp
You can use the following \fBlibcontract\fR(3LIB) calls on a template file
descriptor:
.sp
.in +2
.nf
>
ct_tmpl_activate(3contract)
ct_tmpl_clear(3contract)
ct_tmpl_create(3contract)
.fi
.in -2
.sp
See TERMS for additional template functions.
.RE
.sp
.ne 2
.na
\fBlatest\fR
.ad
.RS 12n
Opening this file returns a file descriptor for the status file of the last
\fItype\fR contract written by the opening LWP. See \fBSTRUCTURE OF
/system/contract/\fItype\fR/\fIid\fR\fR. If the opening LWP has not created a
\fItype\fR contract, opening latest fails with \fBESRCH\fR.
.RE
.sp
.ne 2
.na
\fBbundle\fR
.ad
.RS 12n
Opening this file returns a file descriptor for an event endpoint which
receives events from all \fItype\fR contracts on the system. No privileges are
required to open a type bundle event endpoint. Events sent by contracts owned
and written by users other than the reader's effective user id are invisible,
that is, they are silently skipped, unless the reader has
\fB{PRIV_CONTRACT_OBSERVER}\fR in its effective set. See \fBEVENTS\fR.
.RE
.sp
.ne 2
.na
\fBpbundle\fR
.ad
.RS 12n
Opening this file returns a file descriptor for an event endpoint which
receives events from all \fItype\fR contracts held by the opening process. See
\fBEVENTS\fR.
.RE
.SS "STRUCTURE OF /system/contract/all"
.LP
The \fB/system/contract/all\fR directory contains a numerically named file for
each contract in the system. Each file is a symbolic link to the type-specific
directory for that contract, that is \fB/system/contract/all/\fIid\fR\fR points
to \fB/system/contract/\fItype\fR/\fIid\fR\fR.
.SS "STRUCTURE OF /system/contract/\fItype\fR/\fIid\fR"
.LP
Each \fB/system/contract/\fItype\fR/\fIid\fR\fR directory contains the
following files:
.sp
.ne 2
.na
\fBctl\fR
.ad
.RS 10n
Opening this file returns a file descriptor for contract \fIid\fR's control
file. The open fails if the opening process does not hold contract \fIid\fR and
the contract has not been inherited by the process contract of which the
opening process is a member. See \fBprocess\fR(5).
.sp
The following \fBlibcontract\fR(3LIB) calls can be made on a \fBctl\fR file
descriptor if the contract is owned by the caller:
.sp
.in +2
.nf
ct_ctl_abandon(3contract)
ct_ctl_newct(3contract)
ct_ctl_ack(3contract)
ct_ctl_qack(3contract)
.fi
.in -2
.sp
The following \fBlibcontract\fR(3LIB) call can be made on a ctl file descriptor
if the contract doesn't have an owner:
.sp
.in +2
.nf
ct_ctl_adopt(3contract)
.fi
.in -2
.sp
.RE
.sp
.ne 2
.na
\fBstatus\fR
.ad
.RS 10n
Opening this file returns a file descriptor for contract \fIid\fR's status
file. The following \fBlibcontract\fR(3LIB) calls can be made on a status file
descriptor:
.LP
.nf
ct_status_read(3contract)
.fi
See STATUS.
.RE
.sp
.ne 2
.na
\fBevents\fR
.ad
.RS 10n
Opening this file returns a file descriptor for an event endpoint which
receives events from contract \fIid\fR. See \fBEVENTS\fR.
.sp
Only a process which has the same effective user ID as the process owning the
contract, the same effective user ID as the contract's author, or has
\fB{PRIV_CONTRACT_OBSERVER}\fR in its effective set can open the event endpoint
for a contract.
.RE
.SS "TERMS"
.LP
The following terms are defined for all contracts:
.sp
.ne 2
.na
\fBcookie\fR
.ad
.RS 25n
Specifies a 64-bit quantity that the contract author can use to identify the
contract. Use \fBct_tmpl_set_cookie\fR(3CONTRACT) to set this term.
.RE
.sp
.ne 2
.na
\fBinformative event set\fR
.ad
.RS 25n
Selects which events are delivered as informative events. Use
\fBct_tmpl_set_informative\fR(3CONTRACT) to set this term.
.RE
.sp
.ne 2
.na
\fBcritical event set\fR
.ad
.RS 25n
Selects which events are delivered as critical events. Use
\fBct_tmpl_set_critical\fR(3CONTRACT) to set this term.
.RE
.SS "STATUS"
.LP
A status object returned by \fBct_status_read\fR(3CONTRACT) contains the
following pieces of information:
.sp
.ne 2
.na
\fBcontract ID\fR
.ad
.sp .6
.RS 4n
The numeric ID of the contract. Use \fBct_status_get_id\fR(3CONTRACT) to obtain
this information.
.RE
.sp
.ne 2
.na
\fBcontract type\fR
.ad
.sp .6
.RS 4n
The type of the contract, specified as a string. Obtained using
\fBct_status_get_type\fR(3CONTRACT). The contract type is the same as its
subdirectory name under \fB/system/contract\fR.
.RE
.sp
.ne 2
.na
\fBcreator's zone ID\fR
.ad
.sp .6
.RS 4n
The zone ID of the process which created the contract. Obtained using
\fBct_status_get_zoneid\fR(3CONTRACT).
.RE
.sp
.ne 2
.na
\fBownership state\fR
.ad
.sp .6
.RS 4n
The state of the contract, specified as \fBCTS_OWNED\fR, \fBCTS_INHERITED\fR,
\fBCTS_ORPHAN\fR, or \fBCTS_DEAD\fR. Use \fBct_status_get_state\fR(3CONTRACT)
to obtain this information.
.RE
.sp
.ne 2
.na
\fBcontract holder\fR
.ad
.sp .6
.RS 4n
If the contract's state is \fBCTS_OWNED\fR, the ID of the process which owns
the contract. If the contract's state is \fBCTS_INHERITED\fR, the ID of the
contract which is acting as regent. If the contract's state is \fBCTS_ORPHAN\fR
or \fBCTS_DEAD\fR, this is undefined. Use \fBct_status_get_holder\fR(3CONTRACT)
to obtain this information.
.RE
.sp
.ne 2
.na
\fBnumber of critical events\fR
.ad
.sp .6
.RS 4n
The number of unacknowledged critical events pending on the contract's event
queue. Use \fBct_status_get_nevents\fR(3CONTRACT) to obtain this information.
.RE
.sp
.ne 2
.na
\fBnegotiation time\fR
.ad
.sp .6
.RS 4n
The time remaining before the current synchronous negotiation times out. Use
\fBct_status_get_ntime\fR(3CONTRACT) to obtain this information.
.RE
.sp
.ne 2
.na
\fBnegotiation quantum time\fR
.ad
.sp .6
.RS 4n
The time remaining before the current negotiation quantum runs out. Use
\fBct_status_get_qtime\fR(3CONTRACT) to obtain this information.
.RE
.sp
.ne 2
.na
\fBnegotiation event ID\fR
.ad
.sp .6
.RS 4n
The ID of the event which initiated the negotiation timeout. Use
\fBct_status_get_nevid\fR(3CONTRACT) to obtain this information.
.RE
.sp
.ne 2
.na
\fBcookie (term)\fR
.ad
.sp .6
.RS 4n
The contract's cookie term. Use \fBct_status_get_cookie\fR(3CONTRACT) to obtain
this information.
.RE
.sp
.ne 2
.na
\fBInformative event set (term)\fR
.ad
.sp .6
.RS 4n
The contract's informative event set. Use
\fBct_status_get_informative\fR(3CONTRACT) to obtain this information.
.RE
.sp
.ne 2
.na
\fBCritical event set (term)\fR
.ad
.sp .6
.RS 4n
The contract's critical event set. Use \fBct_status_get_critical\fR(3CONTRACT)
to obtain this information.
.RE
.SS "EVENTS"
.LP
All three event endpoints, \fB/system/contract/\fItype\fR/bundle\fR,
\fB/system/contract/\fItype\fR/pbundle\fR, and
\fB/system/contract/\fItype\fR/\fIid\fR/events\fR, are accessed in the same
manner.
.sp
.LP
The following \fBlibcontract\fR(3LIB) interfaces are used with an event
endpoint file descriptor:
.sp
.in +2
.nf
ct_event_read(3contract)
ct_event_read_critical(3contract)
ct_event_reset(3contract)
.fi
.in -2
.sp
.sp
.LP
To facilitate processes watching multiple event endpoints, it is possible to
poll(2) on event endpoints. When it is possible to receive on an endpoint file
descriptor, POLLIN is set for that descriptor.
.sp
.LP
An event object returned by \fBct_event_read\fR(3CONTRACT) contains the
following information:
.sp
.ne 2
.na
\fBcontract ID\fR
.ad
.RS 28n
The ID of the contract that generated the event. Use
\fBct_event_read\fR(3CONTRACT) to obtain this information.
.RE
.sp
.ne 2
.na
\fBevent ID\fR
.ad
.RS 28n
The ID of the contract event.Use \fBct_event_get_evid\fR(3CONTRACT).
.RE
.sp
.ne 2
.na
\fBflags\fR
.ad
.RS 28n
A bit vector possibly including \fBCT_ACK\fR and \fBCTE_INFO\fR. Use
\fBct_event_get_flags\fR(3CONTRACT) to obtain this information.
.RE
.sp
.ne 2
.na
\fBevent type\fR
.ad
.RS 28n
The type of event, equal to one of the constants specified in the contract
type's manual page or \fBCT_EV_NEGEND\fR. Use
\fBct_event_get_type\fR(3CONTRACT) to obtain this information.
.RE
.SS "EVENT TYPES"
.LP
The following event types are defined:
.sp
.ne 2
.na
\fB\fBCT_EV_NEGEND\fR\fR
.ad
.RS 16n
Some time after an exit negotiation is initiated, the \fBCT_EV_NEGEND\fR event
is sent. This indicates that the negotiation ended. This might be because the
operation was cancelled, or because the operation was successful. If
successful, and the owner requested that a new contract be written, this
contains the ID of that contract.
.sp
\fBCT_EV_NEGEND\fR cannot be included in a contract's informative or critical
event set. It is always delivered and always critical. If \fBCT_EV_NEGEND\fR
indicates that the operation was successful, no further events are sent. The
contract's owner should use \fBct_ctl_abandon\fR(3CONTRACT) to abandon the
contract.
.sp
A \fBCT_EV_NEGEND\fR event contains:
.sp
.ne 2
.na
\fBnegotiation ID\fR
.ad
.RS 19n
The ID of the negotiation which ended. Use \fBct_event_get_nevid\fR(3CONTRACT)
to obain this information.
.RE
.sp
.ne 2
.na
\fBnew contract ID\fR
.ad
.RS 19n
The ID of the newly created contract. This value is 0 if no contract was
created, or the ID of the existing contract if the operation was not completed.
Use \fBct_event_get_newct\fR(3CONTRACT) to obtain this information.
.RE
.RE
.SH FILES
.ne 2
.na
\fB\fB/system/contract\fR\fR
.ad
.sp .6
.RS 4n
List of all contract types
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/all\fR\fR
.ad
.sp .6
.RS 4n
Directory of all contract IDs
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/all/\fIid\fR\fR\fR
.ad
.sp .6
.RS 4n
Symbolic link to the type-specific directory of contract \fIid\fR
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/\fItype\fR\fR\fR
.ad
.sp .6
.RS 4n
Specific type directory
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/\fItype\fR/template\fR\fR
.ad
.sp .6
.RS 4n
Template for the contract type
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/\fItype\fR/bundle\fR\fR
.ad
.sp .6
.RS 4n
Listening point for all contracts of that type
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/\fItype\fR/pbundle\fR\fR
.ad
.sp .6
.RS 4n
Listening point for all contracts of that type for the opening process
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/\fItype\fR /latest\fR\fR
.ad
.sp .6
.RS 4n
Status of most recent \fItype\fR contract created by the opening LWP
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/\fItype\fR/\fIID\fR\fR\fR
.ad
.sp .6
.RS 4n
Directory for contract id
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/\fItype\fR/\fIID\fR/events\fR\fR
.ad
.sp .6
.RS 4n
Listening point for contract id's events
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/\fItype\fR/\fIID\fR/ctl\fR\fR
.ad
.sp .6
.RS 4n
Control file for contract ID
.RE
.sp
.ne 2
.na
\fB\fB/system/contract/\fItype\fR/\fIID\fR/status\fR\fR
.ad
.sp .6
.RS 4n
Status info for contract ID
.RE
.SH SEE ALSO
.LP
.BR ctrun (1),
.BR ctstat (1),
.BR ctwatch (1),
.BR close (2),
.BR ioctl (2),
.BR open (2),
.BR poll (2),
.BR ct_ctl_abandon (3CONTRACT),
.BR ct_event_get_evid (3CONTRACT),
.BR ct_event_get_flags (3CONTRACT),
.BR ct_event_get_nevid (3CONTRACT),
.BR ct_event_get_newct (3CONTRACT),
.BR ct_event_get_type (3CONTRACT),
.BR ct_event_read (3CONTRACT),
.BR ct_status_get_cookie (3CONTRACT),
.BR ct_status_get_critical (3CONTRACT),
.BR ct_status_get_holder (3CONTRACT),
.BR ct_status_get_id (3CONTRACT),
.BR ct_status_get_informative (3CONTRACT),
.BR ct_status_get_nevents (3CONTRACT),
.BR ct_status_get_nevid (3CONTRACT),
.BR ct_status_get_ntime (3CONTRACT),
.BR ct_status_get_qtime (3CONTRACT),
.BR ct_status_get_state (3CONTRACT),
.BR ct_status_get_type (3CONTRACT),
.BR ct_status_read (3CONTRACT),
.BR ct_tmpl_set_cookie (3CONTRACT),
.BR ct_tmpl_set_critical (3CONTRACT),
.BR ct_tmpl_set_informative (3CONTRACT),
.BR libcontract (3LIB),
.BR process (5),
.BR largefile (7),
.BR lfcompile (7),
.BR privileges (7),
.BR chroot (8)
|