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>


   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 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  24  */
  25 
  26 #ifndef _LIBSCF_H
  27 #define _LIBSCF_H
  28 
  29 
  30 #include <stddef.h>
  31 #include <libnvpair.h>
  32 
  33 #ifndef NATIVE_BUILD
  34 #include <sys/secflags.h>
  35 #endif  /* NATIVE_BUILD */
  36 #include <sys/types.h>
  37 
  38 #ifdef  __cplusplus
  39 extern "C" {
  40 #endif
  41 
  42 typedef struct scf_version *scf_version_t;
  43 #define SCF_VERSION     ((scf_version_t)1UL)
  44 
  45 /*
  46  * Opaque structures
  47  */
  48 typedef struct scf_handle scf_handle_t;
  49 typedef struct scf_scope scf_scope_t;
  50 typedef struct scf_service scf_service_t;
  51 typedef struct scf_instance scf_instance_t;
  52 typedef struct scf_propertygroup scf_propertygroup_t;
  53 typedef struct scf_property scf_property_t;
  54 
  55 typedef struct scf_snapshot scf_snapshot_t;
  56 typedef struct scf_snaplevel scf_snaplevel_t;
  57 
  58 typedef struct scf_transaction scf_transaction_t;
  59 typedef struct scf_transaction_entry scf_transaction_entry_t;
  60 typedef struct scf_value scf_value_t;
  61 
  62 typedef struct scf_iter scf_iter_t;
  63 


 211         secflagdelta_t ss_upper;
 212 #else
 213         /*
 214          * This is never used, but is necessary for bootstrapping.
 215          * Not even the size matters.
 216          */
 217         void *ss_default;
 218         void *ss_lower;
 219         void *ss_upper;
 220 #endif /* NATIVE_BUILD */
 221 } scf_secflags_t;
 222 
 223 /*
 224  * scf_tmpl_strerror() human readable flag
 225  */
 226 #define SCF_TMPL_STRERROR_HUMAN 0x1
 227 
 228 /*
 229  * Standard services
 230  */
 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")
 245 
 246 /*
 247  * Major milestones
 248  */
 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")
 253 #define SCF_MILESTONE_MULTI_USER_SERVER \
 254         ((const char *) "svc:/milestone/multi-user-server:default")
 255 
 256 /*
 257  * standard scope names
 258  */
 259 #define SCF_SCOPE_LOCAL                 ((const char *)"localhost")
 260 
 261 /*
 262  * Property group types
 263  */
 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")
 271 
 272 /*
 273  * Dependency types
 274  */
 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")
 284 
 285 /*
 286  * Standard property group names
 287  */
 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")
 301 
 302 /*
 303  * Template property group names and prefixes
 304  */
 305 #define SCF_PG_TM_COMMON_NAME           ((const char *)"tm_common_name")
 306 #define SCF_PG_TM_DESCRIPTION           ((const char *)"tm_description")
 307 
 308 #define SCF_PG_TM_MAN_PREFIX            ((const char *)"tm_man_")
 309 #define SCF_PG_TM_DOC_PREFIX            ((const char *)"tm_doc_")
 310 
 311 /*
 312  * Standard property names
 313  */
 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")
 374 
 375 /*
 376  * Template property names
 377  */
 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_")
 401 
 402 /*
 403  * Templates wildcard string
 404  */
 405 #define SCF_TMPL_WILDCARD       ((const char *)"*")
 406 
 407 /*
 408  * Strings used by restarters for state and next_state properties.
 409  * MAX_SCF_STATE_STRING holds the max length of a state string, including the
 410  * terminating null.
 411  */
 412 
 413 #define MAX_SCF_STATE_STRING_SZ         14
 414 
 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")
 423 
 424 #define SCF_STATE_UNINIT                0x00000001
 425 #define SCF_STATE_MAINT                 0x00000002
 426 #define SCF_STATE_OFFLINE               0x00000004
 427 #define SCF_STATE_DISABLED              0x00000008
 428 #define SCF_STATE_ONLINE                0x00000010
 429 #define SCF_STATE_DEGRADED              0x00000020
 430 #define SCF_STATE_ALL                   0x0000003F
 431 
 432 /*
 433  * software fma svc-transition class
 434  */
 435 #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")
 446 
 447 /*
 448  * Useful transition macros
 449  */
 450 #define SCF_TRANS_SHIFT_INITIAL_STATE(s)        ((s) << 16)
 451 #define SCF_TRANSITION_ALL \
 452         (SCF_TRANS_SHIFT_INITIAL_STATE(SCF_STATE_ALL) | SCF_STATE_ALL)
 453 #define SCF_TRANS(f, t) (SCF_TRANS_SHIFT_INITIAL_STATE(f) | (t))
 454 #define SCF_TRANS_VALID(t)      (!((t) & ~SCF_TRANSITION_ALL))
 455 #define SCF_TRANS_INITIAL_STATE(t)      ((t) >> 16 & SCF_STATE_ALL)
 456 #define SCF_TRANS_FINAL_STATE(t)        ((t) & SCF_STATE_ALL)
 457 
 458 /*
 459  * Prefixes for states in state transition notification
 460  */
 461 #define SCF_STN_PREFIX_FROM             ((const char *)"from-")
 462 #define SCF_STN_PREFIX_TO               ((const char *)"to-")
 463 
 464 #define SCF_PG_FLAG_NONPERSISTENT       0x1
 465 
 466 #define SCF_TRACE_LIBRARY               0x1
 467 #define SCF_TRACE_DAEMON                0x2
 468 
 469 #define SMF_IMMEDIATE                   0x1
 470 #define SMF_TEMPORARY                   0x2
 471 #define SMF_AT_NEXT_BOOT                0x4
 472 
 473 scf_error_t scf_error(void);
 474 const char *scf_strerror(scf_error_t);
 475 
 476 ssize_t scf_limit(uint32_t code);
 477 #define SCF_LIMIT_MAX_NAME_LENGTH       -2000U
 478 #define SCF_LIMIT_MAX_VALUE_LENGTH      -2001U
 479 #define SCF_LIMIT_MAX_PG_TYPE_LENGTH    -2002U
 480 #define SCF_LIMIT_MAX_FMRI_LENGTH       -2003U
 481 
 482 scf_handle_t *scf_handle_create(scf_version_t);




   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 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2016 RackTop Systems.
  25  */
  26 
  27 #ifndef _LIBSCF_H
  28 #define _LIBSCF_H
  29 
  30 
  31 #include <stddef.h>
  32 #include <libnvpair.h>
  33 
  34 #ifndef NATIVE_BUILD
  35 #include <sys/secflags.h>
  36 #endif  /* NATIVE_BUILD */
  37 #include <sys/types.h>
  38 
  39 #ifdef  __cplusplus
  40 extern "C" {
  41 #endif
  42 
  43 typedef unsigned long scf_version_t;
  44 #define SCF_VERSION             1UL
  45 
  46 /*
  47  * Opaque structures
  48  */
  49 typedef struct scf_handle scf_handle_t;
  50 typedef struct scf_scope scf_scope_t;
  51 typedef struct scf_service scf_service_t;
  52 typedef struct scf_instance scf_instance_t;
  53 typedef struct scf_propertygroup scf_propertygroup_t;
  54 typedef struct scf_property scf_property_t;
  55 
  56 typedef struct scf_snapshot scf_snapshot_t;
  57 typedef struct scf_snaplevel scf_snaplevel_t;
  58 
  59 typedef struct scf_transaction scf_transaction_t;
  60 typedef struct scf_transaction_entry scf_transaction_entry_t;
  61 typedef struct scf_value scf_value_t;
  62 
  63 typedef struct scf_iter scf_iter_t;
  64 


 212         secflagdelta_t ss_upper;
 213 #else
 214         /*
 215          * This is never used, but is necessary for bootstrapping.
 216          * Not even the size matters.
 217          */
 218         void *ss_default;
 219         void *ss_lower;
 220         void *ss_upper;
 221 #endif /* NATIVE_BUILD */
 222 } scf_secflags_t;
 223 
 224 /*
 225  * scf_tmpl_strerror() human readable flag
 226  */
 227 #define SCF_TMPL_STRERROR_HUMAN 0x1
 228 
 229 /*
 230  * Standard services
 231  */
 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"







 239 
 240 /*
 241  * Major milestones
 242  */
 243 #define SCF_MILESTONE_SINGLE_USER       "svc:/milestone/single-user:default"
 244 #define SCF_MILESTONE_MULTI_USER        "svc:/milestone/multi-user:default"


 245 #define SCF_MILESTONE_MULTI_USER_SERVER \
 246         "svc:/milestone/multi-user-server:default"
 247 
 248 /*
 249  * standard scope names
 250  */
 251 #define SCF_SCOPE_LOCAL                 "localhost"
 252 
 253 /*
 254  * Property group types
 255  */
 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"
 263 
 264 /*
 265  * Dependency types
 266  */
 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"
 276 
 277 /*
 278  * Standard property group names
 279  */
 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"
 293 
 294 /*
 295  * Template property group names and prefixes
 296  */
 297 #define SCF_PG_TM_COMMON_NAME           "tm_common_name"
 298 #define SCF_PG_TM_DESCRIPTION           "tm_description"
 299 
 300 #define SCF_PG_TM_MAN_PREFIX            "tm_man_"
 301 #define SCF_PG_TM_DOC_PREFIX            "tm_doc_"
 302 
 303 /*
 304  * Standard property names
 305  */
 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"


 364 
 365 /*
 366  * Template property names
 367  */
 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_"

 390 
 391 /*
 392  * Templates wildcard string
 393  */
 394 #define SCF_TMPL_WILDCARD               "*"
 395 
 396 /*
 397  * Strings used by restarters for state and next_state properties.
 398  * MAX_SCF_STATE_STRING holds the max length of a state string, including the
 399  * terminating null.
 400  */
 401 
 402 #define MAX_SCF_STATE_STRING_SZ         14
 403 
 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"
 412 
 413 #define SCF_STATE_UNINIT                0x00000001
 414 #define SCF_STATE_MAINT                 0x00000002
 415 #define SCF_STATE_OFFLINE               0x00000004
 416 #define SCF_STATE_DISABLED              0x00000008
 417 #define SCF_STATE_ONLINE                0x00000010
 418 #define SCF_STATE_DEGRADED              0x00000020
 419 #define SCF_STATE_ALL                   0x0000003F
 420 
 421 /*
 422  * software fma svc-transition class
 423  */
 424 #define SCF_NOTIFY_PARAMS_VERSION       0X0
 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"


 433 
 434 /*
 435  * Useful transition macros
 436  */
 437 #define SCF_TRANS_SHIFT_INITIAL_STATE(s)        ((s) << 16)
 438 #define SCF_TRANSITION_ALL \
 439         (SCF_TRANS_SHIFT_INITIAL_STATE(SCF_STATE_ALL) | SCF_STATE_ALL)
 440 #define SCF_TRANS(f, t) (SCF_TRANS_SHIFT_INITIAL_STATE(f) | (t))
 441 #define SCF_TRANS_VALID(t)      (!((t) & ~SCF_TRANSITION_ALL))
 442 #define SCF_TRANS_INITIAL_STATE(t)      ((t) >> 16 & SCF_STATE_ALL)
 443 #define SCF_TRANS_FINAL_STATE(t)        ((t) & SCF_STATE_ALL)
 444 
 445 /*
 446  * Prefixes for states in state transition notification
 447  */
 448 #define SCF_STN_PREFIX_FROM             "from-"
 449 #define SCF_STN_PREFIX_TO               "to-"
 450 
 451 #define SCF_PG_FLAG_NONPERSISTENT       0x1
 452 
 453 #define SCF_TRACE_LIBRARY               0x1
 454 #define SCF_TRACE_DAEMON                0x2
 455 
 456 #define SMF_IMMEDIATE                   0x1
 457 #define SMF_TEMPORARY                   0x2
 458 #define SMF_AT_NEXT_BOOT                0x4
 459 
 460 scf_error_t scf_error(void);
 461 const char *scf_strerror(scf_error_t);
 462 
 463 ssize_t scf_limit(uint32_t code);
 464 #define SCF_LIMIT_MAX_NAME_LENGTH       -2000U
 465 #define SCF_LIMIT_MAX_VALUE_LENGTH      -2001U
 466 #define SCF_LIMIT_MAX_PG_TYPE_LENGTH    -2002U
 467 #define SCF_LIMIT_MAX_FMRI_LENGTH       -2003U
 468 
 469 scf_handle_t *scf_handle_create(scf_version_t);