libscf.h revision 10461:d59a044cc787
1160681Sjkim/* 240767Sjoerg * CDDL HEADER START 340767Sjoerg * 440767Sjoerg * The contents of this file are subject to the terms of the 540767Sjoerg * Common Development and Distribution License (the "License"). 640767Sjoerg * You may not use this file except in compliance with the License. 740767Sjoerg * 840767Sjoerg * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 940767Sjoerg * or http://www.opensolaris.org/os/licensing. 1040767Sjoerg * See the License for the specific language governing permissions 1140767Sjoerg * and limitations under the License. 1240767Sjoerg * 1399112Sobrien * When distributing Covered Code, include this CDDL HEADER in each 1499112Sobrien * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1578310Seric * If applicable, add the following below this CDDL HEADER, with the 1640769Sjoerg * fields enclosed by brackets "[]" replaced with your own identifying 1740769Sjoerg * information: Portions Copyright [yyyy] [name of copyright owner] 1840769Sjoerg * 1940769Sjoerg * CDDL HEADER END 2040769Sjoerg */ 2140769Sjoerg 2240769Sjoerg/* 2340769Sjoerg * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2440769Sjoerg * Use is subject to license terms. 2540767Sjoerg */ 2640767Sjoerg 2740767Sjoerg#ifndef _LIBSCF_H 28227237Sed#define _LIBSCF_H 29227237Sed 30227237Sed 31227237Sed#include <stddef.h> 32227237Sed#include <sys/types.h> 3340767Sjoerg 34227237Sed#ifdef __cplusplus 35227237Sedextern "C" { 3640767Sjoerg#endif 37227237Sed 38102944Sdwmalonetypedef struct scf_version *scf_version_t; 3940767Sjoerg#define SCF_VERSION ((scf_version_t)1UL) 40120935Stjr 41120935Stjr/* 4278781Sdd * Opaque structures 43160681Sjkim */ 44231994Skevlotypedef struct scf_handle scf_handle_t; 4540767Sjoergtypedef struct scf_scope scf_scope_t; 46120935Stjrtypedef struct scf_service scf_service_t; 47231994Skevlotypedef struct scf_instance scf_instance_t; 48231994Skevlotypedef struct scf_propertygroup scf_propertygroup_t; 49231994Skevlotypedef struct scf_property scf_property_t; 50231994Skevlo 51231994Skevlotypedef struct scf_snapshot scf_snapshot_t; 52231994Skevlotypedef struct scf_snaplevel scf_snaplevel_t; 5340767Sjoerg 5440767Sjoergtypedef struct scf_transaction scf_transaction_t; 5540767Sjoergtypedef struct scf_transaction_entry scf_transaction_entry_t; 5640767Sjoergtypedef struct scf_value scf_value_t; 5740767Sjoerg 5840767Sjoergtypedef struct scf_iter scf_iter_t; 5940767Sjoerg 6040767Sjoergtypedef struct scf_pg_tmpl scf_pg_tmpl_t; 6140767Sjoergtypedef struct scf_prop_tmpl scf_prop_tmpl_t; 6278781Sddtypedef struct scf_tmpl_errors scf_tmpl_errors_t; 6340767Sjoerg 6478781Sddtypedef struct scf_simple_app_props scf_simple_app_props_t; 6578781Sddtypedef struct scf_simple_prop scf_simple_prop_t; 6640767Sjoerg 6740767Sjoerg/* 6840767Sjoerg * Types 6940767Sjoerg */ 7078781Sddtypedef enum { 7140767Sjoerg SCF_TYPE_INVALID = 0, 7240767Sjoerg 7340767Sjoerg SCF_TYPE_BOOLEAN, 7440767Sjoerg SCF_TYPE_COUNT, 7540767Sjoerg SCF_TYPE_INTEGER, 7640767Sjoerg SCF_TYPE_TIME, 7740767Sjoerg SCF_TYPE_ASTRING, 7840767Sjoerg SCF_TYPE_OPAQUE, 7940769Sjoerg 80102944Sdwmalone SCF_TYPE_USTRING = 100, 8140767Sjoerg 82102944Sdwmalone SCF_TYPE_URI = 200, 8340769Sjoerg SCF_TYPE_FMRI, 8440769Sjoerg 8540767Sjoerg SCF_TYPE_HOST = 300, 8640769Sjoerg SCF_TYPE_HOSTNAME, 8740769Sjoerg SCF_TYPE_NET_ADDR_V4, 8840769Sjoerg SCF_TYPE_NET_ADDR_V6 8940769Sjoerg} scf_type_t; 9040769Sjoerg 9140769Sjoergtypedef struct scf_time { 9240769Sjoerg int64_t t_seconds; 9340769Sjoerg int32_t t_ns; 9440769Sjoerg} scf_time_t; 9540769Sjoerg 9640767Sjoerg/* 9740769Sjoerg * There is no explicit initializer for this structure. Functions 9840769Sjoerg * which set or populate this structure assume that it is either 9940769Sjoerg * uninitialized or destroyed. 10040769Sjoerg */ 10140769Sjoergtypedef struct scf_values { 10240769Sjoerg scf_type_t value_type; 10340769Sjoerg void *reserved; /* reserved for future use */ 10440767Sjoerg int value_count; 10540767Sjoerg char **values_as_strings; 10640767Sjoerg union { 10740767Sjoerg uint64_t *v_count; 10840767Sjoerg uint8_t *v_boolean; 10940767Sjoerg int64_t *v_integer; 11040767Sjoerg char **v_astring; 11140767Sjoerg char **v_ustring; 11240769Sjoerg char **v_opaque; 11340767Sjoerg scf_time_t *v_time; 11440767Sjoerg } values; 11540767Sjoerg} scf_values_t; 11640767Sjoerg 11740767Sjoergtypedef struct scf_count_ranges { 11840767Sjoerg int scr_num_ranges; 11940767Sjoerg uint64_t *scr_min; 12040767Sjoerg uint64_t *scr_max; 12140767Sjoerg} scf_count_ranges_t; 12240767Sjoerg 12340767Sjoergtypedef struct scf_int_ranges { 12440767Sjoerg int sir_num_ranges; 12540767Sjoerg int64_t *sir_min; 12640767Sjoerg int64_t *sir_max; 12740767Sjoerg} scf_int_ranges_t; 12840767Sjoerg 12940767Sjoerg/* 13040767Sjoerg * Return codes 13140767Sjoerg */ 13240767Sjoerg#define SCF_SUCCESS 0 13340769Sjoerg#define SCF_COMPLETE 1 13440769Sjoerg#define SCF_FAILED -1 13540767Sjoerg 13640767Sjoergtypedef enum scf_error { 137227237Sed SCF_ERROR_NONE = 1000, /* no error */ 138102944Sdwmalone SCF_ERROR_NOT_BOUND, /* handle not bound */ 13940767Sjoerg SCF_ERROR_NOT_SET, /* cannot use unset argument */ 14040767Sjoerg SCF_ERROR_NOT_FOUND, /* nothing of that name found */ 14178781Sdd SCF_ERROR_TYPE_MISMATCH, /* type does not match value */ 142160681Sjkim SCF_ERROR_IN_USE, /* cannot modify while in-use */ 14340767Sjoerg SCF_ERROR_CONNECTION_BROKEN, /* repository connection gone */ 14440767Sjoerg SCF_ERROR_INVALID_ARGUMENT, /* bad argument */ 14540767Sjoerg SCF_ERROR_NO_MEMORY, /* no memory available */ 14678781Sdd SCF_ERROR_CONSTRAINT_VIOLATED, /* required constraint not met */ 14740767Sjoerg SCF_ERROR_EXISTS, /* object already exists */ 14878781Sdd SCF_ERROR_NO_SERVER, /* repository server unavailable */ 14978781Sdd SCF_ERROR_NO_RESOURCES, /* server has insufficient resources */ 15078781Sdd SCF_ERROR_PERMISSION_DENIED, /* insufficient privileges for action */ 15178781Sdd SCF_ERROR_BACKEND_ACCESS, /* backend refused access */ 15240767Sjoerg SCF_ERROR_HANDLE_MISMATCH, /* mismatched SCF handles */ 15340767Sjoerg SCF_ERROR_HANDLE_DESTROYED, /* object bound to destroyed handle */ 154 SCF_ERROR_VERSION_MISMATCH, /* incompatible SCF version */ 155 SCF_ERROR_BACKEND_READONLY, /* backend is read-only */ 156 SCF_ERROR_DELETED, /* object has been deleted */ 157 SCF_ERROR_TEMPLATE_INVALID, /* template data is invalid */ 158 159 SCF_ERROR_CALLBACK_FAILED = 1080, /* user callback function failed */ 160 161 SCF_ERROR_INTERNAL = 1101 /* internal error */ 162} scf_error_t; 163 164/* 165 * This enum MUST be kept in sync with 166 * struct _scf_tmpl_error_desc em_desc() in scf_tmpl.c 167 */ 168typedef enum scf_tmpl_error_type { 169 SCF_TERR_MISSING_PG, /* property group missing */ 170 SCF_TERR_WRONG_PG_TYPE, /* property group type incorrect */ 171 SCF_TERR_MISSING_PROP, /* missing required property */ 172 SCF_TERR_WRONG_PROP_TYPE, /* property type incorrect */ 173 SCF_TERR_CARDINALITY_VIOLATION, /* wrong number of values */ 174 SCF_TERR_VALUE_CONSTRAINT_VIOLATED, /* constraint violated for value */ 175 SCF_TERR_RANGE_VIOLATION, /* value violated specified range */ 176 SCF_TERR_PG_REDEFINE, /* global or restarter pg_pattern */ 177 /* redefined by the instance */ 178 SCF_TERR_PROP_TYPE_MISMATCH, /* property and value type mismatch */ 179 SCF_TERR_VALUE_OUT_OF_RANGE, /* value is out of range in template */ 180 SCF_TERR_INVALID_VALUE, /* value is not valid for the */ 181 /* template */ 182 SCF_TERR_PG_PATTERN_CONFLICT, /* pg_pattern conflicts with higher */ 183 /* level definition */ 184 SCF_TERR_PROP_PATTERN_CONFLICT, /* prop_pattern conflicts with higher */ 185 /* level definition */ 186 SCF_TERR_GENERAL_REDEFINE, /* global or restarter template */ 187 /* redefined */ 188 SCF_TERR_INCLUDE_VALUES, /* No supporting constraints or */ 189 /* values for include_values */ 190 SCF_TERR_PG_PATTERN_INCOMPLETE, /* Required pg_pattern is missing */ 191 /* name or type attribute. */ 192 SCF_TERR_PROP_PATTERN_INCOMPLETE /* Required prop_pattern is */ 193 /* missing a type attribute. */ 194} scf_tmpl_error_type_t; 195 196typedef struct scf_tmpl_error scf_tmpl_error_t; 197 198/* 199 * scf_tmpl_strerror() human readable flag 200 */ 201#define SCF_TMPL_STRERROR_HUMAN 0x1 202 203/* 204 * Standard services 205 */ 206#define SCF_SERVICE_CONFIGD ((const char *) \ 207 "svc:/system/svc/repository:default") 208#define SCF_INSTANCE_GLOBAL ((const char *) \ 209 "svc:/system/svc/global:default") 210#define SCF_SERVICE_GLOBAL ((const char *) \ 211 "svc:/system/svc/global") 212#define SCF_SERVICE_STARTD ((const char *) \ 213 "svc:/system/svc/restarter:default") 214 215/* 216 * Major milestones 217 */ 218#define SCF_MILESTONE_SINGLE_USER \ 219 ((const char *) "svc:/milestone/single-user:default") 220#define SCF_MILESTONE_MULTI_USER \ 221 ((const char *) "svc:/milestone/multi-user:default") 222#define SCF_MILESTONE_MULTI_USER_SERVER \ 223 ((const char *) "svc:/milestone/multi-user-server:default") 224 225/* 226 * standard scope names 227 */ 228#define SCF_SCOPE_LOCAL ((const char *)"localhost") 229 230/* 231 * Property group types 232 */ 233#define SCF_GROUP_APPLICATION ((const char *)"application") 234#define SCF_GROUP_FRAMEWORK ((const char *)"framework") 235#define SCF_GROUP_DEPENDENCY ((const char *)"dependency") 236#define SCF_GROUP_METHOD ((const char *)"method") 237#define SCF_GROUP_TEMPLATE ((const char *)"template") 238#define SCF_GROUP_TEMPLATE_PG_PATTERN ((const char *)"template_pg_pattern") 239#define SCF_GROUP_TEMPLATE_PROP_PATTERN ((const char *)"template_prop_pattern") 240 241/* 242 * Dependency types 243 */ 244#define SCF_DEP_REQUIRE_ALL ((const char *)"require_all") 245#define SCF_DEP_REQUIRE_ANY ((const char *)"require_any") 246#define SCF_DEP_EXCLUDE_ALL ((const char *)"exclude_all") 247#define SCF_DEP_OPTIONAL_ALL ((const char *)"optional_all") 248 249#define SCF_DEP_RESET_ON_ERROR ((const char *)"error") 250#define SCF_DEP_RESET_ON_RESTART ((const char *)"restart") 251#define SCF_DEP_RESET_ON_REFRESH ((const char *)"refresh") 252#define SCF_DEP_RESET_ON_NONE ((const char *)"none") 253 254/* 255 * Standard property group names 256 */ 257#define SCF_PG_GENERAL ((const char *)"general") 258#define SCF_PG_GENERAL_OVR ((const char *)"general_ovr") 259#define SCF_PG_RESTARTER ((const char *)"restarter") 260#define SCF_PG_RESTARTER_ACTIONS ((const char *)"restarter_actions") 261#define SCF_PG_METHOD_CONTEXT ((const char *)"method_context") 262#define SCF_PG_APP_DEFAULT ((const char *)"application") 263#define SCF_PG_DEPENDENTS ((const char *)"dependents") 264#define SCF_PG_OPTIONS ((const char *)"options") 265#define SCF_PG_OPTIONS_OVR ((const char *)"options_ovr") 266#define SCF_PG_STARTD ((const char *)"startd") 267#define SCF_PG_STARTD_PRIVATE ((const char *)"svc-startd-private") 268#define SCF_PG_DEATHROW ((const char *)"deathrow") 269#define SCF_PG_MANIFESTFILES ((const char *)"manifestfiles") 270 271/* 272 * Template property group names and prefixes 273 */ 274#define SCF_PG_TM_COMMON_NAME ((const char *)"tm_common_name") 275#define SCF_PG_TM_DESCRIPTION ((const char *)"tm_description") 276 277#define SCF_PG_TM_MAN_PREFIX ((const char *)"tm_man_") 278#define SCF_PG_TM_DOC_PREFIX ((const char *)"tm_doc_") 279 280/* 281 * Standard property names 282 */ 283#define SCF_PROPERTY_AUX_STATE ((const char *)"auxiliary_state") 284#define SCF_PROPERTY_AUX_FMRI ((const char *)"auxiliary_fmri") 285#define SCF_PROPERTY_AUX_TTY ((const char *)"auxiliary_tty") 286#define SCF_PROPERTY_CONTRACT ((const char *)"contract") 287#define SCF_PROPERTY_COREFILE_PATTERN ((const char *)"corefile_pattern") 288#define SCF_PROPERTY_DEGRADED ((const char *)"degraded") 289#define SCF_PROPERTY_DEGRADE_IMMEDIATE ((const char *)"degrade_immediate") 290#define SCF_PROPERTY_DURATION ((const char *)"duration") 291#define SCF_PROPERTY_ENABLED ((const char *)"enabled") 292#define SCF_PROPERTY_DEATHROW ((const char *)"deathrow") 293#define SCF_PROPERTY_ENTITY_STABILITY ((const char *)"entity_stability") 294#define SCF_PROPERTY_ENTITIES ((const char *)"entities") 295#define SCF_PROPERTY_EXEC ((const char *)"exec") 296#define SCF_PROPERTY_GROUP ((const char *)"group") 297#define SCF_PROPERTY_GROUPING ((const char *)"grouping") 298#define SCF_PROPERTY_IGNORE ((const char *)"ignore_error") 299#define SCF_PROPERTY_INTERNAL_SEPARATORS ((const char *)"internal_separators") 300#define SCF_PROPERTY_LIMIT_PRIVILEGES ((const char *)"limit_privileges") 301#define SCF_PROPERTY_MAINT_OFF ((const char *)"maint_off") 302#define SCF_PROPERTY_MAINT_ON ((const char *)"maint_on") 303#define SCF_PROPERTY_MAINT_ON_IMMEDIATE ((const char *)"maint_on_immediate") 304#define SCF_PROPERTY_MAINT_ON_IMMTEMP ((const char *)"maint_on_immtemp") 305#define SCF_PROPERTY_MAINT_ON_TEMPORARY ((const char *)"maint_on_temporary") 306#define SCF_PROPERTY_METHOD_PID ((const char *)"method_pid") 307#define SCF_PROPERTY_MILESTONE ((const char *)"milestone") 308#define SCF_PROPERTY_NEED_SESSION ((const char *)"need_session") 309#define SCF_PROPERTY_NEXT_STATE ((const char *)"next_state") 310#define SCF_PROPERTY_PACKAGE ((const char *)"package") 311#define SCF_PROPERTY_PRIVILEGES ((const char *)"privileges") 312#define SCF_PROPERTY_PROFILE ((const char *)"profile") 313#define SCF_PROPERTY_PROJECT ((const char *)"project") 314#define SCF_PROPERTY_REFRESH ((const char *)"refresh") 315#define SCF_PROPERTY_RESOURCE_POOL ((const char *)"resource_pool") 316#define SCF_PROPERTY_ENVIRONMENT ((const char *)"environment") 317#define SCF_PROPERTY_RESTART ((const char *)"restart") 318#define SCF_PROPERTY_RESTARTER ((const char *)"restarter") 319#define SCF_PROPERTY_RESTART_INTERVAL ((const char *)"restart_interval") 320#define SCF_PROPERTY_RESTART_ON ((const char *)"restart_on") 321#define SCF_PROPERTY_RESTORE ((const char *)"restore") 322#define SCF_PROPERTY_SINGLE_INSTANCE ((const char *)"single_instance") 323#define SCF_PROPERTY_START_METHOD_TIMESTAMP \ 324 ((const char *)"start_method_timestamp") 325#define SCF_PROPERTY_START_METHOD_WAITSTATUS \ 326 ((const char *)"start_method_waitstatus") 327#define SCF_PROPERTY_START_PID ((const char *)"start_pid") 328#define SCF_PROPERTY_STATE ((const char *)"state") 329#define SCF_PROPERTY_STABILITY ((const char *)"stability") 330#define SCF_PROPERTY_STATE_TIMESTAMP ((const char *)"state_timestamp") 331#define SCF_PROPERTY_SUPP_GROUPS ((const char *)"supp_groups") 332#define SCF_PROPERTY_TIMEOUT ((const char *)"timeout_seconds") 333#define SCF_PROPERTY_TIMEOUT_RETRY ((const char *)"timeout_retry") 334#define SCF_PROPERTY_TRANSIENT_CONTRACT ((const char *)"transient_contract") 335#define SCF_PROPERTY_TYPE ((const char *)"type") 336#define SCF_PROPERTY_USE_PROFILE ((const char *)"use_profile") 337#define SCF_PROPERTY_USER ((const char *)"user") 338#define SCF_PROPERTY_UTMPX_PREFIX ((const char *)"utmpx_prefix") 339#define SCF_PROPERTY_WORKING_DIRECTORY ((const char *)"working_directory") 340 341/* 342 * Template property names 343 */ 344#define SCF_PROPERTY_TM_CARDINALITY_MIN ((const char *)"cardinality_min") 345#define SCF_PROPERTY_TM_CARDINALITY_MAX ((const char *)"cardinality_max") 346#define SCF_PROPERTY_TM_CHOICES_INCLUDE_VALUES ((const char *) \ 347 "choices_include_values") 348#define SCF_PROPERTY_TM_CHOICES_NAME ((const char *)"choices_name") 349#define SCF_PROPERTY_TM_CHOICES_RANGE ((const char *)"choices_range") 350#define SCF_PROPERTY_TM_CONSTRAINT_NAME ((const char *)"constraint_name") 351#define SCF_PROPERTY_TM_CONSTRAINT_RANGE ((const char *)"constraint_range") 352#define SCF_PROPERTY_TM_MANPATH ((const char *)"manpath") 353#define SCF_PROPERTY_TM_NAME ((const char *)"name") 354#define SCF_PROPERTY_TM_PG_PATTERN ((const char *)"pg_pattern") 355#define SCF_PROPERTY_TM_REQUIRED ((const char *)"required") 356#define SCF_PROPERTY_TM_SECTION ((const char *)"section") 357#define SCF_PROPERTY_TM_TARGET ((const char *)"target") 358#define SCF_PROPERTY_TM_TITLE ((const char *)"title") 359#define SCF_PROPERTY_TM_TYPE ((const char *)"type") 360#define SCF_PROPERTY_TM_URI ((const char *)"uri") 361#define SCF_PROPERTY_TM_VALUE_PREFIX ((const char *)"value_") 362#define SCF_PROPERTY_TM_VALUES_NAME ((const char *)"values_name") 363#define SCF_PROPERTY_TM_VISIBILITY ((const char *)"visibility") 364#define SCF_PROPERTY_TM_COMMON_NAME_PREFIX ((const char *)"common_name_") 365#define SCF_PROPERTY_TM_DESCRIPTION_PREFIX ((const char *)"description_") 366#define SCF_PROPERTY_TM_UNITS_PREFIX ((const char *)"units_") 367 368/* 369 * Templates wildcard string 370 */ 371#define SCF_TMPL_WILDCARD ((const char *)"*") 372 373/* 374 * Strings used by restarters for state and next_state properties. 375 * MAX_SCF_STATE_STRING holds the max length of a state string, including the 376 * terminating null. 377 */ 378 379#define MAX_SCF_STATE_STRING_SZ 14 380 381#define SCF_STATE_STRING_NONE ((const char *)"none") 382#define SCF_STATE_STRING_UNINIT ((const char *)"uninitialized") 383#define SCF_STATE_STRING_MAINT ((const char *)"maintenance") 384#define SCF_STATE_STRING_OFFLINE ((const char *)"offline") 385#define SCF_STATE_STRING_DISABLED ((const char *)"disabled") 386#define SCF_STATE_STRING_ONLINE ((const char *)"online") 387#define SCF_STATE_STRING_DEGRADED ((const char *)"degraded") 388#define SCF_STATE_STRING_LEGACY ((const char *)"legacy_run") 389 390#define SCF_STATE_UNINIT 0x00000001 391#define SCF_STATE_MAINT 0x00000002 392#define SCF_STATE_OFFLINE 0x00000004 393#define SCF_STATE_DISABLED 0x00000008 394#define SCF_STATE_ONLINE 0x00000010 395#define SCF_STATE_DEGRADED 0x00000020 396#define SCF_STATE_ALL 0x0000003F 397 398#define SCF_PG_FLAG_NONPERSISTENT 0x1 399 400#define SCF_TRACE_LIBRARY 0x1 401#define SCF_TRACE_DAEMON 0x2 402 403#define SMF_IMMEDIATE 0x1 404#define SMF_TEMPORARY 0x2 405#define SMF_AT_NEXT_BOOT 0x4 406 407scf_error_t scf_error(void); 408const char *scf_strerror(scf_error_t); 409 410ssize_t scf_limit(uint32_t code); 411#define SCF_LIMIT_MAX_NAME_LENGTH -2000U 412#define SCF_LIMIT_MAX_VALUE_LENGTH -2001U 413#define SCF_LIMIT_MAX_PG_TYPE_LENGTH -2002U 414#define SCF_LIMIT_MAX_FMRI_LENGTH -2003U 415 416scf_handle_t *scf_handle_create(scf_version_t); 417 418int scf_handle_decorate(scf_handle_t *, const char *, scf_value_t *); 419#define SCF_DECORATE_CLEAR ((scf_value_t *)0) 420 421int scf_handle_bind(scf_handle_t *); 422int scf_handle_unbind(scf_handle_t *); 423void scf_handle_destroy(scf_handle_t *); 424 425int scf_type_base_type(scf_type_t type, scf_type_t *out); 426const char *scf_type_to_string(scf_type_t); 427scf_type_t scf_string_to_type(const char *); 428 429/* values */ 430scf_value_t *scf_value_create(scf_handle_t *); 431scf_handle_t *scf_value_handle(const scf_value_t *); 432void scf_value_destroy(scf_value_t *); 433 434scf_type_t scf_value_base_type(const scf_value_t *); 435scf_type_t scf_value_type(const scf_value_t *); 436int scf_value_is_type(const scf_value_t *, scf_type_t); 437 438void scf_value_reset(scf_value_t *); 439 440int scf_value_get_boolean(const scf_value_t *, uint8_t *); 441int scf_value_get_count(const scf_value_t *, uint64_t *); 442int scf_value_get_integer(const scf_value_t *, int64_t *); 443int scf_value_get_time(const scf_value_t *, int64_t *, int32_t *); 444ssize_t scf_value_get_astring(const scf_value_t *, char *, size_t); 445ssize_t scf_value_get_ustring(const scf_value_t *, char *, size_t); 446ssize_t scf_value_get_opaque(const scf_value_t *, void *, size_t); 447 448void scf_value_set_boolean(scf_value_t *, uint8_t); 449void scf_value_set_count(scf_value_t *, uint64_t); 450void scf_value_set_integer(scf_value_t *, int64_t); 451int scf_value_set_time(scf_value_t *, int64_t, int32_t); 452int scf_value_set_astring(scf_value_t *, const char *); 453int scf_value_set_ustring(scf_value_t *, const char *); 454int scf_value_set_opaque(scf_value_t *, const void *, size_t); 455 456ssize_t scf_value_get_as_string(const scf_value_t *, char *, size_t); 457ssize_t scf_value_get_as_string_typed(const scf_value_t *, scf_type_t, 458 char *, size_t); 459int scf_value_set_from_string(scf_value_t *, scf_type_t, const char *); 460 461scf_iter_t *scf_iter_create(scf_handle_t *); 462scf_handle_t *scf_iter_handle(const scf_iter_t *); 463void scf_iter_reset(scf_iter_t *); 464void scf_iter_destroy(scf_iter_t *); 465 466int scf_iter_handle_scopes(scf_iter_t *, const scf_handle_t *); 467int scf_iter_scope_services(scf_iter_t *, const scf_scope_t *); 468int scf_iter_service_instances(scf_iter_t *, const scf_service_t *); 469int scf_iter_service_pgs(scf_iter_t *, const scf_service_t *); 470int scf_iter_instance_pgs(scf_iter_t *, const scf_instance_t *); 471int scf_iter_instance_pgs_composed(scf_iter_t *, const scf_instance_t *, 472 const scf_snapshot_t *); 473int scf_iter_service_pgs_typed(scf_iter_t *, const scf_service_t *, 474 const char *); 475int scf_iter_instance_pgs_typed(scf_iter_t *, const scf_instance_t *, 476 const char *); 477int scf_iter_instance_pgs_typed_composed(scf_iter_t *, const scf_instance_t *, 478 const scf_snapshot_t *, const char *); 479int scf_iter_snaplevel_pgs(scf_iter_t *, const scf_snaplevel_t *); 480int scf_iter_snaplevel_pgs_typed(scf_iter_t *, const scf_snaplevel_t *, 481 const char *); 482int scf_iter_instance_snapshots(scf_iter_t *, const scf_instance_t *); 483int scf_iter_pg_properties(scf_iter_t *, const scf_propertygroup_t *); 484int scf_iter_property_values(scf_iter_t *, const scf_property_t *); 485 486int scf_iter_next_scope(scf_iter_t *, scf_scope_t *); 487int scf_iter_next_service(scf_iter_t *, scf_service_t *); 488int scf_iter_next_instance(scf_iter_t *, scf_instance_t *); 489int scf_iter_next_pg(scf_iter_t *, scf_propertygroup_t *); 490int scf_iter_next_property(scf_iter_t *, scf_property_t *); 491int scf_iter_next_snapshot(scf_iter_t *, scf_snapshot_t *); 492int scf_iter_next_value(scf_iter_t *, scf_value_t *); 493 494scf_scope_t *scf_scope_create(scf_handle_t *); 495scf_handle_t *scf_scope_handle(const scf_scope_t *); 496 497/* XXX eventually remove this */ 498#define scf_handle_get_local_scope(h, s) \ 499 scf_handle_get_scope((h), SCF_SCOPE_LOCAL, (s)) 500 501int scf_handle_get_scope(scf_handle_t *, const char *, scf_scope_t *); 502void scf_scope_destroy(scf_scope_t *); 503ssize_t scf_scope_get_name(const scf_scope_t *, char *, size_t); 504 505ssize_t scf_scope_to_fmri(const scf_scope_t *, char *, size_t); 506 507scf_service_t *scf_service_create(scf_handle_t *); 508scf_handle_t *scf_service_handle(const scf_service_t *); 509void scf_service_destroy(scf_service_t *); 510int scf_scope_get_parent(const scf_scope_t *, scf_scope_t *); 511ssize_t scf_service_get_name(const scf_service_t *, char *, size_t); 512ssize_t scf_service_to_fmri(const scf_service_t *, char *, size_t); 513int scf_service_get_parent(const scf_service_t *, scf_scope_t *); 514int scf_scope_get_service(const scf_scope_t *, const char *, scf_service_t *); 515int scf_scope_add_service(const scf_scope_t *, const char *, scf_service_t *); 516int scf_service_delete(scf_service_t *); 517 518scf_instance_t *scf_instance_create(scf_handle_t *); 519scf_handle_t *scf_instance_handle(const scf_instance_t *); 520void scf_instance_destroy(scf_instance_t *); 521ssize_t scf_instance_get_name(const scf_instance_t *, char *, size_t); 522ssize_t scf_instance_to_fmri(const scf_instance_t *, char *, size_t); 523int scf_service_get_instance(const scf_service_t *, const char *, 524 scf_instance_t *); 525int scf_service_add_instance(const scf_service_t *, const char *, 526 scf_instance_t *); 527int scf_instance_delete(scf_instance_t *); 528 529scf_snapshot_t *scf_snapshot_create(scf_handle_t *); 530scf_handle_t *scf_snapshot_handle(const scf_snapshot_t *); 531void scf_snapshot_destroy(scf_snapshot_t *); 532ssize_t scf_snapshot_get_name(const scf_snapshot_t *, char *, size_t); 533int scf_snapshot_get_parent(const scf_snapshot_t *, scf_instance_t *); 534int scf_instance_get_snapshot(const scf_instance_t *, const char *, 535 scf_snapshot_t *); 536int scf_snapshot_update(scf_snapshot_t *); 537 538scf_snaplevel_t *scf_snaplevel_create(scf_handle_t *); 539scf_handle_t *scf_snaplevel_handle(const scf_snaplevel_t *); 540void scf_snaplevel_destroy(scf_snaplevel_t *); 541int scf_snaplevel_get_parent(const scf_snaplevel_t *, scf_snapshot_t *); 542ssize_t scf_snaplevel_get_scope_name(const scf_snaplevel_t *, char *, size_t); 543ssize_t scf_snaplevel_get_service_name(const scf_snaplevel_t *, char *, size_t); 544ssize_t scf_snaplevel_get_instance_name(const scf_snaplevel_t *, char *, 545 size_t); 546int scf_snaplevel_get_pg(const scf_snaplevel_t *, const char *, 547 scf_propertygroup_t *pg); 548int scf_snapshot_get_base_snaplevel(const scf_snapshot_t *, scf_snaplevel_t *); 549int scf_snaplevel_get_next_snaplevel(const scf_snaplevel_t *, 550 scf_snaplevel_t *); 551 552scf_propertygroup_t *scf_pg_create(scf_handle_t *); 553scf_handle_t *scf_pg_handle(const scf_propertygroup_t *); 554void scf_pg_destroy(scf_propertygroup_t *); 555ssize_t scf_pg_to_fmri(const scf_propertygroup_t *, char *, size_t); 556ssize_t scf_pg_get_name(const scf_propertygroup_t *, char *, size_t); 557ssize_t scf_pg_get_type(const scf_propertygroup_t *, char *, size_t); 558int scf_pg_get_flags(const scf_propertygroup_t *, uint32_t *); 559int scf_pg_get_parent_service(const scf_propertygroup_t *, scf_service_t *); 560int scf_pg_get_parent_instance(const scf_propertygroup_t *, scf_instance_t *); 561int scf_pg_get_parent_snaplevel(const scf_propertygroup_t *, scf_snaplevel_t *); 562int scf_service_get_pg(const scf_service_t *, const char *, 563 scf_propertygroup_t *); 564int scf_instance_get_pg(const scf_instance_t *, const char *, 565 scf_propertygroup_t *); 566int scf_instance_get_pg_composed(const scf_instance_t *, const scf_snapshot_t *, 567 const char *, scf_propertygroup_t *); 568int scf_service_add_pg(const scf_service_t *, const char *, const char *, 569 uint32_t, scf_propertygroup_t *); 570int scf_instance_add_pg(const scf_instance_t *, const char *, const char *, 571 uint32_t, scf_propertygroup_t *); 572int scf_pg_delete(scf_propertygroup_t *); 573 574int scf_pg_get_underlying_pg(const scf_propertygroup_t *, 575 scf_propertygroup_t *); 576int scf_instance_get_parent(const scf_instance_t *, scf_service_t *); 577 578int scf_pg_update(scf_propertygroup_t *); 579 580scf_property_t *scf_property_create(scf_handle_t *); 581scf_handle_t *scf_property_handle(const scf_property_t *); 582void scf_property_destroy(scf_property_t *); 583int scf_property_is_type(const scf_property_t *, scf_type_t); 584int scf_property_type(const scf_property_t *, scf_type_t *); 585ssize_t scf_property_get_name(const scf_property_t *, char *, size_t); 586int scf_property_get_value(const scf_property_t *, scf_value_t *); 587ssize_t scf_property_to_fmri(const scf_property_t *, char *, size_t); 588int scf_pg_get_property(const scf_propertygroup_t *, const char *, 589 scf_property_t *); 590 591scf_transaction_t *scf_transaction_create(scf_handle_t *); 592scf_handle_t *scf_transaction_handle(const scf_transaction_t *); 593int scf_transaction_start(scf_transaction_t *, scf_propertygroup_t *); 594void scf_transaction_destroy(scf_transaction_t *); 595void scf_transaction_destroy_children(scf_transaction_t *); 596 597void scf_transaction_reset(scf_transaction_t *); 598void scf_transaction_reset_all(scf_transaction_t *); 599 600int scf_transaction_commit(scf_transaction_t *); 601 602scf_transaction_entry_t *scf_entry_create(scf_handle_t *); 603scf_handle_t *scf_entry_handle(const scf_transaction_entry_t *); 604void scf_entry_reset(scf_transaction_entry_t *); 605void scf_entry_destroy(scf_transaction_entry_t *); 606void scf_entry_destroy_children(scf_transaction_entry_t *); 607 608int scf_transaction_property_change(scf_transaction_t *, 609 scf_transaction_entry_t *, const char *, scf_type_t); 610int scf_transaction_property_delete(scf_transaction_t *, 611 scf_transaction_entry_t *, const char *); 612int scf_transaction_property_new(scf_transaction_t *, 613 scf_transaction_entry_t *, const char *, scf_type_t); 614int scf_transaction_property_change_type(scf_transaction_t *, 615 scf_transaction_entry_t *, const char *, scf_type_t); 616 617int scf_entry_add_value(scf_transaction_entry_t *, scf_value_t *); 618 619int scf_handle_decode_fmri(scf_handle_t *, const char *, scf_scope_t *, 620 scf_service_t *, scf_instance_t *, scf_propertygroup_t *, scf_property_t *, 621 int); 622#define SCF_DECODE_FMRI_EXACT 0x00000001 623#define SCF_DECODE_FMRI_TRUNCATE 0x00000002 624#define SCF_DECODE_FMRI_REQUIRE_INSTANCE 0x00000004 625#define SCF_DECODE_FMRI_REQUIRE_NO_INSTANCE 0x00000008 626 627ssize_t scf_myname(scf_handle_t *, char *, size_t); 628 629/* 630 * Property group template interfaces. 631 */ 632scf_pg_tmpl_t *scf_tmpl_pg_create(scf_handle_t *); 633void scf_tmpl_pg_destroy(scf_pg_tmpl_t *); 634void scf_tmpl_pg_reset(scf_pg_tmpl_t *); 635int scf_tmpl_get_by_pg(scf_propertygroup_t *, scf_pg_tmpl_t *, int); 636int scf_tmpl_get_by_pg_name(const char *, const char *, 637 const char *, const char *, scf_pg_tmpl_t *, int); 638int scf_tmpl_iter_pgs(scf_pg_tmpl_t *, const char *, const char *, 639 const char *, int); 640#define SCF_PG_TMPL_FLAG_REQUIRED 0x1 641#define SCF_PG_TMPL_FLAG_EXACT 0x2 642#define SCF_PG_TMPL_FLAG_CURRENT 0x4 643 644ssize_t scf_tmpl_pg_name(const scf_pg_tmpl_t *, char **); 645ssize_t scf_tmpl_pg_common_name(const scf_pg_tmpl_t *, const char *, char **); 646ssize_t scf_tmpl_pg_description(const scf_pg_tmpl_t *, const char *, char **); 647ssize_t scf_tmpl_pg_type(const scf_pg_tmpl_t *, char **); 648 649ssize_t scf_tmpl_pg_target(const scf_pg_tmpl_t *, char **); 650#define SCF_TM_TARGET_ALL ((const char *)"all") 651#define SCF_TM_TARGET_DELEGATE ((const char *)"delegate") 652#define SCF_TM_TARGET_INSTANCE ((const char *)"instance") 653#define SCF_TM_TARGET_THIS ((const char *)"this") 654 655int scf_tmpl_pg_required(const scf_pg_tmpl_t *, uint8_t *); 656 657/* 658 * Property template interfaces. 659 */ 660scf_prop_tmpl_t *scf_tmpl_prop_create(scf_handle_t *); 661void scf_tmpl_prop_destroy(scf_prop_tmpl_t *); 662void scf_tmpl_prop_reset(scf_prop_tmpl_t *); 663int scf_tmpl_get_by_prop(scf_pg_tmpl_t *, const char *, 664 scf_prop_tmpl_t *, int); 665int scf_tmpl_iter_props(scf_pg_tmpl_t *, scf_prop_tmpl_t *, int); 666#define SCF_PROP_TMPL_FLAG_REQUIRED 0x1 667 668ssize_t scf_tmpl_prop_name(const scf_prop_tmpl_t *, char **); 669int scf_tmpl_prop_type(const scf_prop_tmpl_t *, scf_type_t *); 670int scf_tmpl_prop_required(const scf_prop_tmpl_t *, uint8_t *); 671ssize_t scf_tmpl_prop_common_name(const scf_prop_tmpl_t *, const char *, 672 char **); 673ssize_t scf_tmpl_prop_description(const scf_prop_tmpl_t *, const char *, 674 char **); 675ssize_t scf_tmpl_prop_units(const scf_prop_tmpl_t *, const char *, char **); 676int scf_tmpl_prop_cardinality(const scf_prop_tmpl_t *prop, uint64_t *, 677 uint64_t *); 678int scf_tmpl_prop_internal_seps(const scf_prop_tmpl_t *, scf_values_t *); 679 680int scf_tmpl_prop_visibility(const scf_prop_tmpl_t *, uint8_t *); 681#define SCF_TMPL_VISIBILITY_HIDDEN 1 682#define SCF_TMPL_VISIBILITY_READONLY 2 683#define SCF_TMPL_VISIBILITY_READWRITE 3 684 685const char *scf_tmpl_visibility_to_string(uint8_t); 686#define SCF_TM_VISIBILITY_HIDDEN ((const char *)"hidden") 687#define SCF_TM_VISIBILITY_READONLY ((const char *)"readonly") 688#define SCF_TM_VISIBILITY_READWRITE ((const char *)"readwrite") 689 690int scf_tmpl_value_name_constraints(const scf_prop_tmpl_t *prop, 691 scf_values_t *vals); 692void scf_count_ranges_destroy(scf_count_ranges_t *); 693void scf_int_ranges_destroy(scf_int_ranges_t *); 694int scf_tmpl_value_count_range_constraints(const scf_prop_tmpl_t *, 695 scf_count_ranges_t *); 696int scf_tmpl_value_int_range_constraints(const scf_prop_tmpl_t *, 697 scf_int_ranges_t *); 698int scf_tmpl_value_count_range_choices(const scf_prop_tmpl_t *, 699 scf_count_ranges_t *); 700int scf_tmpl_value_int_range_choices(const scf_prop_tmpl_t *, 701 scf_int_ranges_t *); 702int scf_tmpl_value_name_choices(const scf_prop_tmpl_t *prop, 703 scf_values_t *vals); 704 705void scf_values_destroy(scf_values_t *); 706 707ssize_t scf_tmpl_value_common_name(const scf_prop_tmpl_t *, const char *, 708 const char *, char **); 709ssize_t scf_tmpl_value_description(const scf_prop_tmpl_t *, const char *, 710 const char *, char **); 711 712int scf_tmpl_value_in_constraint(const scf_prop_tmpl_t *pt, scf_value_t *value, 713 scf_tmpl_errors_t **errs); 714 715/* 716 * Template validation interfaces 717 */ 718int scf_tmpl_validate_fmri(scf_handle_t *, const char *, 719 const char *, scf_tmpl_errors_t **, int); 720#define SCF_TMPL_VALIDATE_FLAG_CURRENT 0x1 721 722void scf_tmpl_errors_destroy(scf_tmpl_errors_t *errs); 723scf_tmpl_error_t *scf_tmpl_next_error(scf_tmpl_errors_t *); 724void scf_tmpl_reset_errors(scf_tmpl_errors_t *errs); 725int scf_tmpl_strerror(scf_tmpl_error_t *err, char *s, size_t n, int flag); 726int scf_tmpl_error_source_fmri(const scf_tmpl_error_t *, char **); 727int scf_tmpl_error_type(const scf_tmpl_error_t *, scf_tmpl_error_type_t *); 728int scf_tmpl_error_pg_tmpl(const scf_tmpl_error_t *, char **, char **); 729int scf_tmpl_error_pg(const scf_tmpl_error_t *, char **, char **); 730int scf_tmpl_error_prop_tmpl(const scf_tmpl_error_t *, char **, char **); 731int scf_tmpl_error_prop(const scf_tmpl_error_t *, char **, char **); 732int scf_tmpl_error_value(const scf_tmpl_error_t *, char **); 733 734/* 735 * Simplified calls 736 */ 737int smf_enable_instance(const char *, int); 738int smf_disable_instance(const char *, int); 739int smf_refresh_instance(const char *); 740int smf_restart_instance(const char *); 741int smf_maintain_instance(const char *, int); 742int smf_degrade_instance(const char *, int); 743int smf_restore_instance(const char *); 744char *smf_get_state(const char *); 745 746int scf_simple_walk_instances(uint_t, void *, 747 int (*inst_callback)(scf_handle_t *, scf_instance_t *, void *)); 748 749scf_simple_prop_t *scf_simple_prop_get(scf_handle_t *, const char *, 750 const char *, const char *); 751void scf_simple_prop_free(scf_simple_prop_t *); 752scf_simple_app_props_t *scf_simple_app_props_get(scf_handle_t *, const char *); 753void scf_simple_app_props_free(scf_simple_app_props_t *); 754const scf_simple_prop_t *scf_simple_app_props_next( 755 const scf_simple_app_props_t *, scf_simple_prop_t *); 756const scf_simple_prop_t *scf_simple_app_props_search( 757 const scf_simple_app_props_t *, const char *, const char *); 758ssize_t scf_simple_prop_numvalues(const scf_simple_prop_t *); 759scf_type_t scf_simple_prop_type(const scf_simple_prop_t *); 760char *scf_simple_prop_name(const scf_simple_prop_t *); 761char *scf_simple_prop_pgname(const scf_simple_prop_t *); 762uint8_t *scf_simple_prop_next_boolean(scf_simple_prop_t *); 763uint64_t *scf_simple_prop_next_count(scf_simple_prop_t *); 764int64_t *scf_simple_prop_next_integer(scf_simple_prop_t *); 765int64_t *scf_simple_prop_next_time(scf_simple_prop_t *, int32_t *); 766char *scf_simple_prop_next_astring(scf_simple_prop_t *); 767char *scf_simple_prop_next_ustring(scf_simple_prop_t *); 768void *scf_simple_prop_next_opaque(scf_simple_prop_t *, size_t *); 769void scf_simple_prop_next_reset(scf_simple_prop_t *); 770 771/* 772 * SMF exit status definitions 773 */ 774#define SMF_EXIT_OK 0 775#define SMF_EXIT_ERR_FATAL 95 776#define SMF_EXIT_ERR_CONFIG 96 777#define SMF_EXIT_MON_DEGRADE 97 778#define SMF_EXIT_MON_OFFLINE 98 779#define SMF_EXIT_ERR_NOSMF 99 780#define SMF_EXIT_ERR_PERM 100 781 782#ifdef __cplusplus 783} 784#endif 785 786#endif /* _LIBSCF_H */ 787