Print this page
7484 Garbage in libscf.h makes dumb compilers cry
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Sam Zaydel <szaydel@racktopsystems.com>
Reviewed by: Kim Shrier <kshrier@racktopsystems.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libscf/inc/libscf.h
+++ new/usr/src/lib/libscf/inc/libscf.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 + * Copyright 2016 RackTop Systems.
24 25 */
25 26
26 27 #ifndef _LIBSCF_H
27 28 #define _LIBSCF_H
28 29
29 30
30 31 #include <stddef.h>
31 32 #include <libnvpair.h>
32 33
33 34 #ifndef NATIVE_BUILD
34 35 #include <sys/secflags.h>
35 36 #endif /* NATIVE_BUILD */
36 37 #include <sys/types.h>
37 38
38 39 #ifdef __cplusplus
39 40 extern "C" {
40 41 #endif
41 42
42 -typedef struct scf_version *scf_version_t;
43 -#define SCF_VERSION ((scf_version_t)1UL)
43 +typedef unsigned long scf_version_t;
44 +#define SCF_VERSION 1UL
44 45
45 46 /*
46 47 * Opaque structures
47 48 */
48 49 typedef struct scf_handle scf_handle_t;
49 50 typedef struct scf_scope scf_scope_t;
50 51 typedef struct scf_service scf_service_t;
51 52 typedef struct scf_instance scf_instance_t;
52 53 typedef struct scf_propertygroup scf_propertygroup_t;
53 54 typedef struct scf_property scf_property_t;
54 55
55 56 typedef struct scf_snapshot scf_snapshot_t;
56 57 typedef struct scf_snaplevel scf_snaplevel_t;
57 58
58 59 typedef struct scf_transaction scf_transaction_t;
59 60 typedef struct scf_transaction_entry scf_transaction_entry_t;
60 61 typedef struct scf_value scf_value_t;
61 62
62 63 typedef struct scf_iter scf_iter_t;
63 64
64 65 typedef struct scf_pg_tmpl scf_pg_tmpl_t;
65 66 typedef struct scf_prop_tmpl scf_prop_tmpl_t;
66 67 typedef struct scf_tmpl_errors scf_tmpl_errors_t;
67 68
68 69 typedef struct scf_simple_app_props scf_simple_app_props_t;
69 70 typedef struct scf_simple_prop scf_simple_prop_t;
70 71
71 72 /*
72 73 * Types
73 74 */
74 75 typedef enum {
75 76 SCF_TYPE_INVALID = 0,
76 77
77 78 SCF_TYPE_BOOLEAN,
78 79 SCF_TYPE_COUNT,
79 80 SCF_TYPE_INTEGER,
80 81 SCF_TYPE_TIME,
81 82 SCF_TYPE_ASTRING,
82 83 SCF_TYPE_OPAQUE,
83 84
84 85 SCF_TYPE_USTRING = 100,
85 86
86 87 SCF_TYPE_URI = 200,
87 88 SCF_TYPE_FMRI,
88 89
89 90 SCF_TYPE_HOST = 300,
90 91 SCF_TYPE_HOSTNAME,
91 92 SCF_TYPE_NET_ADDR_V4,
92 93 SCF_TYPE_NET_ADDR_V6,
93 94 SCF_TYPE_NET_ADDR
94 95 } scf_type_t;
95 96
96 97 typedef struct scf_time {
97 98 int64_t t_seconds;
98 99 int32_t t_ns;
99 100 } scf_time_t;
100 101
101 102 /*
102 103 * There is no explicit initializer for this structure. Functions
103 104 * which set or populate this structure assume that it is either
104 105 * uninitialized or destroyed.
105 106 */
106 107 typedef struct scf_values {
107 108 scf_type_t value_type;
108 109 void *reserved; /* reserved for future use */
109 110 int value_count;
110 111 char **values_as_strings;
111 112 union {
112 113 uint64_t *v_count;
113 114 uint8_t *v_boolean;
114 115 int64_t *v_integer;
115 116 char **v_astring;
116 117 char **v_ustring;
117 118 char **v_opaque;
118 119 scf_time_t *v_time;
119 120 } values;
120 121 } scf_values_t;
121 122
122 123 typedef struct scf_count_ranges {
123 124 int scr_num_ranges;
124 125 uint64_t *scr_min;
125 126 uint64_t *scr_max;
126 127 } scf_count_ranges_t;
127 128
128 129 typedef struct scf_int_ranges {
129 130 int sir_num_ranges;
130 131 int64_t *sir_min;
131 132 int64_t *sir_max;
132 133 } scf_int_ranges_t;
133 134
134 135 /*
135 136 * Return codes
136 137 */
137 138 #define SCF_SUCCESS 0
138 139 #define SCF_COMPLETE 1
139 140 #define SCF_FAILED -1
140 141
141 142 typedef enum scf_error {
142 143 SCF_ERROR_NONE = 1000, /* no error */
143 144 SCF_ERROR_NOT_BOUND, /* handle not bound */
144 145 SCF_ERROR_NOT_SET, /* cannot use unset argument */
145 146 SCF_ERROR_NOT_FOUND, /* nothing of that name found */
146 147 SCF_ERROR_TYPE_MISMATCH, /* type does not match value */
147 148 SCF_ERROR_IN_USE, /* cannot modify while in-use */
148 149 SCF_ERROR_CONNECTION_BROKEN, /* repository connection gone */
149 150 SCF_ERROR_INVALID_ARGUMENT, /* bad argument */
150 151 SCF_ERROR_NO_MEMORY, /* no memory available */
151 152 SCF_ERROR_CONSTRAINT_VIOLATED, /* required constraint not met */
152 153 SCF_ERROR_EXISTS, /* object already exists */
153 154 SCF_ERROR_NO_SERVER, /* repository server unavailable */
154 155 SCF_ERROR_NO_RESOURCES, /* server has insufficient resources */
155 156 SCF_ERROR_PERMISSION_DENIED, /* insufficient privileges for action */
156 157 SCF_ERROR_BACKEND_ACCESS, /* backend refused access */
157 158 SCF_ERROR_HANDLE_MISMATCH, /* mismatched SCF handles */
158 159 SCF_ERROR_HANDLE_DESTROYED, /* object bound to destroyed handle */
159 160 SCF_ERROR_VERSION_MISMATCH, /* incompatible SCF version */
160 161 SCF_ERROR_BACKEND_READONLY, /* backend is read-only */
161 162 SCF_ERROR_DELETED, /* object has been deleted */
162 163 SCF_ERROR_TEMPLATE_INVALID, /* template data is invalid */
163 164
164 165 SCF_ERROR_CALLBACK_FAILED = 1080, /* user callback function failed */
165 166
166 167 SCF_ERROR_INTERNAL = 1101 /* internal error */
167 168 } scf_error_t;
168 169
169 170 /*
170 171 * This enum MUST be kept in sync with
171 172 * struct _scf_tmpl_error_desc em_desc() in scf_tmpl.c
172 173 */
173 174 typedef enum scf_tmpl_error_type {
174 175 SCF_TERR_MISSING_PG, /* property group missing */
175 176 SCF_TERR_WRONG_PG_TYPE, /* property group type incorrect */
176 177 SCF_TERR_MISSING_PROP, /* missing required property */
177 178 SCF_TERR_WRONG_PROP_TYPE, /* property type incorrect */
178 179 SCF_TERR_CARDINALITY_VIOLATION, /* wrong number of values */
179 180 SCF_TERR_VALUE_CONSTRAINT_VIOLATED, /* constraint violated for value */
180 181 SCF_TERR_RANGE_VIOLATION, /* value violated specified range */
181 182 SCF_TERR_PG_REDEFINE, /* global or restarter pg_pattern */
182 183 /* redefined by the instance */
183 184 SCF_TERR_PROP_TYPE_MISMATCH, /* property and value type mismatch */
184 185 SCF_TERR_VALUE_OUT_OF_RANGE, /* value is out of range in template */
185 186 SCF_TERR_INVALID_VALUE, /* value is not valid for the */
186 187 /* template */
187 188 SCF_TERR_PG_PATTERN_CONFLICT, /* pg_pattern conflicts with higher */
188 189 /* level definition */
189 190 SCF_TERR_PROP_PATTERN_CONFLICT, /* prop_pattern conflicts with higher */
190 191 /* level definition */
191 192 SCF_TERR_GENERAL_REDEFINE, /* global or restarter template */
192 193 /* redefined */
193 194 SCF_TERR_INCLUDE_VALUES, /* No supporting constraints or */
194 195 /* values for include_values */
195 196 SCF_TERR_PG_PATTERN_INCOMPLETE, /* Required pg_pattern is missing */
196 197 /* name or type attribute. */
197 198 SCF_TERR_PROP_PATTERN_INCOMPLETE /* Required prop_pattern is */
198 199 /* missing a type attribute. */
199 200 } scf_tmpl_error_type_t;
200 201
201 202 typedef struct scf_tmpl_error scf_tmpl_error_t;
202 203
203 204 /*
204 205 * This unfortunately needs to be public, because consumers of librestart must
205 206 * deal with it
206 207 */
207 208 typedef struct {
208 209 #ifndef NATIVE_BUILD
209 210 secflagdelta_t ss_default;
210 211 secflagdelta_t ss_lower;
211 212 secflagdelta_t ss_upper;
212 213 #else
213 214 /*
214 215 * This is never used, but is necessary for bootstrapping.
215 216 * Not even the size matters.
216 217 */
217 218 void *ss_default;
218 219 void *ss_lower;
219 220 void *ss_upper;
220 221 #endif /* NATIVE_BUILD */
↓ open down ↓ |
167 lines elided |
↑ open up ↑ |
221 222 } scf_secflags_t;
222 223
223 224 /*
224 225 * scf_tmpl_strerror() human readable flag
225 226 */
226 227 #define SCF_TMPL_STRERROR_HUMAN 0x1
227 228
228 229 /*
229 230 * Standard services
230 231 */
231 -#define SCF_SERVICE_CONFIGD ((const char *) \
232 - "svc:/system/svc/repository:default")
233 -#define SCF_INSTANCE_GLOBAL ((const char *) \
234 - "svc:/system/svc/global:default")
235 -#define SCF_SERVICE_GLOBAL ((const char *) \
236 - "svc:/system/svc/global")
237 -#define SCF_SERVICE_STARTD ((const char *) \
238 - "svc:/system/svc/restarter:default")
239 -#define SCF_INSTANCE_EMI ((const char *) \
240 - "svc:/system/early-manifest-import:default")
241 -#define SCF_INSTANCE_FS_MINIMAL ((const char *) \
242 - "svc:/system/filesystem/minimal:default")
243 -#define SCF_INSTANCE_MI ((const char *) \
244 - "svc:/system/manifest-import:default")
232 +#define SCF_SERVICE_CONFIGD "svc:/system/svc/repository:default"
233 +#define SCF_INSTANCE_GLOBAL "svc:/system/svc/global:default"
234 +#define SCF_SERVICE_GLOBAL "svc:/system/svc/global"
235 +#define SCF_SERVICE_STARTD "svc:/system/svc/restarter:default"
236 +#define SCF_INSTANCE_EMI "svc:/system/early-manifest-import:default"
237 +#define SCF_INSTANCE_FS_MINIMAL "svc:/system/filesystem/minimal:default"
238 +#define SCF_INSTANCE_MI "svc:/system/manifest-import:default"
245 239
246 240 /*
247 241 * Major milestones
248 242 */
249 -#define SCF_MILESTONE_SINGLE_USER \
250 - ((const char *) "svc:/milestone/single-user:default")
251 -#define SCF_MILESTONE_MULTI_USER \
252 - ((const char *) "svc:/milestone/multi-user:default")
243 +#define SCF_MILESTONE_SINGLE_USER "svc:/milestone/single-user:default"
244 +#define SCF_MILESTONE_MULTI_USER "svc:/milestone/multi-user:default"
253 245 #define SCF_MILESTONE_MULTI_USER_SERVER \
254 - ((const char *) "svc:/milestone/multi-user-server:default")
246 + "svc:/milestone/multi-user-server:default"
255 247
256 248 /*
257 249 * standard scope names
258 250 */
259 -#define SCF_SCOPE_LOCAL ((const char *)"localhost")
251 +#define SCF_SCOPE_LOCAL "localhost"
260 252
261 253 /*
262 254 * Property group types
263 255 */
264 -#define SCF_GROUP_APPLICATION ((const char *)"application")
265 -#define SCF_GROUP_FRAMEWORK ((const char *)"framework")
266 -#define SCF_GROUP_DEPENDENCY ((const char *)"dependency")
267 -#define SCF_GROUP_METHOD ((const char *)"method")
268 -#define SCF_GROUP_TEMPLATE ((const char *)"template")
269 -#define SCF_GROUP_TEMPLATE_PG_PATTERN ((const char *)"template_pg_pattern")
270 -#define SCF_GROUP_TEMPLATE_PROP_PATTERN ((const char *)"template_prop_pattern")
256 +#define SCF_GROUP_APPLICATION "application"
257 +#define SCF_GROUP_FRAMEWORK "framework"
258 +#define SCF_GROUP_DEPENDENCY "dependency"
259 +#define SCF_GROUP_METHOD "method"
260 +#define SCF_GROUP_TEMPLATE "template"
261 +#define SCF_GROUP_TEMPLATE_PG_PATTERN "template_pg_pattern"
262 +#define SCF_GROUP_TEMPLATE_PROP_PATTERN "template_prop_pattern"
271 263
272 264 /*
273 265 * Dependency types
274 266 */
275 -#define SCF_DEP_REQUIRE_ALL ((const char *)"require_all")
276 -#define SCF_DEP_REQUIRE_ANY ((const char *)"require_any")
277 -#define SCF_DEP_EXCLUDE_ALL ((const char *)"exclude_all")
278 -#define SCF_DEP_OPTIONAL_ALL ((const char *)"optional_all")
279 -
280 -#define SCF_DEP_RESET_ON_ERROR ((const char *)"error")
281 -#define SCF_DEP_RESET_ON_RESTART ((const char *)"restart")
282 -#define SCF_DEP_RESET_ON_REFRESH ((const char *)"refresh")
283 -#define SCF_DEP_RESET_ON_NONE ((const char *)"none")
267 +#define SCF_DEP_REQUIRE_ALL "require_all"
268 +#define SCF_DEP_REQUIRE_ANY "require_any"
269 +#define SCF_DEP_EXCLUDE_ALL "exclude_all"
270 +#define SCF_DEP_OPTIONAL_ALL "optional_all"
271 +
272 +#define SCF_DEP_RESET_ON_ERROR "error"
273 +#define SCF_DEP_RESET_ON_RESTART "restart"
274 +#define SCF_DEP_RESET_ON_REFRESH "refresh"
275 +#define SCF_DEP_RESET_ON_NONE "none"
284 276
285 277 /*
286 278 * Standard property group names
287 279 */
288 -#define SCF_PG_GENERAL ((const char *)"general")
289 -#define SCF_PG_GENERAL_OVR ((const char *)"general_ovr")
290 -#define SCF_PG_RESTARTER ((const char *)"restarter")
291 -#define SCF_PG_RESTARTER_ACTIONS ((const char *)"restarter_actions")
292 -#define SCF_PG_METHOD_CONTEXT ((const char *)"method_context")
293 -#define SCF_PG_APP_DEFAULT ((const char *)"application")
294 -#define SCF_PG_DEPENDENTS ((const char *)"dependents")
295 -#define SCF_PG_OPTIONS ((const char *)"options")
296 -#define SCF_PG_OPTIONS_OVR ((const char *)"options_ovr")
297 -#define SCF_PG_STARTD ((const char *)"startd")
298 -#define SCF_PG_STARTD_PRIVATE ((const char *)"svc-startd-private")
299 -#define SCF_PG_DEATHROW ((const char *)"deathrow")
300 -#define SCF_PG_MANIFESTFILES ((const char *)"manifestfiles")
280 +#define SCF_PG_GENERAL "general"
281 +#define SCF_PG_GENERAL_OVR "general_ovr"
282 +#define SCF_PG_RESTARTER "restarter"
283 +#define SCF_PG_RESTARTER_ACTIONS "restarter_actions"
284 +#define SCF_PG_METHOD_CONTEXT "method_context"
285 +#define SCF_PG_APP_DEFAULT "application"
286 +#define SCF_PG_DEPENDENTS "dependents"
287 +#define SCF_PG_OPTIONS "options"
288 +#define SCF_PG_OPTIONS_OVR "options_ovr"
289 +#define SCF_PG_STARTD "startd"
290 +#define SCF_PG_STARTD_PRIVATE "svc-startd-private"
291 +#define SCF_PG_DEATHROW "deathrow"
292 +#define SCF_PG_MANIFESTFILES "manifestfiles"
301 293
302 294 /*
303 295 * Template property group names and prefixes
304 296 */
305 -#define SCF_PG_TM_COMMON_NAME ((const char *)"tm_common_name")
306 -#define SCF_PG_TM_DESCRIPTION ((const char *)"tm_description")
297 +#define SCF_PG_TM_COMMON_NAME "tm_common_name"
298 +#define SCF_PG_TM_DESCRIPTION "tm_description"
307 299
308 -#define SCF_PG_TM_MAN_PREFIX ((const char *)"tm_man_")
309 -#define SCF_PG_TM_DOC_PREFIX ((const char *)"tm_doc_")
300 +#define SCF_PG_TM_MAN_PREFIX "tm_man_"
301 +#define SCF_PG_TM_DOC_PREFIX "tm_doc_"
310 302
311 303 /*
312 304 * Standard property names
313 305 */
314 -#define SCF_PROPERTY_ACTIVE_POSTFIX ((const char *)"active")
315 -#define SCF_PROPERTY_AUX_STATE ((const char *)"auxiliary_state")
316 -#define SCF_PROPERTY_AUX_FMRI ((const char *)"auxiliary_fmri")
317 -#define SCF_PROPERTY_AUX_TTY ((const char *)"auxiliary_tty")
318 -#define SCF_PROPERTY_CONTRACT ((const char *)"contract")
319 -#define SCF_PROPERTY_COREFILE_PATTERN ((const char *)"corefile_pattern")
320 -#define SCF_PROPERTY_DEGRADED ((const char *)"degraded")
321 -#define SCF_PROPERTY_DEGRADE_IMMEDIATE ((const char *)"degrade_immediate")
322 -#define SCF_PROPERTY_DODUMP ((const char *)"do_dump")
323 -#define SCF_PROPERTY_DURATION ((const char *)"duration")
324 -#define SCF_PROPERTY_ENABLED ((const char *)"enabled")
325 -#define SCF_PROPERTY_DEATHROW ((const char *)"deathrow")
326 -#define SCF_PROPERTY_ENTITY_STABILITY ((const char *)"entity_stability")
327 -#define SCF_PROPERTY_ENTITIES ((const char *)"entities")
328 -#define SCF_PROPERTY_EXEC ((const char *)"exec")
329 -#define SCF_PROPERTY_GROUP ((const char *)"group")
330 -#define SCF_PROPERTY_GROUPING ((const char *)"grouping")
331 -#define SCF_PROPERTY_IGNORE ((const char *)"ignore_error")
332 -#define SCF_PROPERTY_INTERNAL_SEPARATORS ((const char *)"internal_separators")
333 -#define SCF_PROPERTY_LIMIT_PRIVILEGES ((const char *)"limit_privileges")
334 -#define SCF_PROPERTY_MAINT_OFF ((const char *)"maint_off")
335 -#define SCF_PROPERTY_MAINT_ON ((const char *)"maint_on")
336 -#define SCF_PROPERTY_MAINT_ON_IMMEDIATE ((const char *)"maint_on_immediate")
337 -#define SCF_PROPERTY_MAINT_ON_IMMTEMP ((const char *)"maint_on_immtemp")
338 -#define SCF_PROPERTY_MAINT_ON_TEMPORARY ((const char *)"maint_on_temporary")
339 -#define SCF_PROPERTY_METHOD_PID ((const char *)"method_pid")
340 -#define SCF_PROPERTY_MILESTONE ((const char *)"milestone")
341 -#define SCF_PROPERTY_NEED_SESSION ((const char *)"need_session")
342 -#define SCF_PROPERTY_NEXT_STATE ((const char *)"next_state")
343 -#define SCF_PROPERTY_PACKAGE ((const char *)"package")
344 -#define SCF_PROPERTY_PRIVILEGES ((const char *)"privileges")
345 -#define SCF_PROPERTY_PROFILE ((const char *)"profile")
346 -#define SCF_PROPERTY_PROJECT ((const char *)"project")
347 -#define SCF_PROPERTY_REFRESH ((const char *)"refresh")
348 -#define SCF_PROPERTY_RESOURCE_POOL ((const char *)"resource_pool")
349 -#define SCF_PROPERTY_ENVIRONMENT ((const char *)"environment")
350 -#define SCF_PROPERTY_RESTART ((const char *)"restart")
351 -#define SCF_PROPERTY_RESTARTER ((const char *)"restarter")
352 -#define SCF_PROPERTY_RESTART_INTERVAL ((const char *)"restart_interval")
353 -#define SCF_PROPERTY_RESTART_ON ((const char *)"restart_on")
354 -#define SCF_PROPERTY_RESTORE ((const char *)"restore")
355 -#define SCF_PROPERTY_SECFLAGS ((const char *)"security_flags")
356 -#define SCF_PROPERTY_SINGLE_INSTANCE ((const char *)"single_instance")
357 -#define SCF_PROPERTY_START_METHOD_TIMESTAMP \
358 - ((const char *)"start_method_timestamp")
359 -#define SCF_PROPERTY_START_METHOD_WAITSTATUS \
360 - ((const char *)"start_method_waitstatus")
361 -#define SCF_PROPERTY_START_PID ((const char *)"start_pid")
362 -#define SCF_PROPERTY_STATE ((const char *)"state")
363 -#define SCF_PROPERTY_STABILITY ((const char *)"stability")
364 -#define SCF_PROPERTY_STATE_TIMESTAMP ((const char *)"state_timestamp")
365 -#define SCF_PROPERTY_SUPP_GROUPS ((const char *)"supp_groups")
366 -#define SCF_PROPERTY_TIMEOUT ((const char *)"timeout_seconds")
367 -#define SCF_PROPERTY_TIMEOUT_RETRY ((const char *)"timeout_retry")
368 -#define SCF_PROPERTY_TRANSIENT_CONTRACT ((const char *)"transient_contract")
369 -#define SCF_PROPERTY_TYPE ((const char *)"type")
370 -#define SCF_PROPERTY_USE_PROFILE ((const char *)"use_profile")
371 -#define SCF_PROPERTY_USER ((const char *)"user")
372 -#define SCF_PROPERTY_UTMPX_PREFIX ((const char *)"utmpx_prefix")
373 -#define SCF_PROPERTY_WORKING_DIRECTORY ((const char *)"working_directory")
306 +#define SCF_PROPERTY_ACTIVE_POSTFIX "active"
307 +#define SCF_PROPERTY_AUX_STATE "auxiliary_state"
308 +#define SCF_PROPERTY_AUX_FMRI "auxiliary_fmri"
309 +#define SCF_PROPERTY_AUX_TTY "auxiliary_tty"
310 +#define SCF_PROPERTY_CONTRACT "contract"
311 +#define SCF_PROPERTY_COREFILE_PATTERN "corefile_pattern"
312 +#define SCF_PROPERTY_DEGRADED "degraded"
313 +#define SCF_PROPERTY_DEGRADE_IMMEDIATE "degrade_immediate"
314 +#define SCF_PROPERTY_DODUMP "do_dump"
315 +#define SCF_PROPERTY_DURATION "duration"
316 +#define SCF_PROPERTY_ENABLED "enabled"
317 +#define SCF_PROPERTY_DEATHROW "deathrow"
318 +#define SCF_PROPERTY_ENTITY_STABILITY "entity_stability"
319 +#define SCF_PROPERTY_ENTITIES "entities"
320 +#define SCF_PROPERTY_EXEC "exec"
321 +#define SCF_PROPERTY_GROUP "group"
322 +#define SCF_PROPERTY_GROUPING "grouping"
323 +#define SCF_PROPERTY_IGNORE "ignore_error"
324 +#define SCF_PROPERTY_INTERNAL_SEPARATORS "internal_separators"
325 +#define SCF_PROPERTY_LIMIT_PRIVILEGES "limit_privileges"
326 +#define SCF_PROPERTY_MAINT_OFF "maint_off"
327 +#define SCF_PROPERTY_MAINT_ON "maint_on"
328 +#define SCF_PROPERTY_MAINT_ON_IMMEDIATE "maint_on_immediate"
329 +#define SCF_PROPERTY_MAINT_ON_IMMTEMP "maint_on_immtemp"
330 +#define SCF_PROPERTY_MAINT_ON_TEMPORARY "maint_on_temporary"
331 +#define SCF_PROPERTY_METHOD_PID "method_pid"
332 +#define SCF_PROPERTY_MILESTONE "milestone"
333 +#define SCF_PROPERTY_NEED_SESSION "need_session"
334 +#define SCF_PROPERTY_NEXT_STATE "next_state"
335 +#define SCF_PROPERTY_PACKAGE "package"
336 +#define SCF_PROPERTY_PRIVILEGES "privileges"
337 +#define SCF_PROPERTY_PROFILE "profile"
338 +#define SCF_PROPERTY_PROJECT "project"
339 +#define SCF_PROPERTY_REFRESH "refresh"
340 +#define SCF_PROPERTY_RESOURCE_POOL "resource_pool"
341 +#define SCF_PROPERTY_ENVIRONMENT "environment"
342 +#define SCF_PROPERTY_RESTART "restart"
343 +#define SCF_PROPERTY_RESTARTER "restarter"
344 +#define SCF_PROPERTY_RESTART_INTERVAL "restart_interval"
345 +#define SCF_PROPERTY_RESTART_ON "restart_on"
346 +#define SCF_PROPERTY_RESTORE "restore"
347 +#define SCF_PROPERTY_SECFLAGS "security_flags"
348 +#define SCF_PROPERTY_SINGLE_INSTANCE "single_instance"
349 +#define SCF_PROPERTY_START_METHOD_TIMESTAMP "start_method_timestamp"
350 +#define SCF_PROPERTY_START_METHOD_WAITSTATUS "start_method_waitstatus"
351 +#define SCF_PROPERTY_START_PID "start_pid"
352 +#define SCF_PROPERTY_STATE "state"
353 +#define SCF_PROPERTY_STABILITY "stability"
354 +#define SCF_PROPERTY_STATE_TIMESTAMP "state_timestamp"
355 +#define SCF_PROPERTY_SUPP_GROUPS "supp_groups"
356 +#define SCF_PROPERTY_TIMEOUT "timeout_seconds"
357 +#define SCF_PROPERTY_TIMEOUT_RETRY "timeout_retry"
358 +#define SCF_PROPERTY_TRANSIENT_CONTRACT "transient_contract"
359 +#define SCF_PROPERTY_TYPE "type"
360 +#define SCF_PROPERTY_USE_PROFILE "use_profile"
361 +#define SCF_PROPERTY_USER "user"
362 +#define SCF_PROPERTY_UTMPX_PREFIX "utmpx_prefix"
363 +#define SCF_PROPERTY_WORKING_DIRECTORY "working_directory"
374 364
375 365 /*
376 366 * Template property names
377 367 */
378 -#define SCF_PROPERTY_TM_CARDINALITY_MIN ((const char *)"cardinality_min")
379 -#define SCF_PROPERTY_TM_CARDINALITY_MAX ((const char *)"cardinality_max")
380 -#define SCF_PROPERTY_TM_CHOICES_INCLUDE_VALUES ((const char *) \
381 - "choices_include_values")
382 -#define SCF_PROPERTY_TM_CHOICES_NAME ((const char *)"choices_name")
383 -#define SCF_PROPERTY_TM_CHOICES_RANGE ((const char *)"choices_range")
384 -#define SCF_PROPERTY_TM_CONSTRAINT_NAME ((const char *)"constraint_name")
385 -#define SCF_PROPERTY_TM_CONSTRAINT_RANGE ((const char *)"constraint_range")
386 -#define SCF_PROPERTY_TM_MANPATH ((const char *)"manpath")
387 -#define SCF_PROPERTY_TM_NAME ((const char *)"name")
388 -#define SCF_PROPERTY_TM_PG_PATTERN ((const char *)"pg_pattern")
389 -#define SCF_PROPERTY_TM_REQUIRED ((const char *)"required")
390 -#define SCF_PROPERTY_TM_SECTION ((const char *)"section")
391 -#define SCF_PROPERTY_TM_TARGET ((const char *)"target")
392 -#define SCF_PROPERTY_TM_TITLE ((const char *)"title")
393 -#define SCF_PROPERTY_TM_TYPE ((const char *)"type")
394 -#define SCF_PROPERTY_TM_URI ((const char *)"uri")
395 -#define SCF_PROPERTY_TM_VALUE_PREFIX ((const char *)"value_")
396 -#define SCF_PROPERTY_TM_VALUES_NAME ((const char *)"values_name")
397 -#define SCF_PROPERTY_TM_VISIBILITY ((const char *)"visibility")
398 -#define SCF_PROPERTY_TM_COMMON_NAME_PREFIX ((const char *)"common_name_")
399 -#define SCF_PROPERTY_TM_DESCRIPTION_PREFIX ((const char *)"description_")
400 -#define SCF_PROPERTY_TM_UNITS_PREFIX ((const char *)"units_")
368 +#define SCF_PROPERTY_TM_CARDINALITY_MIN "cardinality_min"
369 +#define SCF_PROPERTY_TM_CARDINALITY_MAX "cardinality_max"
370 +#define SCF_PROPERTY_TM_CHOICES_INCLUDE_VALUES "choices_include_values"
371 +#define SCF_PROPERTY_TM_CHOICES_NAME "choices_name"
372 +#define SCF_PROPERTY_TM_CHOICES_RANGE "choices_range"
373 +#define SCF_PROPERTY_TM_CONSTRAINT_NAME "constraint_name"
374 +#define SCF_PROPERTY_TM_CONSTRAINT_RANGE "constraint_range"
375 +#define SCF_PROPERTY_TM_MANPATH "manpath"
376 +#define SCF_PROPERTY_TM_NAME "name"
377 +#define SCF_PROPERTY_TM_PG_PATTERN "pg_pattern"
378 +#define SCF_PROPERTY_TM_REQUIRED "required"
379 +#define SCF_PROPERTY_TM_SECTION "section"
380 +#define SCF_PROPERTY_TM_TARGET "target"
381 +#define SCF_PROPERTY_TM_TITLE "title"
382 +#define SCF_PROPERTY_TM_TYPE "type"
383 +#define SCF_PROPERTY_TM_URI "uri"
384 +#define SCF_PROPERTY_TM_VALUE_PREFIX "value_"
385 +#define SCF_PROPERTY_TM_VALUES_NAME "values_name"
386 +#define SCF_PROPERTY_TM_VISIBILITY "visibility"
387 +#define SCF_PROPERTY_TM_COMMON_NAME_PREFIX "common_name_"
388 +#define SCF_PROPERTY_TM_DESCRIPTION_PREFIX "description_"
389 +#define SCF_PROPERTY_TM_UNITS_PREFIX "units_"
401 390
402 391 /*
403 392 * Templates wildcard string
404 393 */
405 -#define SCF_TMPL_WILDCARD ((const char *)"*")
394 +#define SCF_TMPL_WILDCARD "*"
406 395
407 396 /*
408 397 * Strings used by restarters for state and next_state properties.
409 398 * MAX_SCF_STATE_STRING holds the max length of a state string, including the
410 399 * terminating null.
411 400 */
412 401
413 402 #define MAX_SCF_STATE_STRING_SZ 14
414 403
415 -#define SCF_STATE_STRING_NONE ((const char *)"none")
416 -#define SCF_STATE_STRING_UNINIT ((const char *)"uninitialized")
417 -#define SCF_STATE_STRING_MAINT ((const char *)"maintenance")
418 -#define SCF_STATE_STRING_OFFLINE ((const char *)"offline")
419 -#define SCF_STATE_STRING_DISABLED ((const char *)"disabled")
420 -#define SCF_STATE_STRING_ONLINE ((const char *)"online")
421 -#define SCF_STATE_STRING_DEGRADED ((const char *)"degraded")
422 -#define SCF_STATE_STRING_LEGACY ((const char *)"legacy_run")
404 +#define SCF_STATE_STRING_NONE "none"
405 +#define SCF_STATE_STRING_UNINIT "uninitialized"
406 +#define SCF_STATE_STRING_MAINT "maintenance"
407 +#define SCF_STATE_STRING_OFFLINE "offline"
408 +#define SCF_STATE_STRING_DISABLED "disabled"
409 +#define SCF_STATE_STRING_ONLINE "online"
410 +#define SCF_STATE_STRING_DEGRADED "degraded"
411 +#define SCF_STATE_STRING_LEGACY "legacy_run"
423 412
424 413 #define SCF_STATE_UNINIT 0x00000001
425 414 #define SCF_STATE_MAINT 0x00000002
426 415 #define SCF_STATE_OFFLINE 0x00000004
427 416 #define SCF_STATE_DISABLED 0x00000008
428 417 #define SCF_STATE_ONLINE 0x00000010
429 418 #define SCF_STATE_DEGRADED 0x00000020
430 419 #define SCF_STATE_ALL 0x0000003F
431 420
432 421 /*
433 422 * software fma svc-transition class
434 423 */
435 424 #define SCF_NOTIFY_PARAMS_VERSION 0X0
436 -#define SCF_NOTIFY_NAME_FMRI ((const char *)"fmri")
437 -#define SCF_NOTIFY_NAME_VERSION ((const char *)"version")
438 -#define SCF_NOTIFY_NAME_TSET ((const char *)"tset")
439 -#define SCF_NOTIFY_PG_POSTFIX ((const char *)"fmnotify")
440 -#define SCF_NOTIFY_PARAMS ((const char *)"notify-params")
441 -#define SCF_NOTIFY_PARAMS_INST \
442 - ((const char *)"svc:/system/fm/notify-params:default")
443 -#define SCF_SVC_TRANSITION_CLASS \
444 - ((const char *)"ireport.os.smf.state-transition")
445 -#define SCF_NOTIFY_PARAMS_PG_TYPE ((const char *)"notify_params")
425 +#define SCF_NOTIFY_NAME_FMRI "fmri"
426 +#define SCF_NOTIFY_NAME_VERSION "version"
427 +#define SCF_NOTIFY_NAME_TSET "tset"
428 +#define SCF_NOTIFY_PG_POSTFIX "fmnotify"
429 +#define SCF_NOTIFY_PARAMS "notify-params"
430 +#define SCF_NOTIFY_PARAMS_INST "svc:/system/fm/notify-params:default"
431 +#define SCF_SVC_TRANSITION_CLASS "ireport.os.smf.state-transition"
432 +#define SCF_NOTIFY_PARAMS_PG_TYPE "notify_params"
446 433
447 434 /*
448 435 * Useful transition macros
449 436 */
450 437 #define SCF_TRANS_SHIFT_INITIAL_STATE(s) ((s) << 16)
451 438 #define SCF_TRANSITION_ALL \
452 439 (SCF_TRANS_SHIFT_INITIAL_STATE(SCF_STATE_ALL) | SCF_STATE_ALL)
453 440 #define SCF_TRANS(f, t) (SCF_TRANS_SHIFT_INITIAL_STATE(f) | (t))
454 441 #define SCF_TRANS_VALID(t) (!((t) & ~SCF_TRANSITION_ALL))
455 442 #define SCF_TRANS_INITIAL_STATE(t) ((t) >> 16 & SCF_STATE_ALL)
456 443 #define SCF_TRANS_FINAL_STATE(t) ((t) & SCF_STATE_ALL)
457 444
458 445 /*
459 446 * Prefixes for states in state transition notification
460 447 */
461 -#define SCF_STN_PREFIX_FROM ((const char *)"from-")
462 -#define SCF_STN_PREFIX_TO ((const char *)"to-")
448 +#define SCF_STN_PREFIX_FROM "from-"
449 +#define SCF_STN_PREFIX_TO "to-"
463 450
464 451 #define SCF_PG_FLAG_NONPERSISTENT 0x1
465 452
466 453 #define SCF_TRACE_LIBRARY 0x1
467 454 #define SCF_TRACE_DAEMON 0x2
468 455
469 456 #define SMF_IMMEDIATE 0x1
470 457 #define SMF_TEMPORARY 0x2
471 458 #define SMF_AT_NEXT_BOOT 0x4
472 459
473 460 scf_error_t scf_error(void);
474 461 const char *scf_strerror(scf_error_t);
475 462
476 463 ssize_t scf_limit(uint32_t code);
477 464 #define SCF_LIMIT_MAX_NAME_LENGTH -2000U
478 465 #define SCF_LIMIT_MAX_VALUE_LENGTH -2001U
479 466 #define SCF_LIMIT_MAX_PG_TYPE_LENGTH -2002U
480 467 #define SCF_LIMIT_MAX_FMRI_LENGTH -2003U
481 468
482 469 scf_handle_t *scf_handle_create(scf_version_t);
483 470
484 471 int scf_handle_decorate(scf_handle_t *, const char *, scf_value_t *);
485 472 #define SCF_DECORATE_CLEAR ((scf_value_t *)0)
486 473
487 474 int scf_handle_bind(scf_handle_t *);
488 475 int scf_handle_unbind(scf_handle_t *);
489 476 void scf_handle_destroy(scf_handle_t *);
490 477
491 478 int scf_type_base_type(scf_type_t type, scf_type_t *out);
492 479 const char *scf_type_to_string(scf_type_t);
493 480 scf_type_t scf_string_to_type(const char *);
494 481
495 482 /* values */
496 483 scf_value_t *scf_value_create(scf_handle_t *);
497 484 scf_handle_t *scf_value_handle(const scf_value_t *);
498 485 void scf_value_destroy(scf_value_t *);
499 486
500 487 scf_type_t scf_value_base_type(const scf_value_t *);
501 488 scf_type_t scf_value_type(const scf_value_t *);
502 489 int scf_value_is_type(const scf_value_t *, scf_type_t);
503 490
504 491 void scf_value_reset(scf_value_t *);
505 492
506 493 int scf_value_get_boolean(const scf_value_t *, uint8_t *);
507 494 int scf_value_get_count(const scf_value_t *, uint64_t *);
508 495 int scf_value_get_integer(const scf_value_t *, int64_t *);
509 496 int scf_value_get_time(const scf_value_t *, int64_t *, int32_t *);
510 497 ssize_t scf_value_get_astring(const scf_value_t *, char *, size_t);
511 498 ssize_t scf_value_get_ustring(const scf_value_t *, char *, size_t);
512 499 ssize_t scf_value_get_opaque(const scf_value_t *, void *, size_t);
513 500
514 501 void scf_value_set_boolean(scf_value_t *, uint8_t);
515 502 void scf_value_set_count(scf_value_t *, uint64_t);
516 503 void scf_value_set_integer(scf_value_t *, int64_t);
517 504 int scf_value_set_time(scf_value_t *, int64_t, int32_t);
518 505 int scf_value_set_astring(scf_value_t *, const char *);
519 506 int scf_value_set_ustring(scf_value_t *, const char *);
520 507 int scf_value_set_opaque(scf_value_t *, const void *, size_t);
521 508
522 509 ssize_t scf_value_get_as_string(const scf_value_t *, char *, size_t);
523 510 ssize_t scf_value_get_as_string_typed(const scf_value_t *, scf_type_t,
524 511 char *, size_t);
525 512 int scf_value_set_from_string(scf_value_t *, scf_type_t, const char *);
526 513
527 514 scf_iter_t *scf_iter_create(scf_handle_t *);
528 515 scf_handle_t *scf_iter_handle(const scf_iter_t *);
529 516 void scf_iter_reset(scf_iter_t *);
530 517 void scf_iter_destroy(scf_iter_t *);
531 518
532 519 int scf_iter_handle_scopes(scf_iter_t *, const scf_handle_t *);
533 520 int scf_iter_scope_services(scf_iter_t *, const scf_scope_t *);
534 521 int scf_iter_service_instances(scf_iter_t *, const scf_service_t *);
535 522 int scf_iter_service_pgs(scf_iter_t *, const scf_service_t *);
536 523 int scf_iter_instance_pgs(scf_iter_t *, const scf_instance_t *);
537 524 int scf_iter_instance_pgs_composed(scf_iter_t *, const scf_instance_t *,
538 525 const scf_snapshot_t *);
539 526 int scf_iter_service_pgs_typed(scf_iter_t *, const scf_service_t *,
540 527 const char *);
541 528 int scf_iter_instance_pgs_typed(scf_iter_t *, const scf_instance_t *,
542 529 const char *);
543 530 int scf_iter_instance_pgs_typed_composed(scf_iter_t *, const scf_instance_t *,
544 531 const scf_snapshot_t *, const char *);
545 532 int scf_iter_snaplevel_pgs(scf_iter_t *, const scf_snaplevel_t *);
546 533 int scf_iter_snaplevel_pgs_typed(scf_iter_t *, const scf_snaplevel_t *,
547 534 const char *);
548 535 int scf_iter_instance_snapshots(scf_iter_t *, const scf_instance_t *);
549 536 int scf_iter_pg_properties(scf_iter_t *, const scf_propertygroup_t *);
550 537 int scf_iter_property_values(scf_iter_t *, const scf_property_t *);
551 538
552 539 int scf_iter_next_scope(scf_iter_t *, scf_scope_t *);
553 540 int scf_iter_next_service(scf_iter_t *, scf_service_t *);
554 541 int scf_iter_next_instance(scf_iter_t *, scf_instance_t *);
555 542 int scf_iter_next_pg(scf_iter_t *, scf_propertygroup_t *);
556 543 int scf_iter_next_property(scf_iter_t *, scf_property_t *);
557 544 int scf_iter_next_snapshot(scf_iter_t *, scf_snapshot_t *);
558 545 int scf_iter_next_value(scf_iter_t *, scf_value_t *);
559 546
560 547 scf_scope_t *scf_scope_create(scf_handle_t *);
561 548 scf_handle_t *scf_scope_handle(const scf_scope_t *);
562 549
563 550 /* XXX eventually remove this */
564 551 #define scf_handle_get_local_scope(h, s) \
565 552 scf_handle_get_scope((h), SCF_SCOPE_LOCAL, (s))
566 553
567 554 int scf_handle_get_scope(scf_handle_t *, const char *, scf_scope_t *);
568 555 void scf_scope_destroy(scf_scope_t *);
569 556 ssize_t scf_scope_get_name(const scf_scope_t *, char *, size_t);
570 557
571 558 ssize_t scf_scope_to_fmri(const scf_scope_t *, char *, size_t);
572 559
573 560 scf_service_t *scf_service_create(scf_handle_t *);
574 561 scf_handle_t *scf_service_handle(const scf_service_t *);
575 562 void scf_service_destroy(scf_service_t *);
576 563 int scf_scope_get_parent(const scf_scope_t *, scf_scope_t *);
577 564 ssize_t scf_service_get_name(const scf_service_t *, char *, size_t);
578 565 ssize_t scf_service_to_fmri(const scf_service_t *, char *, size_t);
579 566 int scf_service_get_parent(const scf_service_t *, scf_scope_t *);
580 567 int scf_scope_get_service(const scf_scope_t *, const char *, scf_service_t *);
581 568 int scf_scope_add_service(const scf_scope_t *, const char *, scf_service_t *);
582 569 int scf_service_delete(scf_service_t *);
583 570
584 571 scf_instance_t *scf_instance_create(scf_handle_t *);
585 572 scf_handle_t *scf_instance_handle(const scf_instance_t *);
586 573 void scf_instance_destroy(scf_instance_t *);
587 574 ssize_t scf_instance_get_name(const scf_instance_t *, char *, size_t);
588 575 ssize_t scf_instance_to_fmri(const scf_instance_t *, char *, size_t);
589 576 int scf_service_get_instance(const scf_service_t *, const char *,
590 577 scf_instance_t *);
591 578 int scf_service_add_instance(const scf_service_t *, const char *,
592 579 scf_instance_t *);
593 580 int scf_instance_delete(scf_instance_t *);
594 581
595 582 scf_snapshot_t *scf_snapshot_create(scf_handle_t *);
596 583 scf_handle_t *scf_snapshot_handle(const scf_snapshot_t *);
597 584 void scf_snapshot_destroy(scf_snapshot_t *);
598 585 ssize_t scf_snapshot_get_name(const scf_snapshot_t *, char *, size_t);
599 586 int scf_snapshot_get_parent(const scf_snapshot_t *, scf_instance_t *);
600 587 int scf_instance_get_snapshot(const scf_instance_t *, const char *,
601 588 scf_snapshot_t *);
602 589 int scf_snapshot_update(scf_snapshot_t *);
603 590
604 591 scf_snaplevel_t *scf_snaplevel_create(scf_handle_t *);
605 592 scf_handle_t *scf_snaplevel_handle(const scf_snaplevel_t *);
606 593 void scf_snaplevel_destroy(scf_snaplevel_t *);
607 594 int scf_snaplevel_get_parent(const scf_snaplevel_t *, scf_snapshot_t *);
608 595 ssize_t scf_snaplevel_get_scope_name(const scf_snaplevel_t *, char *, size_t);
609 596 ssize_t scf_snaplevel_get_service_name(const scf_snaplevel_t *, char *, size_t);
610 597 ssize_t scf_snaplevel_get_instance_name(const scf_snaplevel_t *, char *,
611 598 size_t);
612 599 int scf_snaplevel_get_pg(const scf_snaplevel_t *, const char *,
613 600 scf_propertygroup_t *pg);
614 601 int scf_snapshot_get_base_snaplevel(const scf_snapshot_t *, scf_snaplevel_t *);
615 602 int scf_snaplevel_get_next_snaplevel(const scf_snaplevel_t *,
616 603 scf_snaplevel_t *);
617 604
618 605 scf_propertygroup_t *scf_pg_create(scf_handle_t *);
619 606 scf_handle_t *scf_pg_handle(const scf_propertygroup_t *);
620 607 void scf_pg_destroy(scf_propertygroup_t *);
621 608 ssize_t scf_pg_to_fmri(const scf_propertygroup_t *, char *, size_t);
622 609 ssize_t scf_pg_get_name(const scf_propertygroup_t *, char *, size_t);
623 610 ssize_t scf_pg_get_type(const scf_propertygroup_t *, char *, size_t);
624 611 int scf_pg_get_flags(const scf_propertygroup_t *, uint32_t *);
625 612 int scf_pg_get_parent_service(const scf_propertygroup_t *, scf_service_t *);
626 613 int scf_pg_get_parent_instance(const scf_propertygroup_t *, scf_instance_t *);
627 614 int scf_pg_get_parent_snaplevel(const scf_propertygroup_t *, scf_snaplevel_t *);
628 615 int scf_service_get_pg(const scf_service_t *, const char *,
629 616 scf_propertygroup_t *);
630 617 int scf_instance_get_pg(const scf_instance_t *, const char *,
631 618 scf_propertygroup_t *);
632 619 int scf_instance_get_pg_composed(const scf_instance_t *, const scf_snapshot_t *,
633 620 const char *, scf_propertygroup_t *);
634 621 int scf_service_add_pg(const scf_service_t *, const char *, const char *,
635 622 uint32_t, scf_propertygroup_t *);
636 623 int scf_instance_add_pg(const scf_instance_t *, const char *, const char *,
637 624 uint32_t, scf_propertygroup_t *);
638 625 int scf_pg_delete(scf_propertygroup_t *);
639 626
640 627 int scf_pg_get_underlying_pg(const scf_propertygroup_t *,
641 628 scf_propertygroup_t *);
642 629 int scf_instance_get_parent(const scf_instance_t *, scf_service_t *);
643 630
644 631 int scf_pg_update(scf_propertygroup_t *);
645 632
646 633 scf_property_t *scf_property_create(scf_handle_t *);
647 634 scf_handle_t *scf_property_handle(const scf_property_t *);
648 635 void scf_property_destroy(scf_property_t *);
649 636 int scf_property_is_type(const scf_property_t *, scf_type_t);
650 637 int scf_property_type(const scf_property_t *, scf_type_t *);
651 638 ssize_t scf_property_get_name(const scf_property_t *, char *, size_t);
652 639 int scf_property_get_value(const scf_property_t *, scf_value_t *);
653 640 ssize_t scf_property_to_fmri(const scf_property_t *, char *, size_t);
654 641 int scf_pg_get_property(const scf_propertygroup_t *, const char *,
655 642 scf_property_t *);
656 643
657 644 scf_transaction_t *scf_transaction_create(scf_handle_t *);
658 645 scf_handle_t *scf_transaction_handle(const scf_transaction_t *);
659 646 int scf_transaction_start(scf_transaction_t *, scf_propertygroup_t *);
660 647 void scf_transaction_destroy(scf_transaction_t *);
661 648 void scf_transaction_destroy_children(scf_transaction_t *);
662 649
663 650 void scf_transaction_reset(scf_transaction_t *);
664 651 void scf_transaction_reset_all(scf_transaction_t *);
665 652
666 653 int scf_transaction_commit(scf_transaction_t *);
667 654
668 655 scf_transaction_entry_t *scf_entry_create(scf_handle_t *);
669 656 scf_handle_t *scf_entry_handle(const scf_transaction_entry_t *);
670 657 void scf_entry_reset(scf_transaction_entry_t *);
671 658 void scf_entry_destroy(scf_transaction_entry_t *);
672 659 void scf_entry_destroy_children(scf_transaction_entry_t *);
673 660
674 661 int scf_transaction_property_change(scf_transaction_t *,
675 662 scf_transaction_entry_t *, const char *, scf_type_t);
676 663 int scf_transaction_property_delete(scf_transaction_t *,
677 664 scf_transaction_entry_t *, const char *);
678 665 int scf_transaction_property_new(scf_transaction_t *,
679 666 scf_transaction_entry_t *, const char *, scf_type_t);
680 667 int scf_transaction_property_change_type(scf_transaction_t *,
681 668 scf_transaction_entry_t *, const char *, scf_type_t);
682 669
683 670 int scf_entry_add_value(scf_transaction_entry_t *, scf_value_t *);
684 671
685 672 int scf_handle_decode_fmri(scf_handle_t *, const char *, scf_scope_t *,
686 673 scf_service_t *, scf_instance_t *, scf_propertygroup_t *, scf_property_t *,
687 674 int);
688 675 #define SCF_DECODE_FMRI_EXACT 0x00000001
689 676 #define SCF_DECODE_FMRI_TRUNCATE 0x00000002
690 677 #define SCF_DECODE_FMRI_REQUIRE_INSTANCE 0x00000004
691 678 #define SCF_DECODE_FMRI_REQUIRE_NO_INSTANCE 0x00000008
692 679
693 680 ssize_t scf_myname(scf_handle_t *, char *, size_t);
694 681
695 682 /*
696 683 * Property group template interfaces.
697 684 */
698 685 scf_pg_tmpl_t *scf_tmpl_pg_create(scf_handle_t *);
699 686 void scf_tmpl_pg_destroy(scf_pg_tmpl_t *);
700 687 void scf_tmpl_pg_reset(scf_pg_tmpl_t *);
701 688 int scf_tmpl_get_by_pg(scf_propertygroup_t *, scf_pg_tmpl_t *, int);
702 689 int scf_tmpl_get_by_pg_name(const char *, const char *,
703 690 const char *, const char *, scf_pg_tmpl_t *, int);
704 691 int scf_tmpl_iter_pgs(scf_pg_tmpl_t *, const char *, const char *,
705 692 const char *, int);
706 693 #define SCF_PG_TMPL_FLAG_REQUIRED 0x1
707 694 #define SCF_PG_TMPL_FLAG_EXACT 0x2
708 695 #define SCF_PG_TMPL_FLAG_CURRENT 0x4
709 696
710 697 ssize_t scf_tmpl_pg_name(const scf_pg_tmpl_t *, char **);
711 698 ssize_t scf_tmpl_pg_common_name(const scf_pg_tmpl_t *, const char *, char **);
712 699 ssize_t scf_tmpl_pg_description(const scf_pg_tmpl_t *, const char *, char **);
713 700 ssize_t scf_tmpl_pg_type(const scf_pg_tmpl_t *, char **);
714 701
715 702 ssize_t scf_tmpl_pg_target(const scf_pg_tmpl_t *, char **);
716 703 #define SCF_TM_TARGET_ALL ((const char *)"all")
717 704 #define SCF_TM_TARGET_DELEGATE ((const char *)"delegate")
718 705 #define SCF_TM_TARGET_INSTANCE ((const char *)"instance")
719 706 #define SCF_TM_TARGET_THIS ((const char *)"this")
720 707
721 708 int scf_tmpl_pg_required(const scf_pg_tmpl_t *, uint8_t *);
722 709
723 710 /*
724 711 * Property template interfaces.
725 712 */
726 713 scf_prop_tmpl_t *scf_tmpl_prop_create(scf_handle_t *);
727 714 void scf_tmpl_prop_destroy(scf_prop_tmpl_t *);
728 715 void scf_tmpl_prop_reset(scf_prop_tmpl_t *);
729 716 int scf_tmpl_get_by_prop(scf_pg_tmpl_t *, const char *,
730 717 scf_prop_tmpl_t *, int);
731 718 int scf_tmpl_iter_props(scf_pg_tmpl_t *, scf_prop_tmpl_t *, int);
732 719 #define SCF_PROP_TMPL_FLAG_REQUIRED 0x1
733 720
734 721 ssize_t scf_tmpl_prop_name(const scf_prop_tmpl_t *, char **);
735 722 int scf_tmpl_prop_type(const scf_prop_tmpl_t *, scf_type_t *);
736 723 int scf_tmpl_prop_required(const scf_prop_tmpl_t *, uint8_t *);
737 724 ssize_t scf_tmpl_prop_common_name(const scf_prop_tmpl_t *, const char *,
738 725 char **);
739 726 ssize_t scf_tmpl_prop_description(const scf_prop_tmpl_t *, const char *,
740 727 char **);
741 728 ssize_t scf_tmpl_prop_units(const scf_prop_tmpl_t *, const char *, char **);
742 729 int scf_tmpl_prop_cardinality(const scf_prop_tmpl_t *prop, uint64_t *,
743 730 uint64_t *);
744 731 int scf_tmpl_prop_internal_seps(const scf_prop_tmpl_t *, scf_values_t *);
745 732
746 733 int scf_tmpl_prop_visibility(const scf_prop_tmpl_t *, uint8_t *);
747 734 #define SCF_TMPL_VISIBILITY_HIDDEN 1
748 735 #define SCF_TMPL_VISIBILITY_READONLY 2
749 736 #define SCF_TMPL_VISIBILITY_READWRITE 3
750 737
751 738 const char *scf_tmpl_visibility_to_string(uint8_t);
752 739 #define SCF_TM_VISIBILITY_HIDDEN ((const char *)"hidden")
753 740 #define SCF_TM_VISIBILITY_READONLY ((const char *)"readonly")
754 741 #define SCF_TM_VISIBILITY_READWRITE ((const char *)"readwrite")
755 742
756 743 int scf_tmpl_value_name_constraints(const scf_prop_tmpl_t *prop,
757 744 scf_values_t *vals);
758 745 void scf_count_ranges_destroy(scf_count_ranges_t *);
759 746 void scf_int_ranges_destroy(scf_int_ranges_t *);
760 747 int scf_tmpl_value_count_range_constraints(const scf_prop_tmpl_t *,
761 748 scf_count_ranges_t *);
762 749 int scf_tmpl_value_int_range_constraints(const scf_prop_tmpl_t *,
763 750 scf_int_ranges_t *);
764 751 int scf_tmpl_value_count_range_choices(const scf_prop_tmpl_t *,
765 752 scf_count_ranges_t *);
766 753 int scf_tmpl_value_int_range_choices(const scf_prop_tmpl_t *,
767 754 scf_int_ranges_t *);
768 755 int scf_tmpl_value_name_choices(const scf_prop_tmpl_t *prop,
769 756 scf_values_t *vals);
770 757
771 758 void scf_values_destroy(scf_values_t *);
772 759
773 760 ssize_t scf_tmpl_value_common_name(const scf_prop_tmpl_t *, const char *,
774 761 const char *, char **);
775 762 ssize_t scf_tmpl_value_description(const scf_prop_tmpl_t *, const char *,
776 763 const char *, char **);
777 764
778 765 int scf_tmpl_value_in_constraint(const scf_prop_tmpl_t *pt, scf_value_t *value,
779 766 scf_tmpl_errors_t **errs);
780 767
781 768 /*
782 769 * Template validation interfaces
783 770 */
784 771 int scf_tmpl_validate_fmri(scf_handle_t *, const char *,
785 772 const char *, scf_tmpl_errors_t **, int);
786 773 #define SCF_TMPL_VALIDATE_FLAG_CURRENT 0x1
787 774
788 775 void scf_tmpl_errors_destroy(scf_tmpl_errors_t *errs);
789 776 scf_tmpl_error_t *scf_tmpl_next_error(scf_tmpl_errors_t *);
790 777 void scf_tmpl_reset_errors(scf_tmpl_errors_t *errs);
791 778 int scf_tmpl_strerror(scf_tmpl_error_t *err, char *s, size_t n, int flag);
792 779 int scf_tmpl_error_source_fmri(const scf_tmpl_error_t *, char **);
793 780 int scf_tmpl_error_type(const scf_tmpl_error_t *, scf_tmpl_error_type_t *);
794 781 int scf_tmpl_error_pg_tmpl(const scf_tmpl_error_t *, char **, char **);
795 782 int scf_tmpl_error_pg(const scf_tmpl_error_t *, char **, char **);
796 783 int scf_tmpl_error_prop_tmpl(const scf_tmpl_error_t *, char **, char **);
797 784 int scf_tmpl_error_prop(const scf_tmpl_error_t *, char **, char **);
798 785 int scf_tmpl_error_value(const scf_tmpl_error_t *, char **);
799 786
800 787 /*
801 788 * Simplified calls
802 789 */
803 790 int smf_enable_instance(const char *, int);
804 791 int smf_disable_instance(const char *, int);
805 792 int smf_refresh_instance(const char *);
806 793 int smf_restart_instance(const char *);
807 794 int smf_maintain_instance(const char *, int);
808 795 int smf_degrade_instance(const char *, int);
809 796 int smf_restore_instance(const char *);
810 797 char *smf_get_state(const char *);
811 798
812 799 int scf_simple_walk_instances(uint_t, void *,
813 800 int (*inst_callback)(scf_handle_t *, scf_instance_t *, void *));
814 801
815 802 scf_simple_prop_t *scf_simple_prop_get(scf_handle_t *, const char *,
816 803 const char *, const char *);
817 804 void scf_simple_prop_free(scf_simple_prop_t *);
818 805 scf_simple_app_props_t *scf_simple_app_props_get(scf_handle_t *, const char *);
819 806 void scf_simple_app_props_free(scf_simple_app_props_t *);
820 807 const scf_simple_prop_t *scf_simple_app_props_next(
821 808 const scf_simple_app_props_t *, scf_simple_prop_t *);
822 809 const scf_simple_prop_t *scf_simple_app_props_search(
823 810 const scf_simple_app_props_t *, const char *, const char *);
824 811 ssize_t scf_simple_prop_numvalues(const scf_simple_prop_t *);
825 812 scf_type_t scf_simple_prop_type(const scf_simple_prop_t *);
826 813 char *scf_simple_prop_name(const scf_simple_prop_t *);
827 814 char *scf_simple_prop_pgname(const scf_simple_prop_t *);
828 815 uint8_t *scf_simple_prop_next_boolean(scf_simple_prop_t *);
829 816 uint64_t *scf_simple_prop_next_count(scf_simple_prop_t *);
830 817 int64_t *scf_simple_prop_next_integer(scf_simple_prop_t *);
831 818 int64_t *scf_simple_prop_next_time(scf_simple_prop_t *, int32_t *);
832 819 char *scf_simple_prop_next_astring(scf_simple_prop_t *);
833 820 char *scf_simple_prop_next_ustring(scf_simple_prop_t *);
834 821 void *scf_simple_prop_next_opaque(scf_simple_prop_t *, size_t *);
835 822 void scf_simple_prop_next_reset(scf_simple_prop_t *);
836 823
837 824 /*
838 825 * smf_state_from_string()
839 826 * return SCF_STATE_* value for the input
840 827 * -1 on error. String "all" maps to SCF_STATE_ALL macro
841 828 */
842 829 int32_t smf_state_from_string(const char *);
843 830
844 831 /*
845 832 * smf_state_to_string()
846 833 * return SCF_STATE_STRING* value for the input
847 834 * NULL on error.
848 835 */
849 836 const char *smf_state_to_string(int32_t);
850 837
851 838 /*
852 839 * Notification interfaces
853 840 */
854 841 int smf_notify_set_params(const char *, nvlist_t *);
855 842 int smf_notify_get_params(nvlist_t **, nvlist_t *);
856 843 int smf_notify_del_params(const char *, const char *, int32_t);
857 844
858 845 /*
859 846 * SMF exit status definitions
860 847 */
861 848 #define SMF_EXIT_OK 0
862 849 #define SMF_EXIT_ERR_FATAL 95
863 850 #define SMF_EXIT_ERR_CONFIG 96
864 851 #define SMF_EXIT_MON_DEGRADE 97
865 852 #define SMF_EXIT_MON_OFFLINE 98
866 853 #define SMF_EXIT_ERR_NOSMF 99
867 854 #define SMF_EXIT_ERR_PERM 100
868 855
869 856 #ifdef __cplusplus
870 857 }
871 858 #endif
872 859
873 860 #endif /* _LIBSCF_H */
↓ open down ↓ |
401 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX