/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2016 RackTop Systems.
*/
#ifndef _LIBSCF_H
#define _LIBSCF_H
#include <stddef.h>
#include <libnvpair.h>
#ifndef NATIVE_BUILD
#include <sys/secflags.h>
#endif /* NATIVE_BUILD */
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned long scf_version_t;
/*
* Opaque structures
*/
/*
* Types
*/
typedef enum {
SCF_TYPE_INVALID = 0,
} scf_type_t;
typedef struct scf_time {
} scf_time_t;
/*
* There is no explicit initializer for this structure. Functions
* which set or populate this structure assume that it is either
* uninitialized or destroyed.
*/
typedef struct scf_values {
int value_count;
char **values_as_strings;
union {
char **v_astring;
char **v_ustring;
char **v_opaque;
} values;
} scf_values_t;
typedef struct scf_count_ranges {
int scr_num_ranges;
typedef struct scf_int_ranges {
int sir_num_ranges;
/*
* Return codes
*/
#define SCF_SUCCESS 0
typedef enum scf_error {
} scf_error_t;
/*
* This enum MUST be kept in sync with
* struct _scf_tmpl_error_desc em_desc() in scf_tmpl.c
*/
typedef enum scf_tmpl_error_type {
/* redefined by the instance */
/* template */
/* level definition */
/* level definition */
/* redefined */
/* values for include_values */
/* name or type attribute. */
/* missing a type attribute. */
/*
* This unfortunately needs to be public, because consumers of librestart must
* deal with it
*/
typedef struct {
#ifndef NATIVE_BUILD
#else
/*
* This is never used, but is necessary for bootstrapping.
* Not even the size matters.
*/
void *ss_default;
void *ss_lower;
void *ss_upper;
#endif /* NATIVE_BUILD */
/*
* scf_tmpl_strerror() human readable flag
*/
/*
* Standard services
*/
/*
* Major milestones
*/
#define SCF_MILESTONE_MULTI_USER_SERVER \
"svc:/milestone/multi-user-server:default"
/*
* standard scope names
*/
/*
* Property group types
*/
/*
* Dependency types
*/
/*
* Standard property group names
*/
/*
* Template property group names and prefixes
*/
/*
* Standard property names
*/
/*
* Template property names
*/
/*
* Templates wildcard string
*/
/*
* Strings used by restarters for state and next_state properties.
* MAX_SCF_STATE_STRING holds the max length of a state string, including the
* terminating null.
*/
/*
* software fma svc-transition class
*/
/*
* Useful transition macros
*/
#define SCF_TRANSITION_ALL \
/*
* Prefixes for states in state transition notification
*/
scf_error_t scf_error(void);
const char *scf_strerror(scf_error_t);
int scf_handle_bind(scf_handle_t *);
int scf_handle_unbind(scf_handle_t *);
void scf_handle_destroy(scf_handle_t *);
const char *scf_type_to_string(scf_type_t);
scf_type_t scf_string_to_type(const char *);
/* values */
void scf_value_destroy(scf_value_t *);
void scf_value_reset(scf_value_t *);
int scf_value_set_astring(scf_value_t *, const char *);
int scf_value_set_ustring(scf_value_t *, const char *);
char *, size_t);
void scf_iter_reset(scf_iter_t *);
void scf_iter_destroy(scf_iter_t *);
const scf_snapshot_t *);
const char *);
const char *);
const scf_snapshot_t *, const char *);
const char *);
/* XXX eventually remove this */
#define scf_handle_get_local_scope(h, s) \
scf_handle_get_scope((h), SCF_SCOPE_LOCAL, (s))
void scf_scope_destroy(scf_scope_t *);
void scf_service_destroy(scf_service_t *);
int scf_service_delete(scf_service_t *);
void scf_instance_destroy(scf_instance_t *);
int scf_service_get_instance(const scf_service_t *, const char *,
scf_instance_t *);
int scf_service_add_instance(const scf_service_t *, const char *,
scf_instance_t *);
int scf_instance_delete(scf_instance_t *);
void scf_snapshot_destroy(scf_snapshot_t *);
int scf_instance_get_snapshot(const scf_instance_t *, const char *,
scf_snapshot_t *);
int scf_snapshot_update(scf_snapshot_t *);
void scf_snaplevel_destroy(scf_snaplevel_t *);
size_t);
int scf_snaplevel_get_pg(const scf_snaplevel_t *, const char *,
int scf_snaplevel_get_next_snaplevel(const scf_snaplevel_t *,
scf_snaplevel_t *);
void scf_pg_destroy(scf_propertygroup_t *);
int scf_service_get_pg(const scf_service_t *, const char *,
int scf_instance_get_pg(const scf_instance_t *, const char *,
const char *, scf_propertygroup_t *);
int scf_service_add_pg(const scf_service_t *, const char *, const char *,
int scf_instance_add_pg(const scf_instance_t *, const char *, const char *,
int scf_pg_delete(scf_propertygroup_t *);
int scf_pg_get_underlying_pg(const scf_propertygroup_t *,
int scf_pg_update(scf_propertygroup_t *);
void scf_property_destroy(scf_property_t *);
int scf_pg_get_property(const scf_propertygroup_t *, const char *,
scf_property_t *);
void scf_transaction_destroy(scf_transaction_t *);
void scf_transaction_reset(scf_transaction_t *);
void scf_entry_reset(scf_transaction_entry_t *);
void scf_entry_destroy(scf_transaction_entry_t *);
scf_transaction_entry_t *, const char *, scf_type_t);
scf_transaction_entry_t *, const char *);
scf_transaction_entry_t *, const char *, scf_type_t);
scf_transaction_entry_t *, const char *, scf_type_t);
int);
/*
* Property group template interfaces.
*/
void scf_tmpl_pg_destroy(scf_pg_tmpl_t *);
void scf_tmpl_pg_reset(scf_pg_tmpl_t *);
int scf_tmpl_get_by_pg_name(const char *, const char *,
const char *, const char *, scf_pg_tmpl_t *, int);
int scf_tmpl_iter_pgs(scf_pg_tmpl_t *, const char *, const char *,
const char *, int);
/*
* Property template interfaces.
*/
void scf_tmpl_prop_destroy(scf_prop_tmpl_t *);
void scf_tmpl_prop_reset(scf_prop_tmpl_t *);
int scf_tmpl_get_by_prop(scf_pg_tmpl_t *, const char *,
scf_prop_tmpl_t *, int);
char **);
char **);
uint64_t *);
const char *scf_tmpl_visibility_to_string(uint8_t);
scf_values_t *vals);
void scf_int_ranges_destroy(scf_int_ranges_t *);
int scf_tmpl_value_count_range_constraints(const scf_prop_tmpl_t *,
int scf_tmpl_value_int_range_constraints(const scf_prop_tmpl_t *,
scf_int_ranges_t *);
int scf_tmpl_value_count_range_choices(const scf_prop_tmpl_t *,
int scf_tmpl_value_int_range_choices(const scf_prop_tmpl_t *,
scf_int_ranges_t *);
scf_values_t *vals);
void scf_values_destroy(scf_values_t *);
const char *, char **);
const char *, char **);
/*
* Template validation interfaces
*/
int scf_tmpl_validate_fmri(scf_handle_t *, const char *,
const char *, scf_tmpl_errors_t **, int);
int scf_tmpl_error_source_fmri(const scf_tmpl_error_t *, char **);
int scf_tmpl_error_pg_tmpl(const scf_tmpl_error_t *, char **, char **);
int scf_tmpl_error_pg(const scf_tmpl_error_t *, char **, char **);
int scf_tmpl_error_prop_tmpl(const scf_tmpl_error_t *, char **, char **);
int scf_tmpl_error_prop(const scf_tmpl_error_t *, char **, char **);
int scf_tmpl_error_value(const scf_tmpl_error_t *, char **);
/*
* Simplified calls
*/
int smf_enable_instance(const char *, int);
int smf_disable_instance(const char *, int);
int smf_refresh_instance(const char *);
int smf_restart_instance(const char *);
int smf_maintain_instance(const char *, int);
int smf_degrade_instance(const char *, int);
int smf_restore_instance(const char *);
char *smf_get_state(const char *);
int scf_simple_walk_instances(uint_t, void *,
const char *, const char *);
void scf_simple_prop_free(scf_simple_prop_t *);
const scf_simple_app_props_t *, scf_simple_prop_t *);
const scf_simple_app_props_t *, const char *, const char *);
char *scf_simple_prop_name(const scf_simple_prop_t *);
char *scf_simple_prop_pgname(const scf_simple_prop_t *);
/*
* smf_state_from_string()
* return SCF_STATE_* value for the input
* -1 on error. String "all" maps to SCF_STATE_ALL macro
*/
int32_t smf_state_from_string(const char *);
/*
* smf_state_to_string()
* return SCF_STATE_STRING* value for the input
* NULL on error.
*/
const char *smf_state_to_string(int32_t);
/*
* Notification interfaces
*/
int smf_notify_set_params(const char *, nvlist_t *);
int smf_notify_del_params(const char *, const char *, int32_t);
/*
* SMF exit status definitions
*/
#define SMF_EXIT_OK 0
#ifdef __cplusplus
}
#endif
#endif /* _LIBSCF_H */