1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _LIBSCF_H 27 #define _LIBSCF_H 28 29 30 #include <stddef.h> 31 #include <sys/types.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 typedef struct scf_version *scf_version_t; 38 #define SCF_VERSION ((scf_version_t)1UL) 39 40 /* 41 * Opaque structures 42 */ 43 typedef struct scf_handle scf_handle_t; 44 typedef struct scf_scope scf_scope_t; 45 typedef struct scf_service scf_service_t; 46 typedef struct scf_instance scf_instance_t; 47 typedef struct scf_propertygroup scf_propertygroup_t; 48 typedef struct scf_property scf_property_t; 49 50 typedef struct scf_snapshot scf_snapshot_t; 51 typedef struct scf_snaplevel scf_snaplevel_t; 52 53 typedef struct scf_transaction scf_transaction_t; 54 typedef struct scf_transaction_entry scf_transaction_entry_t; 55 typedef struct scf_value scf_value_t; 56 57 typedef struct scf_iter scf_iter_t; 58 59 typedef struct scf_simple_app_props scf_simple_app_props_t; 60 typedef struct scf_simple_prop scf_simple_prop_t; 61 62 /* 63 * Types 64 */ 65 typedef enum { 66 SCF_TYPE_INVALID = 0, 67 68 SCF_TYPE_BOOLEAN, 69 SCF_TYPE_COUNT, 70 SCF_TYPE_INTEGER, 71 SCF_TYPE_TIME, 72 SCF_TYPE_ASTRING, 73 SCF_TYPE_OPAQUE, 74 75 SCF_TYPE_USTRING = 100, 76 77 SCF_TYPE_URI = 200, 78 SCF_TYPE_FMRI, 79 80 SCF_TYPE_HOST = 300, 81 SCF_TYPE_HOSTNAME, 82 SCF_TYPE_NET_ADDR_V4, 83 SCF_TYPE_NET_ADDR_V6 84 } scf_type_t; 85 86 /* 87 * Return codes 88 */ 89 #define SCF_SUCCESS 0 90 #define SCF_COMPLETE 1 91 #define SCF_FAILED -1 92 93 typedef enum scf_error { 94 SCF_ERROR_NONE = 1000, /* no error */ 95 SCF_ERROR_NOT_BOUND, /* handle not bound */ 96 SCF_ERROR_NOT_SET, /* cannot use unset argument */ 97 SCF_ERROR_NOT_FOUND, /* nothing of that name found */ 98 SCF_ERROR_TYPE_MISMATCH, /* type does not match value */ 99 SCF_ERROR_IN_USE, /* cannot modify while in-use */ 100 SCF_ERROR_CONNECTION_BROKEN, /* repository connection gone */ 101 SCF_ERROR_INVALID_ARGUMENT, /* bad argument */ 102 SCF_ERROR_NO_MEMORY, /* no memory available */ 103 SCF_ERROR_CONSTRAINT_VIOLATED, /* required constraint not met */ 104 SCF_ERROR_EXISTS, /* object already exists */ 105 SCF_ERROR_NO_SERVER, /* repository server unavailable */ 106 SCF_ERROR_NO_RESOURCES, /* server has insufficient resources */ 107 SCF_ERROR_PERMISSION_DENIED, /* insufficient privileges for action */ 108 SCF_ERROR_BACKEND_ACCESS, /* backend refused access */ 109 SCF_ERROR_HANDLE_MISMATCH, /* mismatched SCF handles */ 110 SCF_ERROR_HANDLE_DESTROYED, /* object bound to destroyed handle */ 111 SCF_ERROR_VERSION_MISMATCH, /* incompatible SCF version */ 112 SCF_ERROR_BACKEND_READONLY, /* backend is read-only */ 113 SCF_ERROR_DELETED, /* object has been deleted */ 114 115 SCF_ERROR_CALLBACK_FAILED = 1080, /* user callback function failed */ 116 117 SCF_ERROR_INTERNAL = 1101 /* internal error */ 118 } scf_error_t; 119 120 /* 121 * Standard services 122 */ 123 #define SCF_SERVICE_STARTD ((const char *) \ 124 "svc:/system/svc/restarter:default") 125 #define SCF_SERVICE_CONFIGD ((const char *) \ 126 "svc:/system/svc/repository:default") 127 128 /* 129 * Major milestones 130 */ 131 #define SCF_MILESTONE_SINGLE_USER \ 132 ((const char *) "svc:/milestone/single-user:default") 133 #define SCF_MILESTONE_MULTI_USER \ 134 ((const char *) "svc:/milestone/multi-user:default") 135 #define SCF_MILESTONE_MULTI_USER_SERVER \ 136 ((const char *) "svc:/milestone/multi-user-server:default") 137 138 /* 139 * standard scope names 140 */ 141 #define SCF_SCOPE_LOCAL ((const char *)"localhost") 142 143 /* 144 * Property group types 145 */ 146 #define SCF_GROUP_APPLICATION ((const char *)"application") 147 #define SCF_GROUP_FRAMEWORK ((const char *)"framework") 148 #define SCF_GROUP_DEPENDENCY ((const char *)"dependency") 149 #define SCF_GROUP_METHOD ((const char *)"method") 150 #define SCF_GROUP_TEMPLATE ((const char *)"template") 151 152 /* 153 * Dependency types 154 */ 155 #define SCF_DEP_REQUIRE_ALL ((const char *)"require_all") 156 #define SCF_DEP_REQUIRE_ANY ((const char *)"require_any") 157 #define SCF_DEP_EXCLUDE_ALL ((const char *)"exclude_all") 158 #define SCF_DEP_OPTIONAL_ALL ((const char *)"optional_all") 159 160 #define SCF_DEP_RESET_ON_ERROR ((const char *)"error") 161 #define SCF_DEP_RESET_ON_RESTART ((const char *)"restart") 162 #define SCF_DEP_RESET_ON_REFRESH ((const char *)"refresh") 163 #define SCF_DEP_RESET_ON_NONE ((const char *)"none") 164 165 /* 166 * Standard property group names 167 */ 168 #define SCF_PG_GENERAL ((const char *)"general") 169 #define SCF_PG_GENERAL_OVR ((const char *)"general_ovr") 170 #define SCF_PG_RESTARTER ((const char *)"restarter") 171 #define SCF_PG_RESTARTER_ACTIONS ((const char *)"restarter_actions") 172 #define SCF_PG_METHOD_CONTEXT ((const char *)"method_context") 173 #define SCF_PG_APP_DEFAULT ((const char *)"application") 174 #define SCF_PG_DEPENDENTS ((const char *)"dependents") 175 #define SCF_PG_OPTIONS ((const char *)"options") 176 #define SCF_PG_OPTIONS_OVR ((const char *)"options_ovr") 177 #define SCF_PG_STARTD ((const char *)"startd") 178 #define SCF_PG_STARTD_PRIVATE ((const char *)"svc-startd-private") 179 #define SCF_PG_DEATHROW ((const char *)"deathrow") 180 181 /* 182 * Template property group names and prefix 183 */ 184 #define SCF_PG_TM_COMMON_NAME ((const char *)"tm_common_name") 185 #define SCF_PG_TM_DESCRIPTION ((const char *)"tm_description") 186 187 #define SCF_PG_TM_MAN_PREFIX ((const char *)"tm_man_") 188 #define SCF_PG_TM_DOC_PREFIX ((const char *)"tm_doc_") 189 190 /* 191 * Standard property names 192 */ 193 #define SCF_PROPERTY_AUX_STATE ((const char *)"auxiliary_state") 194 #define SCF_PROPERTY_CONTRACT ((const char *)"contract") 195 #define SCF_PROPERTY_COREFILE_PATTERN ((const char *)"corefile_pattern") 196 #define SCF_PROPERTY_DEGRADED ((const char *)"degraded") 197 #define SCF_PROPERTY_DEGRADE_IMMEDIATE ((const char *)"degrade_immediate") 198 #define SCF_PROPERTY_DURATION ((const char *)"duration") 199 #define SCF_PROPERTY_ENABLED ((const char *)"enabled") 200 #define SCF_PROPERTY_DEATHROW ((const char *)"deathrow") 201 #define SCF_PROPERTY_ENTITY_STABILITY ((const char *)"entity_stability") 202 #define SCF_PROPERTY_ENTITIES ((const char *)"entities") 203 #define SCF_PROPERTY_EXEC ((const char *)"exec") 204 #define SCF_PROPERTY_GROUP ((const char *)"group") 205 #define SCF_PROPERTY_GROUPING ((const char *)"grouping") 206 #define SCF_PROPERTY_IGNORE ((const char *)"ignore_error") 207 #define SCF_PROPERTY_LIMIT_PRIVILEGES ((const char *)"limit_privileges") 208 #define SCF_PROPERTY_MAINT_OFF ((const char *)"maint_off") 209 #define SCF_PROPERTY_MAINT_ON ((const char *)"maint_on") 210 #define SCF_PROPERTY_MAINT_ON_IMMEDIATE ((const char *)"maint_on_immediate") 211 #define SCF_PROPERTY_MAINT_ON_IMMTEMP ((const char *)"maint_on_immtemp") 212 #define SCF_PROPERTY_MAINT_ON_TEMPORARY ((const char *)"maint_on_temporary") 213 #define SCF_PROPERTY_METHOD_PID ((const char *)"method_pid") 214 #define SCF_PROPERTY_MILESTONE ((const char *)"milestone") 215 #define SCF_PROPERTY_NEED_SESSION ((const char *)"need_session") 216 #define SCF_PROPERTY_NEXT_STATE ((const char *)"next_state") 217 #define SCF_PROPERTY_PACKAGE ((const char *)"package") 218 #define SCF_PROPERTY_PRIVILEGES ((const char *)"privileges") 219 #define SCF_PROPERTY_PROFILE ((const char *)"profile") 220 #define SCF_PROPERTY_PROJECT ((const char *)"project") 221 #define SCF_PROPERTY_REFRESH ((const char *)"refresh") 222 #define SCF_PROPERTY_RESOURCE_POOL ((const char *)"resource_pool") 223 #define SCF_PROPERTY_ENVIRONMENT ((const char *)"environment") 224 #define SCF_PROPERTY_RESTART ((const char *)"restart") 225 #define SCF_PROPERTY_RESTARTER ((const char *)"restarter") 226 #define SCF_PROPERTY_RESTART_INTERVAL ((const char *)"restart_interval") 227 #define SCF_PROPERTY_RESTART_ON ((const char *)"restart_on") 228 #define SCF_PROPERTY_RESTORE ((const char *)"restore") 229 #define SCF_PROPERTY_SINGLE_INSTANCE ((const char *)"single_instance") 230 #define SCF_PROPERTY_START_METHOD_TIMESTAMP \ 231 ((const char *)"start_method_timestamp") 232 #define SCF_PROPERTY_START_METHOD_WAITSTATUS \ 233 ((const char *)"start_method_waitstatus") 234 #define SCF_PROPERTY_START_PID ((const char *)"start_pid") 235 #define SCF_PROPERTY_STATE ((const char *)"state") 236 #define SCF_PROPERTY_STABILITY ((const char *)"stability") 237 #define SCF_PROPERTY_STATE_TIMESTAMP ((const char *)"state_timestamp") 238 #define SCF_PROPERTY_SUPP_GROUPS ((const char *)"supp_groups") 239 #define SCF_PROPERTY_TIMEOUT ((const char *)"timeout_seconds") 240 #define SCF_PROPERTY_TIMEOUT_RETRY ((const char *)"timeout_retry") 241 #define SCF_PROPERTY_TRANSIENT_CONTRACT ((const char *)"transient_contract") 242 #define SCF_PROPERTY_TYPE ((const char *)"type") 243 #define SCF_PROPERTY_USE_PROFILE ((const char *)"use_profile") 244 #define SCF_PROPERTY_USER ((const char *)"user") 245 #define SCF_PROPERTY_UTMPX_PREFIX ((const char *)"utmpx_prefix") 246 #define SCF_PROPERTY_WORKING_DIRECTORY ((const char *)"working_directory") 247 248 /* 249 * Template property names 250 */ 251 #define SCF_PROPERTY_TM_MANPATH ((const char *)"manpath") 252 #define SCF_PROPERTY_TM_SECTION ((const char *)"section") 253 #define SCF_PROPERTY_TM_TITLE ((const char *)"title") 254 #define SCF_PROPERTY_TM_NAME ((const char *)"name") 255 #define SCF_PROPERTY_TM_URI ((const char *)"uri") 256 257 /* 258 * Strings used by restarters for state and next_state properties. 259 * MAX_SCF_STATE_STRING holds the max length of a state string, including the 260 * terminating null. 261 */ 262 263 #define MAX_SCF_STATE_STRING_SZ 14 264 265 #define SCF_STATE_STRING_NONE ((const char *)"none") 266 #define SCF_STATE_STRING_UNINIT ((const char *)"uninitialized") 267 #define SCF_STATE_STRING_MAINT ((const char *)"maintenance") 268 #define SCF_STATE_STRING_OFFLINE ((const char *)"offline") 269 #define SCF_STATE_STRING_DISABLED ((const char *)"disabled") 270 #define SCF_STATE_STRING_ONLINE ((const char *)"online") 271 #define SCF_STATE_STRING_DEGRADED ((const char *)"degraded") 272 #define SCF_STATE_STRING_LEGACY ((const char *)"legacy_run") 273 274 #define SCF_STATE_UNINIT 0x00000001 275 #define SCF_STATE_MAINT 0x00000002 276 #define SCF_STATE_OFFLINE 0x00000004 277 #define SCF_STATE_DISABLED 0x00000008 278 #define SCF_STATE_ONLINE 0x00000010 279 #define SCF_STATE_DEGRADED 0x00000020 280 #define SCF_STATE_ALL 0x0000003F 281 282 #define SCF_PG_FLAG_NONPERSISTENT 0x1 283 284 #define SCF_TRACE_LIBRARY 0x1 285 #define SCF_TRACE_DAEMON 0x2 286 287 #define SMF_IMMEDIATE 0x1 288 #define SMF_TEMPORARY 0x2 289 #define SMF_AT_NEXT_BOOT 0x4 290 291 scf_error_t scf_error(void); 292 const char *scf_strerror(scf_error_t); 293 294 ssize_t scf_limit(uint32_t code); 295 #define SCF_LIMIT_MAX_NAME_LENGTH -2000U 296 #define SCF_LIMIT_MAX_VALUE_LENGTH -2001U 297 #define SCF_LIMIT_MAX_PG_TYPE_LENGTH -2002U 298 #define SCF_LIMIT_MAX_FMRI_LENGTH -2003U 299 300 scf_handle_t *scf_handle_create(scf_version_t); 301 302 int scf_handle_decorate(scf_handle_t *, const char *, scf_value_t *); 303 #define SCF_DECORATE_CLEAR ((scf_value_t *)0) 304 305 int scf_handle_bind(scf_handle_t *); 306 int scf_handle_unbind(scf_handle_t *); 307 void scf_handle_destroy(scf_handle_t *); 308 309 int scf_type_base_type(scf_type_t type, scf_type_t *out); 310 311 /* values */ 312 scf_value_t *scf_value_create(scf_handle_t *); 313 scf_handle_t *scf_value_handle(const scf_value_t *); 314 void scf_value_destroy(scf_value_t *); 315 316 scf_type_t scf_value_base_type(const scf_value_t *); 317 scf_type_t scf_value_type(const scf_value_t *); 318 int scf_value_is_type(const scf_value_t *, scf_type_t); 319 320 void scf_value_reset(scf_value_t *); 321 322 int scf_value_get_boolean(const scf_value_t *, uint8_t *); 323 int scf_value_get_count(const scf_value_t *, uint64_t *); 324 int scf_value_get_integer(const scf_value_t *, int64_t *); 325 int scf_value_get_time(const scf_value_t *, int64_t *, int32_t *); 326 ssize_t scf_value_get_astring(const scf_value_t *, char *, size_t); 327 ssize_t scf_value_get_ustring(const scf_value_t *, char *, size_t); 328 ssize_t scf_value_get_opaque(const scf_value_t *, void *, size_t); 329 330 void scf_value_set_boolean(scf_value_t *, uint8_t); 331 void scf_value_set_count(scf_value_t *, uint64_t); 332 void scf_value_set_integer(scf_value_t *, int64_t); 333 int scf_value_set_time(scf_value_t *, int64_t, int32_t); 334 int scf_value_set_astring(scf_value_t *, const char *); 335 int scf_value_set_ustring(scf_value_t *, const char *); 336 int scf_value_set_opaque(scf_value_t *, const void *, size_t); 337 338 ssize_t scf_value_get_as_string(const scf_value_t *, char *, size_t); 339 ssize_t scf_value_get_as_string_typed(const scf_value_t *, scf_type_t, 340 char *, size_t); 341 int scf_value_set_from_string(scf_value_t *, scf_type_t, const char *); 342 343 scf_iter_t *scf_iter_create(scf_handle_t *); 344 scf_handle_t *scf_iter_handle(const scf_iter_t *); 345 void scf_iter_reset(scf_iter_t *); 346 void scf_iter_destroy(scf_iter_t *); 347 348 int scf_iter_handle_scopes(scf_iter_t *, const scf_handle_t *); 349 int scf_iter_scope_services(scf_iter_t *, const scf_scope_t *); 350 int scf_iter_service_instances(scf_iter_t *, const scf_service_t *); 351 int scf_iter_service_pgs(scf_iter_t *, const scf_service_t *); 352 int scf_iter_instance_pgs(scf_iter_t *, const scf_instance_t *); 353 int scf_iter_instance_pgs_composed(scf_iter_t *, const scf_instance_t *, 354 const scf_snapshot_t *); 355 int scf_iter_service_pgs_typed(scf_iter_t *, const scf_service_t *, 356 const char *); 357 int scf_iter_instance_pgs_typed(scf_iter_t *, const scf_instance_t *, 358 const char *); 359 int scf_iter_instance_pgs_typed_composed(scf_iter_t *, const scf_instance_t *, 360 const scf_snapshot_t *, const char *); 361 int scf_iter_snaplevel_pgs(scf_iter_t *, const scf_snaplevel_t *); 362 int scf_iter_snaplevel_pgs_typed(scf_iter_t *, const scf_snaplevel_t *, 363 const char *); 364 int scf_iter_instance_snapshots(scf_iter_t *, const scf_instance_t *); 365 int scf_iter_pg_properties(scf_iter_t *, const scf_propertygroup_t *); 366 int scf_iter_property_values(scf_iter_t *, const scf_property_t *); 367 368 int scf_iter_next_scope(scf_iter_t *, scf_scope_t *); 369 int scf_iter_next_service(scf_iter_t *, scf_service_t *); 370 int scf_iter_next_instance(scf_iter_t *, scf_instance_t *); 371 int scf_iter_next_pg(scf_iter_t *, scf_propertygroup_t *); 372 int scf_iter_next_property(scf_iter_t *, scf_property_t *); 373 int scf_iter_next_snapshot(scf_iter_t *, scf_snapshot_t *); 374 int scf_iter_next_value(scf_iter_t *, scf_value_t *); 375 376 scf_scope_t *scf_scope_create(scf_handle_t *); 377 scf_handle_t *scf_scope_handle(const scf_scope_t *); 378 379 /* XXX eventually remove this */ 380 #define scf_handle_get_local_scope(h, s) \ 381 scf_handle_get_scope((h), SCF_SCOPE_LOCAL, (s)) 382 383 int scf_handle_get_scope(scf_handle_t *, const char *, scf_scope_t *); 384 void scf_scope_destroy(scf_scope_t *); 385 ssize_t scf_scope_get_name(const scf_scope_t *, char *, size_t); 386 387 ssize_t scf_scope_to_fmri(const scf_scope_t *, char *, size_t); 388 389 scf_service_t *scf_service_create(scf_handle_t *); 390 scf_handle_t *scf_service_handle(const scf_service_t *); 391 void scf_service_destroy(scf_service_t *); 392 int scf_scope_get_parent(const scf_scope_t *, scf_scope_t *); 393 ssize_t scf_service_get_name(const scf_service_t *, char *, size_t); 394 ssize_t scf_service_to_fmri(const scf_service_t *, char *, size_t); 395 int scf_service_get_parent(const scf_service_t *, scf_scope_t *); 396 int scf_scope_get_service(const scf_scope_t *, const char *, scf_service_t *); 397 int scf_scope_add_service(const scf_scope_t *, const char *, scf_service_t *); 398 int scf_service_delete(scf_service_t *); 399 400 scf_instance_t *scf_instance_create(scf_handle_t *); 401 scf_handle_t *scf_instance_handle(const scf_instance_t *); 402 void scf_instance_destroy(scf_instance_t *); 403 ssize_t scf_instance_get_name(const scf_instance_t *, char *, size_t); 404 ssize_t scf_instance_to_fmri(const scf_instance_t *, char *, size_t); 405 int scf_service_get_instance(const scf_service_t *, const char *, 406 scf_instance_t *); 407 int scf_service_add_instance(const scf_service_t *, const char *, 408 scf_instance_t *); 409 int scf_instance_delete(scf_instance_t *); 410 411 scf_snapshot_t *scf_snapshot_create(scf_handle_t *); 412 scf_handle_t *scf_snapshot_handle(const scf_snapshot_t *); 413 void scf_snapshot_destroy(scf_snapshot_t *); 414 ssize_t scf_snapshot_get_name(const scf_snapshot_t *, char *, size_t); 415 int scf_snapshot_get_parent(const scf_snapshot_t *, scf_instance_t *); 416 int scf_instance_get_snapshot(const scf_instance_t *, const char *, 417 scf_snapshot_t *); 418 int scf_snapshot_update(scf_snapshot_t *); 419 420 scf_snaplevel_t *scf_snaplevel_create(scf_handle_t *); 421 scf_handle_t *scf_snaplevel_handle(const scf_snaplevel_t *); 422 void scf_snaplevel_destroy(scf_snaplevel_t *); 423 int scf_snaplevel_get_parent(const scf_snaplevel_t *, scf_snapshot_t *); 424 ssize_t scf_snaplevel_get_scope_name(const scf_snaplevel_t *, char *, size_t); 425 ssize_t scf_snaplevel_get_service_name(const scf_snaplevel_t *, char *, size_t); 426 ssize_t scf_snaplevel_get_instance_name(const scf_snaplevel_t *, char *, 427 size_t); 428 int scf_snaplevel_get_pg(const scf_snaplevel_t *, const char *, 429 scf_propertygroup_t *pg); 430 int scf_snapshot_get_base_snaplevel(const scf_snapshot_t *, scf_snaplevel_t *); 431 int scf_snaplevel_get_next_snaplevel(const scf_snaplevel_t *, 432 scf_snaplevel_t *); 433 434 scf_propertygroup_t *scf_pg_create(scf_handle_t *); 435 scf_handle_t *scf_pg_handle(const scf_propertygroup_t *); 436 void scf_pg_destroy(scf_propertygroup_t *); 437 ssize_t scf_pg_to_fmri(const scf_propertygroup_t *, char *, size_t); 438 ssize_t scf_pg_get_name(const scf_propertygroup_t *, char *, size_t); 439 ssize_t scf_pg_get_type(const scf_propertygroup_t *, char *, size_t); 440 int scf_pg_get_flags(const scf_propertygroup_t *, uint32_t *); 441 int scf_pg_get_parent_service(const scf_propertygroup_t *, scf_service_t *); 442 int scf_pg_get_parent_instance(const scf_propertygroup_t *, scf_instance_t *); 443 int scf_pg_get_parent_snaplevel(const scf_propertygroup_t *, scf_snaplevel_t *); 444 int scf_service_get_pg(const scf_service_t *, const char *, 445 scf_propertygroup_t *); 446 int scf_instance_get_pg(const scf_instance_t *, const char *, 447 scf_propertygroup_t *); 448 int scf_instance_get_pg_composed(const scf_instance_t *, const scf_snapshot_t *, 449 const char *, scf_propertygroup_t *); 450 int scf_service_add_pg(const scf_service_t *, const char *, const char *, 451 uint32_t, scf_propertygroup_t *); 452 int scf_instance_add_pg(const scf_instance_t *, const char *, const char *, 453 uint32_t, scf_propertygroup_t *); 454 int scf_pg_delete(scf_propertygroup_t *); 455 456 int scf_pg_get_underlying_pg(const scf_propertygroup_t *, 457 scf_propertygroup_t *); 458 int scf_instance_get_parent(const scf_instance_t *, scf_service_t *); 459 460 int scf_pg_update(scf_propertygroup_t *); 461 462 scf_property_t *scf_property_create(scf_handle_t *); 463 scf_handle_t *scf_property_handle(const scf_property_t *); 464 void scf_property_destroy(scf_property_t *); 465 int scf_property_is_type(const scf_property_t *, scf_type_t); 466 int scf_property_type(const scf_property_t *, scf_type_t *); 467 ssize_t scf_property_get_name(const scf_property_t *, char *, size_t); 468 int scf_property_get_value(const scf_property_t *, scf_value_t *); 469 ssize_t scf_property_to_fmri(const scf_property_t *, char *, size_t); 470 int scf_pg_get_property(const scf_propertygroup_t *, const char *, 471 scf_property_t *); 472 473 scf_transaction_t *scf_transaction_create(scf_handle_t *); 474 scf_handle_t *scf_transaction_handle(const scf_transaction_t *); 475 int scf_transaction_start(scf_transaction_t *, scf_propertygroup_t *); 476 void scf_transaction_destroy(scf_transaction_t *); 477 void scf_transaction_destroy_children(scf_transaction_t *); 478 479 void scf_transaction_reset(scf_transaction_t *); 480 void scf_transaction_reset_all(scf_transaction_t *); 481 482 int scf_transaction_commit(scf_transaction_t *); 483 484 scf_transaction_entry_t *scf_entry_create(scf_handle_t *); 485 scf_handle_t *scf_entry_handle(const scf_transaction_entry_t *); 486 void scf_entry_reset(scf_transaction_entry_t *); 487 void scf_entry_destroy(scf_transaction_entry_t *); 488 void scf_entry_destroy_children(scf_transaction_entry_t *); 489 490 int scf_transaction_property_change(scf_transaction_t *, 491 scf_transaction_entry_t *, const char *, scf_type_t); 492 int scf_transaction_property_delete(scf_transaction_t *, 493 scf_transaction_entry_t *, const char *); 494 int scf_transaction_property_new(scf_transaction_t *, 495 scf_transaction_entry_t *, const char *, scf_type_t); 496 int scf_transaction_property_change_type(scf_transaction_t *, 497 scf_transaction_entry_t *, const char *, scf_type_t); 498 499 int scf_entry_add_value(scf_transaction_entry_t *, scf_value_t *); 500 501 int scf_handle_decode_fmri(scf_handle_t *, const char *, scf_scope_t *, 502 scf_service_t *, scf_instance_t *, scf_propertygroup_t *, scf_property_t *, 503 int); 504 #define SCF_DECODE_FMRI_EXACT 0x00000001 505 #define SCF_DECODE_FMRI_TRUNCATE 0x00000002 506 #define SCF_DECODE_FMRI_REQUIRE_INSTANCE 0x00000004 507 #define SCF_DECODE_FMRI_REQUIRE_NO_INSTANCE 0x00000008 508 509 ssize_t scf_myname(scf_handle_t *, char *, size_t); 510 511 /* 512 * Simplified calls 513 */ 514 515 int smf_enable_instance(const char *, int); 516 int smf_disable_instance(const char *, int); 517 int smf_refresh_instance(const char *); 518 int smf_restart_instance(const char *); 519 int smf_maintain_instance(const char *, int); 520 int smf_degrade_instance(const char *, int); 521 int smf_restore_instance(const char *); 522 char *smf_get_state(const char *); 523 524 int scf_simple_walk_instances(uint_t, void *, 525 int (*inst_callback)(scf_handle_t *, scf_instance_t *, void *)); 526 527 scf_simple_prop_t *scf_simple_prop_get(scf_handle_t *, const char *, 528 const char *, const char *); 529 void scf_simple_prop_free(scf_simple_prop_t *); 530 scf_simple_app_props_t *scf_simple_app_props_get(scf_handle_t *, const char *); 531 void scf_simple_app_props_free(scf_simple_app_props_t *); 532 const scf_simple_prop_t *scf_simple_app_props_next( 533 const scf_simple_app_props_t *, scf_simple_prop_t *); 534 const scf_simple_prop_t *scf_simple_app_props_search( 535 const scf_simple_app_props_t *, const char *, const char *); 536 ssize_t scf_simple_prop_numvalues(const scf_simple_prop_t *); 537 scf_type_t scf_simple_prop_type(const scf_simple_prop_t *); 538 char *scf_simple_prop_name(const scf_simple_prop_t *); 539 char *scf_simple_prop_pgname(const scf_simple_prop_t *); 540 uint8_t *scf_simple_prop_next_boolean(scf_simple_prop_t *); 541 uint64_t *scf_simple_prop_next_count(scf_simple_prop_t *); 542 int64_t *scf_simple_prop_next_integer(scf_simple_prop_t *); 543 int64_t *scf_simple_prop_next_time(scf_simple_prop_t *, int32_t *); 544 char *scf_simple_prop_next_astring(scf_simple_prop_t *); 545 char *scf_simple_prop_next_ustring(scf_simple_prop_t *); 546 void *scf_simple_prop_next_opaque(scf_simple_prop_t *, size_t *); 547 void scf_simple_prop_next_reset(scf_simple_prop_t *); 548 549 /* 550 * SMF exit status definitions 551 */ 552 #define SMF_EXIT_OK 0 553 #define SMF_EXIT_ERR_FATAL 95 554 #define SMF_EXIT_ERR_CONFIG 96 555 #define SMF_EXIT_MON_DEGRADE 97 556 #define SMF_EXIT_MON_OFFLINE 98 557 #define SMF_EXIT_ERR_NOSMF 99 558 #define SMF_EXIT_ERR_PERM 100 559 560 #ifdef __cplusplus 561 } 562 #endif 563 564 #endif /* _LIBSCF_H */ 565