2 .\" Copyright (c) 2007, 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 SCF_TRANSACTION_CREATE 3SCF "Aug 28, 2007"
8 scf_transaction_create, scf_transaction_handle, scf_transaction_reset,
9 scf_transaction_reset_all, scf_transaction_destroy,
10 scf_transaction_destroy_children, scf_transaction_start,
11 scf_transaction_property_delete, scf_transaction_property_new,
12 scf_transaction_property_change, scf_transaction_property_change_type,
13 scf_transaction_commit \- create and manipulate transaction in the Service
14 Configuration Facility
18 cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lscf\fR [ \fIlibrary\fR\&.\|.\|. ]
21 \fBscf_transaction_t *\fR\fBscf_transaction_create\fR(\fBscf_handle_t *\fR\fIhandle\fR);
26 \fBscf_handle_t *\fR\fBscf_transaction_handle\fR(\fBscf_transaction_t *\fR\fItran\fR);
31 \fBvoid\fR \fBscf_transaction_reset\fR(\fBscf_transaction_t *\fR\fItran\fR);
36 \fBvoid\fR \fBscf_transaction_reset_all\fR(\fBscf_transaction_t *\fR\fItran\fR);
41 \fBvoid\fR \fBscf_transaction_destroy\fR(\fBscf_transaction_t *\fR\fItran\fR);
46 \fBvoid\fR \fBscf_transaction_destroy_children\fR(\fBscf_transaction_t *\fR\fItran\fR);
51 \fBint\fR \fBscf_transaction_start\fR(\fBscf_transaction_t *\fR\fItran\fR,
52 \fBscf_propertygroup_t *\fR\fIpg\fR);
57 \fBint\fR \fBscf_transaction_property_delete\fR(\fBscf_transaction_t *\fR\fItran\fR,
58 \fBscf_transaction_entry_t *\fR\fIentry\fR, \fBconst char *\fR\fIprop_name\fR);
63 \fBint\fR \fBscf_transaction_property_new\fR(\fBscf_transaction_t *\fR\fItran\fR,
64 \fBscf_transaction_entry_t *\fR\fIentry\fR, \fBconst char *\fR\fIprop_name\fR,
65 \fBscf_type_t\fR \fItype\fR);
70 \fBint\fR \fBscf_transaction_property_change\fR(\fBscf_transaction_t *\fR\fItran\fR,
71 \fBscf_transaction_entry_t *\fR\fIentry\fR, \fBconst char *\fR\fIprop_name\fR,
72 \fBscf_type_t\fR \fItype\fR);
77 \fBint\fR \fBscf_transaction_property_change_type\fR(
78 \fBscf_transaction_t *\fR\fItran\fR, \fBscf_transaction_entry_t *\fR\fIentry\fR,
79 \fBconst char *\fR\fIprop_name\fR, \fBscf_type_t\fR \fItype\fR);
84 \fBint\fR \fBscf_transaction_commit\fR(\fBscf_transaction_t *\fR\fItran\fR);
90 Transactions are the mechanism for changing property groups. They act
91 atomically, whereby either all of the updates occur or none of them do. An
92 \fBscf_transaction_t\fR is always in one of the following states:
99 The initial state. A successful return of \fBscf_transaction_start()\fR moves
100 the transaction to the started state.
109 The transaction has started. The \fBscf_transaction_property_delete()\fR,
110 \fBscf_transaction_property_new()\fR, \fBscf_transaction_property_change()\fR,
111 and \fBscf_transaction_property_change_type()\fR functions can be used to set
112 up changes to properties. The \fBscf_transaction_reset()\fR and
113 \fBscf_transaction_reset_all()\fR functions return the transaction to the reset
123 A call to \fBscf_transaction_commit()\fR (whether or not it is successful)
124 moves the transaction to the committed state. Modifying, resetting, or
125 destroying the entries and values associated with a transaction will move it to
135 The \fBscf_transaction_reset()\fR and \fBscf_transaction_reset_all()\fR
136 functions return the transaction to the reset state.
141 The \fBscf_transaction_create()\fR function allocates and initializes an
142 \fBscf_transaction_t\fR bound to \fIhandle\fR. The
143 \fBscf_transaction_destroy()\fR function resets, destroys, and frees
144 \fItran\fR. If there are any entries associated with the transaction,
145 \fBscf_transaction_destroy()\fR also effects a call to
146 \fBscf_transaction_reset()\fR. The \fBscf_transaction_destroy_children()\fR
147 function resets, destroys, and frees all entries and values associated the
151 The \fBscf_transaction_handle()\fR function gets the handle to which \fItran\fR
155 The \fBscf_transaction_start()\fR function sets up the transaction to modify
156 the property group to which \fIpg\fR is set. The time reference used by
157 \fIpg\fR becomes the basis of the transaction. The transaction fails if the
158 property group has been modified since the last update of \fIpg\fR at the time
159 when \fBscf_transaction_commit()\fR is called.
162 The \fBscf_transaction_property_delete()\fR,
163 \fBscf_transaction_property_new()\fR, \fBscf_transaction_property_change()\fR,
164 and \fBscf_transaction_property_change_type()\fR functions add a new
165 transaction entry to the transaction. Each property the transaction affects
166 must have a unique \fBscf_transaction_entry_t\fR. Each
167 \fBscf_transaction_entry_t\fR can be associated with only a single transaction
168 at a time. These functions all fail if the transaction is not in the started
169 state, \fIprop_name\fR is not a valid property name, or \fIentry\fR is already
170 associated with a transaction. These functions affect commit and failure as
175 \fB\fBscf_transaction_property_delete()\fR\fR
179 This function deletes the property \fIprop_name\fR in the property group. It
180 fails if \fIprop_name\fR does not name a property in the property group.
186 \fB\fBscf_transaction_property_new()\fR\fR
190 This function adds a new property prop_name\fI\fR to the property group with a
191 value list of type \fItype\fR. It fails if \fIprop_name\fR names an existing
192 property in the property group.
198 \fB\fBscf_transaction_property_change()\fR\fR
202 This function changes the value list for an existing property \fIprop_name\fR
203 in the property group. It fails if \fIprop_name\fR does not name an existing
204 property in the property group or names an existing property with a different
211 \fB\fBscf_transaction_property_change_type()\fR\fR
215 This function changes the value list and type for an existing property
216 \fIprop_name\fR in the property group. It fails if \fIprop_name\fR does not
217 name an existing property in the property group.
222 If the function call is successful, \fIentry\fR remains active in the
223 transaction until \fBscf_transaction_destroy()\fR,
224 \fBscf_transaction_reset()\fR, or \fBscf_transaction_reset_all()\fR is called.
225 The \fBscf_entry_add_value\fR(3SCF) manual page provides information for
226 setting up the value list for entries that are not associated with
227 \fBscf_transaction_property_delete()\fR. Resetting or destroying an entry or
228 value active in a transaction will move it into the invalid state.
231 The \fBscf_transaction_commit()\fR function attempts to commit \fItran\fR.
234 The \fBscf_transaction_reset()\fR function returns the transaction to the reset
235 state and releases all of the transaction entries that were added.
238 The \fBscf_transaction_reset_all()\fR function returns the transaction to the
239 reset state, releases all of the transaction entries, and calls
240 \fBscf_value_reset\fR(3SCF) on all values associated with the entries.
244 Upon successful completion, \fBscf_transaction_create()\fR returns a new
245 \fBscf_transaction_t\fR. Otherwise, it returns \fINULL\fR.
248 Upon successful completion, \fBscf_transaction_handle()\fR returns the handle
249 associated with the transaction. Otherwise, it returns \fINULL\fR.
252 Upon successful completion, \fBscf_transaction_start()\fR,
253 \fBscf_transaction_property_delete()\fR, \fBscf_transaction_property_new()\fR,
254 \fBscf_transaction_property_change()\fR, and
255 \fBscf_transaction_property_change_type()\fR return 0. Otherwise, they return
259 The \fBscf_transaction_commit()\fR function returns 1 upon successful commit, 0
260 if the property group set in \fBscf_transaction_start()\fR is not the most
261 recent, and -1 on failure.
265 The \fBscf_transaction_create()\fR function will fail if:
269 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
272 The value of the \fIhandle\fR argument is \fINULL\fR.
278 \fB\fBSCF_ERROR_NO_MEMORY\fR\fR
281 There is not enough memory to allocate an \fBscf_transaction_t\fR.
287 \fB\fBSCF_ERROR_NO_RESOURCES\fR\fR
290 The server does not have adequate resources for a new transaction handle.
295 The \fBscf_transaction_handle()\fR function will fail if:
299 \fB\fBSCF_ERROR_HANDLE_DESTROYED\fR\fR
302 The handle associated with \fItran\fR has been destroyed.
307 The \fBscf_transaction_start()\fR function will fail if:
311 \fB\fBSCF_ERROR_BACKEND_ACCESS\fR\fR
315 The repository backend refused the modification.
321 \fB\fBSCF_ERROR_BACKEND_READONLY\fR\fR
325 The repository backend refused modification because it is read-only.
331 \fB\fBSCF_ERROR_CONNECTION_BROKEN\fR\fR
335 The connection to the repository was lost.
341 \fB\fBSCF_ERROR_DELETED\fR\fR
345 The property group has been deleted.
351 \fB\fBSCF_ERROR_HANDLE_MISMATCH\fR\fR
355 The transaction and property group are not derived from the same handle.
361 \fB\fBSCF_ERROR_IN_USE\fR\fR
365 The transaction is not in the \fBreset\fR state. The
366 \fBscf_transaction_reset()\fR and \fBscf_transaction_reset_all()\fR functions
367 can be used to return the transaction to the \fBreset\fR state.
373 \fB\fBSCF_ERROR_NO_RESOURCES\fR\fR
377 The server does not have the resources to complete the request.
383 \fB\fBSCF_ERROR_NOT_BOUND\fR\fR
387 The handle was never bound or has been unbound.
393 \fB\fBSCF_ERROR_NOT_SET\fR\fR
397 The property group specified by \fIpg\fR is not set.
403 \fB\fBSCF_ERROR_PERMISSION_DENIED\fR\fR
407 The user does not have sufficient privileges to modify the property group.
412 The \fBscf_transaction_property_delete()\fR,
413 \fBscf_transaction_property_new()\fR, \fBscf_transaction_property_change()\fR,
414 and \fBscf_transaction_property_change_type()\fR functions will fail if:
418 \fB\fBSCF_ERROR_BACKEND_ACCESS\fR\fR
422 The storage mechanism that the repository server (\fBsvc.configd\fR(1M))
423 chose for the operation denied access.
429 \fB\fBSCF_ERROR_CONNECTION_BROKEN\fR\fR
433 The connection to the repository was lost.
439 \fB\fBSCF_ERROR_DELETED\fR\fR
443 The property group the transaction is changing has been deleted.
449 \fB\fBSCF_ERROR_HANDLE_MISMATCH\fR\fR
453 The transaction and entry are not derived from the same handle.
459 \fB\fBSCF_ERROR_IN_USE\fR\fR
463 The property already has an entry in the transaction.
469 \fB\fBSCF_ERROR_INTERNAL\fR\fR
473 An internal error occurred.
479 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
483 The \fIprop_name\fR argument is not a valid property name.
489 \fB\fBSCF_ERROR_NO_RESOURCES\fR\fR
493 The server does not have the resources to complete the request.
499 \fB\fBSCF_ERROR_NOT_BOUND\fR\fR
503 The handle is not bound.
509 \fB\fBSCF_ERROR_NOT_SET\fR\fR
513 The transaction has not been started.
519 \fB\fBSCF_ERROR_TYPE_MISMATCH\fR\fR
523 The \fItran\fR argument is not of a type compatible with \fItype\fR.
528 The \fBscf_transaction_property_delete()\fR,
529 \fBscf_transaction_property_change()\fR, and
530 \fBscf_transaction_property_change_type()\fR functions will fail if:
534 \fB\fBSCF_ERROR_EXISTS\fR\fR
537 The object already exists.
543 \fB\fBSCF_ERROR_NOT_FOUND\fR\fR
546 The property group does not contain a property named \fIprop_name\fR.
551 The \fBscf_transaction_property_new()\fR ,
552 \fBscf_transaction_property_change()\fR, and
553 \fBscf_transaction_property_change_type()\fR functions will fail if:
557 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
560 The \fIprop_name\fR argument is not not a valid property name, or the
561 \fItype\fR argument is an invalid type.
566 The \fBscf_transaction_property_new()\fR function will fail if:
570 \fB\fBSCF_ERROR_EXISTS\fR\fR
573 The property group already contains a property named \fIprop_name\fR.
579 \fB\fBSCF_ERROR_NOT_FOUND\fR\fR
582 Nothing of that name was found.
587 The \fBscf_transaction_property_change()\fR function will fail if:
591 \fB\fBSCF_ERROR_TYPE_MISMATCH\fR\fR
594 The property \fIprop_name\fR is not of type \fItype\fR.
599 The \fBscf_transaction_commit()\fR function will fail if:
603 \fB\fBSCF_ERROR_BACKEND_READONLY\fR\fR
607 The repository backend is read-only.
613 \fB\fBSCF_ERROR_BACKEND_ACCESS\fR\fR
617 The repository backend refused the modification.
623 \fB\fBSCF_ERROR_NOT_BOUND\fR\fR
627 The handle is not bound.
633 \fB\fBSCF_ERROR_CONNECTION_BROKEN\fR\fR
637 The connection to the repository was lost.
643 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
647 The transaction is in an invalid state.
653 \fB\fBSCF_ERROR_DELETED\fR\fR
657 The property group the transaction is acting on has been deleted.
663 \fB\fBSCF_ERROR_NOT_SET\fR\fR
667 The transaction has not been started.
673 \fB\fBSCF_ERROR_PERMISSION_DENIED\fR\fR
677 The user does not have sufficient privileges to modify the property group.
683 \fB\fBSCF_ERROR_NO_RESOURCES\fR\fR
687 The server does not have sufficient resources to commit the transaction.
692 The \fBscf_error\fR(3SCF) function can be used to retrieve the error value.
695 \fBExample 1 \fRSet an existing boolean value to true.
699 tx = scf_transaction_create(handle);
700 e1 = scf_entry_create(handle);
701 v1 = scf_value_create(handle);
704 if (scf_pg_update(pg) == -1)
706 if (scf_transaction_start(tx, pg) == -1)
709 /* set up transaction entries */
710 if (scf_transaction_property_change(tx, e1, "property",
711 SCF_TYPE_BOOLEAN) == -1) {
712 scf_transaction_reset(tx);
715 scf_value_set_boolean(v1, 1);
716 scf_entry_add_value(e1, v1);
719 result = scf_transaction_commit(tx);
721 scf_transaction_reset(tx);
722 } while (result == 0);
730 scf_transaction_destroy(tx);
731 scf_entry_destroy(e1);
732 scf_value_destroy(v1);
739 See \fBattributes\fR(5) for descriptions of the following attributes:
747 ATTRIBUTE TYPE ATTRIBUTE VALUE
749 Interface Stability Committed
757 \fBlibscf\fR(3LIB), \fBscf_value_reset\fR(3SCF), \fBscf_error\fR(3SCF),
758 \fBscf_pg_create\fR(3SCF), \fBattributes\fR(5)