2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef _POOL_IMPL_H
2N/A#define _POOL_IMPL_H
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/*
2N/A * This file contains the definitions of types and supporting
2N/A * functions to implement the libpool generic data manipulation
2N/A * facility.
2N/A *
2N/A * libpool is designed so that the data representation/storage method
2N/A * used may be easily replaced without affecting core functionality.
2N/A * A libpool configuration is connected to a particular data
2N/A * representation/storage "driver" via the pool_connection_t
2N/A * type. When a configuration is opened (see pool_conf_open) the
2N/A * libpool implementation allocates a specific data manipulation type
2N/A * and initialises it. For instance, see pool_xml_connection_alloc.
2N/A *
2N/A * This function represents a cross-over point and all routines used
2N/A * for data representation/storage are controlled by the type of
2N/A * allocated connection.
2N/A *
2N/A * Currently, there are two implemented methods of access. Data may be
2N/A * retrieved from the kernel, using the pool_knl_connection_t
2N/A * function. This implementation relies on a private interface
2N/A * provided by a driver, /dev/pool, and presents data retrieved from
2N/A * the kernel via the standard libpool interface. Alternatively, data
2N/A * may be retrieved from an XML file, via pool_xml_connection_t, and
2N/A * presented through the standard libpool interface. For details of
2N/A * these two implementations, see pool_kernel_impl.h and
2N/A * pool_xml_impl.h.
2N/A *
2N/A * In addition to defining a specific connection type for a desired
2N/A * data representation/storage medium, several other structures must
2N/A * be defined to allow manipulation of configuration elements.
2N/A *
2N/A * Configuration elements are represented as pool_elem_t instances, or
2N/A * as sub-types of this generic type (such as pool_t, which represents
2N/A * a pool element) with groups (or sets) of these instances available
2N/A * for manipulation via the pool_result_set_t type.
2N/A *
2N/A * For more information on the implementation of these types, read the
2N/A * detailed comments above each structure definition.
2N/A */
2N/A
2N/A/*
2N/A * The pool_elem_t is used to represent a configuration element.The
2N/A * class of the element is stored within the structure along with a
2N/A * pointer to the containing configuration and a pointer to the
2N/A * element's specific subtype.
2N/A *
2N/A * The function pointers are initialised when the element is allocated
2N/A * to use the specific functions provided by the concrete data
2N/A * representation.
2N/A *
2N/A * The full set of operations that can be performed on an element
2N/A * which require special treatment from the data
2N/A * representation/storage medium are defined.
2N/A */
2N/Astruct pool_elem {
2N/A pool_conf_t *pe_conf; /* Configuration */
2N/A pool_elem_class_t pe_class; /* Element class */
2N/A pool_resource_elem_class_t pe_resource_class; /* Resource class */
2N/A pool_component_elem_class_t pe_component_class; /* Component class */
2N/A struct pool_elem *pe_pair; /* Static pair */
2N/A pool_value_class_t (*pe_get_prop)(const pool_elem_t *, const char *,
2N/A pool_value_t *);
2N/A int (*pe_put_prop)(pool_elem_t *, const char *, const pool_value_t *);
2N/A int (*pe_rm_prop)(pool_elem_t *, const char *);
2N/A pool_value_t **(*pe_get_props)(const pool_elem_t *, uint_t *);
2N/A int (*pe_remove)(pool_elem_t *);
2N/A pool_elem_t *(*pe_get_container)(const pool_elem_t *);
2N/A int (*pe_set_container)(pool_elem_t *, pool_elem_t *);
2N/A};
2N/A
2N/A/*
2N/A * libpool performs many operations against a pool_elem_t. This basic
2N/A * type is extended to provide specific functionality and type safety
2N/A * for each of the different types of element supported by
2N/A * libpool. There are four types of element:
2N/A * - pool_system_t, represents an entire configuration
2N/A * - pool_t, represents a single pool
2N/A * - pool_resource_t, represents a single resource
2N/A * - pool_component_t, represents a single resource component
2N/A *
2N/A * pool_system_t is an internal structure, the other structures are
2N/A * externally visible and form a major part of the libpool interface.
2N/A */
2N/Atypedef struct pool_system
2N/A{
2N/A pool_elem_t ps_elem;
2N/A void *pe_pad1;
2N/A void *pe_pad2;
2N/A} pool_system_t;
2N/A
2N/Astruct pool
2N/A{
2N/A pool_elem_t pp_elem;
2N/A /*
2N/A * Specific to pool_t
2N/A */
2N/A int (*pp_associate)(pool_t *, const pool_resource_t *);
2N/A int (*pp_dissociate)(pool_t *, const pool_resource_t *);
2N/A};
2N/A
2N/Astruct pool_resource
2N/A{
2N/A pool_elem_t pr_elem;
2N/A /*
2N/A * Specific to pool_resource_t
2N/A */
2N/A int (*pr_is_system)(const pool_resource_t *);
2N/A int (*pr_can_associate)(const pool_resource_t *);
2N/A};
2N/A
2N/Astruct pool_component
2N/A{
2N/A pool_elem_t pc_elem;
2N/A void *pe_pad1;
2N/A void *pe_pad2;
2N/A};
2N/A
2N/A/*
2N/A * The pool_result_set_t is used to represent a collection (set) of
2N/A * configuration elements. The configuration to which this result set
2N/A * applies is stored along with an indicator as to whether the result
2N/A * set is still in use.
2N/A *
2N/A * The function pointers are initialised when the element is allocated
2N/A * to use the specific functions provided by the concrete data
2N/A * representation.
2N/A *
2N/A * The full set of operations that can be performed on an element
2N/A * which require special treatment from the data
2N/A * representation/storage medium are defined.
2N/A */
2N/Atypedef struct pool_result_set {
2N/A pool_conf_t *prs_conf; /* Configuration */
2N/A int prs_active; /* Query active? */
2N/A int prs_index; /* Result Index */
2N/A pool_elem_t *(*prs_next)(struct pool_result_set *);
2N/A pool_elem_t *(*prs_prev)(struct pool_result_set *);
2N/A pool_elem_t *(*prs_first)(struct pool_result_set *);
2N/A pool_elem_t *(*prs_last)(struct pool_result_set *);
2N/A int (*prs_set_index)(struct pool_result_set *, int);
2N/A int (*prs_get_index)(struct pool_result_set *);
2N/A int (*prs_close)(struct pool_result_set *);
2N/A int (*prs_count)(struct pool_result_set *);
2N/A} pool_result_set_t;
2N/A
2N/A/*
2N/A * The pool_connection_t is used to represent a connection between a
2N/A * libpool configuration and a particular implementation of the
2N/A * libpool interface in a specific data representation/storage medium,
2N/A * e.g. XML.
2N/A *
2N/A * The name of the storage medium is stored along with the type of the
2N/A * data store.
2N/A *
2N/A * The function pointers are initialised when the element is allocated
2N/A * to use the specific functions provided by the concrete data
2N/A * representation.
2N/A *
2N/A * The full set of operations that can be performed on an element
2N/A * which require special treatment from the data
2N/A * representation/storage medium are defined.
2N/A */
2N/Atypedef struct pool_connection {
2N/A const char *pc_name; /* Provider name */
2N/A int pc_store_type; /* Datastore type */
2N/A int pc_oflags; /* Open flags */
2N/A int (*pc_close)(pool_conf_t *);
2N/A int (*pc_validate)(const pool_conf_t *, pool_valid_level_t);
2N/A int (*pc_commit)(pool_conf_t *);
2N/A int (*pc_export)(const pool_conf_t *, const char *,
2N/A pool_export_format_t);
2N/A int (*pc_rollback)(pool_conf_t *);
2N/A pool_result_set_t *(*pc_exec_query)(const pool_conf_t *,
2N/A const pool_elem_t *, const char *, pool_elem_class_t,
2N/A pool_value_t **);
2N/A pool_elem_t *(*pc_elem_create)(pool_conf_t *, pool_elem_class_t,
2N/A pool_resource_elem_class_t, pool_component_elem_class_t);
2N/A int (*pc_remove)(pool_conf_t *);
2N/A int (*pc_res_xfer)(pool_resource_t *, pool_resource_t *, uint64_t);
2N/A int (*pc_res_xxfer)(pool_resource_t *, pool_resource_t *,
2N/A pool_component_t **);
2N/A char *(*pc_get_binding)(pool_conf_t *, pid_t);
2N/A int (*pc_set_binding)(pool_conf_t *, const char *, idtype_t, id_t);
2N/A char *(*pc_get_resource_binding)(pool_conf_t *,
2N/A pool_resource_elem_class_t, pid_t);
2N/A} pool_connection_t;
2N/A
2N/A/*
2N/A * pool_conf represents a resource management configuration. The
2N/A * configuration location is stored in the pc_location member with the
2N/A * state of the configuration stored in pc_state.
2N/A *
2N/A * The pc_prov member provides data representation/storage abstraction
2N/A * for the configuration since all access to data is performed through
2N/A * this member.
2N/A */
2N/Astruct pool_conf {
2N/A const char *pc_location; /* Location */
2N/A pool_connection_t *pc_prov; /* Data Provider */
2N/A pool_conf_state_t pc_state; /* State */
2N/A};
2N/A
2N/A/*
2N/A * Convert a pool_elem_t to it's appropriate sub-type.
2N/A */
2N/Aextern pool_system_t *pool_conf_system(const pool_conf_t *);
2N/Aextern pool_system_t *pool_elem_system(const pool_elem_t *);
2N/Aextern pool_t *pool_elem_pool(const pool_elem_t *);
2N/Aextern pool_resource_t *pool_elem_res(const pool_elem_t *);
2N/Aextern pool_component_t *pool_elem_comp(const pool_elem_t *);
2N/A
2N/A/*
2N/A * Convert a pool_system_t to a pool_elem_t.
2N/A */
2N/Aextern pool_elem_t *pool_system_elem(const pool_system_t *);
2N/A
2N/A/*
2N/A * Get/Set an element's "pair" element. A pair element is a temporary
2N/A * association at commit between an element in the dynamic
2N/A * configuration and an element in the static configuration. This
2N/A * relationship is stored in the pe_pair member of the element.
2N/A */
2N/Aextern pool_elem_t *pool_get_pair(const pool_elem_t *);
2N/Aextern void pool_set_pair(pool_elem_t *, pool_elem_t *);
2N/A
2N/A/*
2N/A * Result Set Manipulation
2N/A */
2N/Aextern pool_elem_t *pool_rs_next(pool_result_set_t *);
2N/Aextern pool_elem_t *pool_rs_prev(pool_result_set_t *);
2N/Aextern pool_elem_t *pool_rs_first(pool_result_set_t *);
2N/Aextern pool_elem_t *pool_rs_last(pool_result_set_t *);
2N/Aextern int pool_rs_count(pool_result_set_t *);
2N/Aextern int pool_rs_get_index(pool_result_set_t *);
2N/Aextern int pool_rs_set_index(pool_result_set_t *, int);
2N/Aextern int pool_rs_close(pool_result_set_t *);
2N/A
2N/A/*
2N/A * General Purpose Query
2N/A */
2N/Aextern pool_result_set_t *pool_exec_query(const pool_conf_t *,
2N/A const pool_elem_t *, const char *, pool_elem_class_t, pool_value_t **);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _POOL_IMPL_H */