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
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
|
'\" te
.\" Copyright (c) 2007, 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 SCF_TRANSACTION_CREATE 3SCF "Aug 28, 2007"
.SH NAME
scf_transaction_create, scf_transaction_handle, scf_transaction_reset,
scf_transaction_reset_all, scf_transaction_destroy,
scf_transaction_destroy_children, scf_transaction_start,
scf_transaction_property_delete, scf_transaction_property_new,
scf_transaction_property_change, scf_transaction_property_change_type,
scf_transaction_commit \- create and manipulate transaction in the Service
Configuration Facility
.SH SYNOPSIS
.LP
.nf
cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lscf\fR [ \fIlibrary\fR\&.\|.\|. ]
#include <libscf.h>
\fBscf_transaction_t *\fR\fBscf_transaction_create\fR(\fBscf_handle_t *\fR\fIhandle\fR);
.fi
.LP
.nf
\fBscf_handle_t *\fR\fBscf_transaction_handle\fR(\fBscf_transaction_t *\fR\fItran\fR);
.fi
.LP
.nf
\fBvoid\fR \fBscf_transaction_reset\fR(\fBscf_transaction_t *\fR\fItran\fR);
.fi
.LP
.nf
\fBvoid\fR \fBscf_transaction_reset_all\fR(\fBscf_transaction_t *\fR\fItran\fR);
.fi
.LP
.nf
\fBvoid\fR \fBscf_transaction_destroy\fR(\fBscf_transaction_t *\fR\fItran\fR);
.fi
.LP
.nf
\fBvoid\fR \fBscf_transaction_destroy_children\fR(\fBscf_transaction_t *\fR\fItran\fR);
.fi
.LP
.nf
\fBint\fR \fBscf_transaction_start\fR(\fBscf_transaction_t *\fR\fItran\fR,
\fBscf_propertygroup_t *\fR\fIpg\fR);
.fi
.LP
.nf
\fBint\fR \fBscf_transaction_property_delete\fR(\fBscf_transaction_t *\fR\fItran\fR,
\fBscf_transaction_entry_t *\fR\fIentry\fR, \fBconst char *\fR\fIprop_name\fR);
.fi
.LP
.nf
\fBint\fR \fBscf_transaction_property_new\fR(\fBscf_transaction_t *\fR\fItran\fR,
\fBscf_transaction_entry_t *\fR\fIentry\fR, \fBconst char *\fR\fIprop_name\fR,
\fBscf_type_t\fR \fItype\fR);
.fi
.LP
.nf
\fBint\fR \fBscf_transaction_property_change\fR(\fBscf_transaction_t *\fR\fItran\fR,
\fBscf_transaction_entry_t *\fR\fIentry\fR, \fBconst char *\fR\fIprop_name\fR,
\fBscf_type_t\fR \fItype\fR);
.fi
.LP
.nf
\fBint\fR \fBscf_transaction_property_change_type\fR(
\fBscf_transaction_t *\fR\fItran\fR, \fBscf_transaction_entry_t *\fR\fIentry\fR,
\fBconst char *\fR\fIprop_name\fR, \fBscf_type_t\fR \fItype\fR);
.fi
.LP
.nf
\fBint\fR \fBscf_transaction_commit\fR(\fBscf_transaction_t *\fR\fItran\fR);
.fi
.SH DESCRIPTION
.sp
.LP
Transactions are the mechanism for changing property groups. They act
atomically, whereby either all of the updates occur or none of them do. An
\fBscf_transaction_t\fR is always in one of the following states:
.sp
.ne 2
.na
\fBreset\fR
.ad
.RS 13n
The initial state. A successful return of \fBscf_transaction_start()\fR moves
the transaction to the started state.
.RE
.sp
.ne 2
.na
\fBstarted\fR
.ad
.RS 13n
The transaction has started. The \fBscf_transaction_property_delete()\fR,
\fBscf_transaction_property_new()\fR, \fBscf_transaction_property_change()\fR,
and \fBscf_transaction_property_change_type()\fR functions can be used to set
up changes to properties. The \fBscf_transaction_reset()\fR and
\fBscf_transaction_reset_all()\fR functions return the transaction to the reset
state.
.RE
.sp
.ne 2
.na
\fBcommitted\fR
.ad
.RS 13n
A call to \fBscf_transaction_commit()\fR (whether or not it is successful)
moves the transaction to the committed state. Modifying, resetting, or
destroying the entries and values associated with a transaction will move it to
the invalid state.
.RE
.sp
.ne 2
.na
\fBinvalid\fR
.ad
.RS 13n
The \fBscf_transaction_reset()\fR and \fBscf_transaction_reset_all()\fR
functions return the transaction to the reset state.
.RE
.sp
.LP
The \fBscf_transaction_create()\fR function allocates and initializes an
\fBscf_transaction_t\fR bound to \fIhandle\fR. The
\fBscf_transaction_destroy()\fR function resets, destroys, and frees
\fItran\fR. If there are any entries associated with the transaction,
\fBscf_transaction_destroy()\fR also effects a call to
\fBscf_transaction_reset()\fR. The \fBscf_transaction_destroy_children()\fR
function resets, destroys, and frees all entries and values associated the
transaction.
.sp
.LP
The \fBscf_transaction_handle()\fR function gets the handle to which \fItran\fR
is bound.
.sp
.LP
The \fBscf_transaction_start()\fR function sets up the transaction to modify
the property group to which \fIpg\fR is set. The time reference used by
\fIpg\fR becomes the basis of the transaction. The transaction fails if the
property group has been modified since the last update of \fIpg\fR at the time
when \fBscf_transaction_commit()\fR is called.
.sp
.LP
The \fBscf_transaction_property_delete()\fR,
\fBscf_transaction_property_new()\fR, \fBscf_transaction_property_change()\fR,
and \fBscf_transaction_property_change_type()\fR functions add a new
transaction entry to the transaction. Each property the transaction affects
must have a unique \fBscf_transaction_entry_t\fR. Each
\fBscf_transaction_entry_t\fR can be associated with only a single transaction
at a time. These functions all fail if the transaction is not in the started
state, \fIprop_name\fR is not a valid property name, or \fIentry\fR is already
associated with a transaction. These functions affect commit and failure as
follows:
.sp
.ne 2
.na
\fB\fBscf_transaction_property_delete()\fR\fR
.ad
.sp .6
.RS 4n
This function deletes the property \fIprop_name\fR in the property group. It
fails if \fIprop_name\fR does not name a property in the property group.
.RE
.sp
.ne 2
.na
\fB\fBscf_transaction_property_new()\fR\fR
.ad
.sp .6
.RS 4n
This function adds a new property prop_name\fI\fR to the property group with a
value list of type \fItype\fR. It fails if \fIprop_name\fR names an existing
property in the property group.
.RE
.sp
.ne 2
.na
\fB\fBscf_transaction_property_change()\fR\fR
.ad
.sp .6
.RS 4n
This function changes the value list for an existing property \fIprop_name\fR
in the property group. It fails if \fIprop_name\fR does not name an existing
property in the property group or names an existing property with a different
type.
.RE
.sp
.ne 2
.na
\fB\fBscf_transaction_property_change_type()\fR\fR
.ad
.sp .6
.RS 4n
This function changes the value list and type for an existing property
\fIprop_name\fR in the property group. It fails if \fIprop_name\fR does not
name an existing property in the property group.
.RE
.sp
.LP
If the function call is successful, \fIentry\fR remains active in the
transaction until \fBscf_transaction_destroy()\fR,
\fBscf_transaction_reset()\fR, or \fBscf_transaction_reset_all()\fR is called.
The \fBscf_entry_add_value\fR(3SCF) manual page provides information for
setting up the value list for entries that are not associated with
\fBscf_transaction_property_delete()\fR. Resetting or destroying an entry or
value active in a transaction will move it into the invalid state.
.sp
.LP
The \fBscf_transaction_commit()\fR function attempts to commit \fItran\fR.
.sp
.LP
The \fBscf_transaction_reset()\fR function returns the transaction to the reset
state and releases all of the transaction entries that were added.
.sp
.LP
The \fBscf_transaction_reset_all()\fR function returns the transaction to the
reset state, releases all of the transaction entries, and calls
\fBscf_value_reset\fR(3SCF) on all values associated with the entries.
.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fBscf_transaction_create()\fR returns a new
\fBscf_transaction_t\fR. Otherwise, it returns \fINULL\fR.
.sp
.LP
Upon successful completion, \fBscf_transaction_handle()\fR returns the handle
associated with the transaction. Otherwise, it returns \fINULL\fR.
.sp
.LP
Upon successful completion, \fBscf_transaction_start()\fR,
\fBscf_transaction_property_delete()\fR, \fBscf_transaction_property_new()\fR,
\fBscf_transaction_property_change()\fR, and
\fBscf_transaction_property_change_type()\fR return 0. Otherwise, they return
\(mi1.
.sp
.LP
The \fBscf_transaction_commit()\fR function returns 1 upon successful commit, 0
if the property group set in \fBscf_transaction_start()\fR is not the most
recent, and -1 on failure.
.SH ERRORS
.sp
.LP
The \fBscf_transaction_create()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
.ad
.RS 30n
The value of the \fIhandle\fR argument is \fINULL\fR.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NO_MEMORY\fR\fR
.ad
.RS 30n
There is not enough memory to allocate an \fBscf_transaction_t\fR.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NO_RESOURCES\fR\fR
.ad
.RS 30n
The server does not have adequate resources for a new transaction handle.
.RE
.sp
.LP
The \fBscf_transaction_handle()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_HANDLE_DESTROYED\fR\fR
.ad
.RS 30n
The handle associated with \fItran\fR has been destroyed.
.RE
.sp
.LP
The \fBscf_transaction_start()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_BACKEND_ACCESS\fR\fR
.ad
.sp .6
.RS 4n
The repository backend refused the modification.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_BACKEND_READONLY\fR\fR
.ad
.sp .6
.RS 4n
The repository backend refused modification because it is read-only.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_CONNECTION_BROKEN\fR\fR
.ad
.sp .6
.RS 4n
The connection to the repository was lost.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_DELETED\fR\fR
.ad
.sp .6
.RS 4n
The property group has been deleted.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_HANDLE_MISMATCH\fR\fR
.ad
.sp .6
.RS 4n
The transaction and property group are not derived from the same handle.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_IN_USE\fR\fR
.ad
.sp .6
.RS 4n
The transaction is not in the \fBreset\fR state. The
\fBscf_transaction_reset()\fR and \fBscf_transaction_reset_all()\fR functions
can be used to return the transaction to the \fBreset\fR state.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NO_RESOURCES\fR\fR
.ad
.sp .6
.RS 4n
The server does not have the resources to complete the request.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_BOUND\fR\fR
.ad
.sp .6
.RS 4n
The handle was never bound or has been unbound.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_SET\fR\fR
.ad
.sp .6
.RS 4n
The property group specified by \fIpg\fR is not set.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_PERMISSION_DENIED\fR\fR
.ad
.sp .6
.RS 4n
The user does not have sufficient privileges to modify the property group.
.RE
.sp
.LP
The \fBscf_transaction_property_delete()\fR,
\fBscf_transaction_property_new()\fR, \fBscf_transaction_property_change()\fR,
and \fBscf_transaction_property_change_type()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_BACKEND_ACCESS\fR\fR
.ad
.sp .6
.RS 4n
The storage mechanism that the repository server (\fBsvc.configd\fR(1M))
chose for the operation denied access.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_CONNECTION_BROKEN\fR\fR
.ad
.sp .6
.RS 4n
The connection to the repository was lost.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_DELETED\fR\fR
.ad
.sp .6
.RS 4n
The property group the transaction is changing has been deleted.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_HANDLE_MISMATCH\fR\fR
.ad
.sp .6
.RS 4n
The transaction and entry are not derived from the same handle.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_IN_USE\fR\fR
.ad
.sp .6
.RS 4n
The property already has an entry in the transaction.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_INTERNAL\fR\fR
.ad
.sp .6
.RS 4n
An internal error occurred.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
.ad
.sp .6
.RS 4n
The \fIprop_name\fR argument is not a valid property name.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NO_RESOURCES\fR\fR
.ad
.sp .6
.RS 4n
The server does not have the resources to complete the request.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_BOUND\fR\fR
.ad
.sp .6
.RS 4n
The handle is not bound.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_SET\fR\fR
.ad
.sp .6
.RS 4n
The transaction has not been started.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_TYPE_MISMATCH\fR\fR
.ad
.sp .6
.RS 4n
The \fItran\fR argument is not of a type compatible with \fItype\fR.
.RE
.sp
.LP
The \fBscf_transaction_property_delete()\fR,
\fBscf_transaction_property_change()\fR, and
\fBscf_transaction_property_change_type()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_EXISTS\fR\fR
.ad
.RS 23n
The object already exists.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_FOUND\fR\fR
.ad
.RS 23n
The property group does not contain a property named \fIprop_name\fR.
.RE
.sp
.LP
The \fBscf_transaction_property_new()\fR ,
\fBscf_transaction_property_change()\fR, and
\fBscf_transaction_property_change_type()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
.ad
.RS 30n
The \fIprop_name\fR argument is not not a valid property name, or the
\fItype\fR argument is an invalid type.
.RE
.sp
.LP
The \fBscf_transaction_property_new()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_EXISTS\fR\fR
.ad
.RS 23n
The property group already contains a property named \fIprop_name\fR.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_FOUND\fR\fR
.ad
.RS 23n
Nothing of that name was found.
.RE
.sp
.LP
The \fBscf_transaction_property_change()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_TYPE_MISMATCH\fR\fR
.ad
.RS 27n
The property \fIprop_name\fR is not of type \fItype\fR.
.RE
.sp
.LP
The \fBscf_transaction_commit()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_BACKEND_READONLY\fR\fR
.ad
.sp .6
.RS 4n
The repository backend is read-only.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_BACKEND_ACCESS\fR\fR
.ad
.sp .6
.RS 4n
The repository backend refused the modification.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_BOUND\fR\fR
.ad
.sp .6
.RS 4n
The handle is not bound.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_CONNECTION_BROKEN\fR\fR
.ad
.sp .6
.RS 4n
The connection to the repository was lost.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
.ad
.sp .6
.RS 4n
The transaction is in an invalid state.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_DELETED\fR\fR
.ad
.sp .6
.RS 4n
The property group the transaction is acting on has been deleted.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_SET\fR\fR
.ad
.sp .6
.RS 4n
The transaction has not been started.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_PERMISSION_DENIED\fR\fR
.ad
.sp .6
.RS 4n
The user does not have sufficient privileges to modify the property group.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NO_RESOURCES\fR\fR
.ad
.sp .6
.RS 4n
The server does not have sufficient resources to commit the transaction.
.RE
.sp
.LP
The \fBscf_error\fR(3SCF) function can be used to retrieve the error value.
.SH EXAMPLES
.LP
\fBExample 1 \fRSet an existing boolean value to true.
.sp
.in +2
.nf
tx = scf_transaction_create(handle);
e1 = scf_entry_create(handle);
v1 = scf_value_create(handle);
do {
if (scf_pg_update(pg) == -1)
goto fail;
if (scf_transaction_start(tx, pg) == -1)
goto fail;
/* set up transaction entries */
if (scf_transaction_property_change(tx, e1, "property",
SCF_TYPE_BOOLEAN) == -1) {
scf_transaction_reset(tx);
goto fail;
}
scf_value_set_boolean(v1, 1);
scf_entry_add_value(e1, v1);
result = scf_transaction_commit(tx);
scf_transaction_reset(tx);
} while (result == 0);
if (result < 0)
goto fail;
/* success */
cleanup:
scf_transaction_destroy(tx);
scf_entry_destroy(e1);
scf_value_destroy(v1);
.fi
.in -2
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Committed
_
MT-Level Safe
.TE
.SH SEE ALSO
.sp
.LP
\fBlibscf\fR(3LIB), \fBscf_value_reset\fR(3SCF), \fBscf_error\fR(3SCF),
\fBscf_pg_create\fR(3SCF), \fBattributes\fR(5)
|