10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*3247Sgjelinek * Common Development and Distribution License (the "License"). 6*3247Sgjelinek * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*3247Sgjelinek * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _POOL_INTERNAL_H 270Sstevel@tonic-gate #define _POOL_INTERNAL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <libnvpair.h> 320Sstevel@tonic-gate #include <stdarg.h> 330Sstevel@tonic-gate #include <sys/pool.h> 340Sstevel@tonic-gate #include <sys/pool_impl.h> 350Sstevel@tonic-gate 360Sstevel@tonic-gate #ifdef __cplusplus 370Sstevel@tonic-gate extern "C" { 380Sstevel@tonic-gate #endif 390Sstevel@tonic-gate 400Sstevel@tonic-gate /* 410Sstevel@tonic-gate * This file contains the libpool internal definitions which are not 420Sstevel@tonic-gate * directly related to the data access abstraction logic. 430Sstevel@tonic-gate */ 440Sstevel@tonic-gate 450Sstevel@tonic-gate /* 460Sstevel@tonic-gate * Define the various query specifiers for use in the 470Sstevel@tonic-gate * pool_connection_t query function, pc_exec_query. 480Sstevel@tonic-gate */ 490Sstevel@tonic-gate 500Sstevel@tonic-gate #define PEC_QRY_ANY (PEC_QRY_SYSTEM | PEC_QRY_POOL | PEC_QRY_RES | \ 510Sstevel@tonic-gate PEC_QRY_COMP) 520Sstevel@tonic-gate #define PEC_QRY_SYSTEM (1 << PEC_SYSTEM) 530Sstevel@tonic-gate #define PEC_QRY_POOL (1 << PEC_POOL) 540Sstevel@tonic-gate #define PEC_QRY_RES (PEC_QRY_RES_COMP | PEC_QRY_RES_AGG) 550Sstevel@tonic-gate #define PEC_QRY_RES_COMP (1 << PEC_RES_COMP) 560Sstevel@tonic-gate #define PEC_QRY_RES_AGG (1 << PEC_RES_AGG) 570Sstevel@tonic-gate #define PEC_QRY_COMP (1 << PEC_COMP) 580Sstevel@tonic-gate #define PEC_QRY_ELEM(e) (1 << pool_elem_class(e)) 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* 610Sstevel@tonic-gate * Internal type conversion macros 620Sstevel@tonic-gate */ 630Sstevel@tonic-gate #define TO_ELEM(s) ((pool_elem_t *)s) 640Sstevel@tonic-gate /* 650Sstevel@tonic-gate * Get the configuration to which the supplied element belongs. 660Sstevel@tonic-gate */ 670Sstevel@tonic-gate #define TO_CONF(s) (s->pe_conf) 680Sstevel@tonic-gate 690Sstevel@tonic-gate /* 700Sstevel@tonic-gate * Known Data Store Types 710Sstevel@tonic-gate */ 720Sstevel@tonic-gate 730Sstevel@tonic-gate #define XML_DATA_STORE 0 740Sstevel@tonic-gate #define KERNEL_DATA_STORE 1 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* 770Sstevel@tonic-gate * Limits on pool values names and strings 780Sstevel@tonic-gate */ 790Sstevel@tonic-gate #define PV_NAME_MAX_LEN 1024 800Sstevel@tonic-gate #define PV_VALUE_MAX_LEN 1024 810Sstevel@tonic-gate 820Sstevel@tonic-gate /* 830Sstevel@tonic-gate * CB_TAB_BUF_SIZE represents the maximum number of indents to which a 840Sstevel@tonic-gate * char_buf_t is expected to grow. This value would need to be raised 850Sstevel@tonic-gate * if it was ever exceeded. It is an arbitrary limit, but currently 860Sstevel@tonic-gate * the implementation does not exceed a depth of 4. 870Sstevel@tonic-gate */ 880Sstevel@tonic-gate 890Sstevel@tonic-gate #define CB_TAB_BUF_SIZE 8 900Sstevel@tonic-gate #define CB_DEFAULT_LEN 256 910Sstevel@tonic-gate 920Sstevel@tonic-gate /* 930Sstevel@tonic-gate * Helpful pset macros 940Sstevel@tonic-gate */ 950Sstevel@tonic-gate #define PSID_IS_SYSSET(psid) (psid == PS_NONE) 960Sstevel@tonic-gate #define POOL_SYSID_BAD (-2) 970Sstevel@tonic-gate #define POOL_SYSID_BAD_STRING "-2" 980Sstevel@tonic-gate 990Sstevel@tonic-gate /* 1000Sstevel@tonic-gate * Size of generated ref_id buffer 1010Sstevel@tonic-gate */ 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate #define KEY_BUFFER_SIZE 48 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* 1060Sstevel@tonic-gate * Various useful constant strings which are often encountered 1070Sstevel@tonic-gate */ 1080Sstevel@tonic-gate extern const char *c_a_dtype; 1090Sstevel@tonic-gate extern const char *c_name; 1100Sstevel@tonic-gate extern const char *c_type; 1110Sstevel@tonic-gate extern const char *c_ref_id; 1120Sstevel@tonic-gate extern const char *c_max_prop; 1130Sstevel@tonic-gate extern const char *c_min_prop; 1140Sstevel@tonic-gate extern const char *c_size_prop; 1150Sstevel@tonic-gate extern const char *c_sys_prop; 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate /* 1180Sstevel@tonic-gate * The char_buf_t type is a very simple string implementation which 1190Sstevel@tonic-gate * makes it easier to manipulate complex character data. 1200Sstevel@tonic-gate */ 1210Sstevel@tonic-gate typedef struct char_buf 1220Sstevel@tonic-gate { 1230Sstevel@tonic-gate size_t cb_size; 1240Sstevel@tonic-gate char *cb_buf; 1250Sstevel@tonic-gate char cb_tab_buf[CB_TAB_BUF_SIZE]; 1260Sstevel@tonic-gate } char_buf_t; 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate /* 1290Sstevel@tonic-gate * libpool uses an opaque discriminated union type, pool_value_t, to 1300Sstevel@tonic-gate * contain values which are used to get/set properties on 1310Sstevel@tonic-gate * configuration components. Each value is strictly typed and the 1320Sstevel@tonic-gate * functions to manipulate these types are exported through the 1330Sstevel@tonic-gate * external interface. 1340Sstevel@tonic-gate */ 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate /* 1370Sstevel@tonic-gate * Initialize a pool_value_t 1380Sstevel@tonic-gate */ 1390Sstevel@tonic-gate #define POOL_VALUE_INITIALIZER /* = DEFAULT POOL VALUE */ \ 1400Sstevel@tonic-gate {POC_INVAL, NULL, NULL } 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate struct pool_value { 1430Sstevel@tonic-gate pool_value_class_t pv_class; /* Value type */ 1440Sstevel@tonic-gate const char *pv_name; /* Value name */ 1450Sstevel@tonic-gate union 1460Sstevel@tonic-gate { 1470Sstevel@tonic-gate uint64_t u; 1480Sstevel@tonic-gate int64_t i; 1490Sstevel@tonic-gate double d; 1500Sstevel@tonic-gate uchar_t b; 1510Sstevel@tonic-gate const char *s; 1520Sstevel@tonic-gate } pv_u; 1530Sstevel@tonic-gate }; 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate /* 1560Sstevel@tonic-gate * The pool_prop_op_t structure is used to perform property specific validation 1570Sstevel@tonic-gate * when setting the values of properties in a plugin and when getting a property 1580Sstevel@tonic-gate * value which is not stored (i.e. it is generated dynamically by the plugin at 1590Sstevel@tonic-gate * access. 1600Sstevel@tonic-gate * 1610Sstevel@tonic-gate * - ppo_get_value will provide a value for the specified property 1620Sstevel@tonic-gate * - ppo_set_value will allow a provider to validate a value before setting it 1630Sstevel@tonic-gate */ 1640Sstevel@tonic-gate typedef struct pool_prop_op { 1650Sstevel@tonic-gate int (*ppo_get_value)(const pool_elem_t *, pool_value_t *); 1660Sstevel@tonic-gate int (*ppo_set_value)(pool_elem_t *, const pool_value_t *); 1670Sstevel@tonic-gate } pool_prop_op_t; 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate /* 1700Sstevel@tonic-gate * The pool_prop_t structure is used to hold all property related information 1710Sstevel@tonic-gate * for each property that a provider is interested in. 1720Sstevel@tonic-gate * 1730Sstevel@tonic-gate * - pp_pname is the name of the property 1740Sstevel@tonic-gate * - pp_value is the initial value of the property 1750Sstevel@tonic-gate * - pp_perms is an OR'd bitmap of the access characteristics for the property 1760Sstevel@tonic-gate * - pp_init is a function which initialises the value member of the property 1770Sstevel@tonic-gate * - pp_op is optional and supports access and validation of property values 1780Sstevel@tonic-gate */ 1790Sstevel@tonic-gate typedef struct pool_prop { 1800Sstevel@tonic-gate const char *pp_pname; 1810Sstevel@tonic-gate pool_value_t pp_value; 1820Sstevel@tonic-gate uint_t pp_perms; 1830Sstevel@tonic-gate int (*pp_init)(struct pool_prop *); 1840Sstevel@tonic-gate pool_prop_op_t pp_op; 1850Sstevel@tonic-gate } pool_prop_t; 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate /* 1880Sstevel@tonic-gate * log state 1890Sstevel@tonic-gate */ 1900Sstevel@tonic-gate enum log_state { 1910Sstevel@tonic-gate LS_DO, 1920Sstevel@tonic-gate LS_UNDO, 1930Sstevel@tonic-gate LS_RECOVER, 1940Sstevel@tonic-gate LS_FAIL 1950Sstevel@tonic-gate }; 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate /* 1980Sstevel@tonic-gate * Forward declaration 1990Sstevel@tonic-gate */ 2000Sstevel@tonic-gate typedef struct log log_t; 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate /* 2030Sstevel@tonic-gate * log item. 2040Sstevel@tonic-gate * 2050Sstevel@tonic-gate * Used to describe each operation which needs to be logged. When 2060Sstevel@tonic-gate * modifications are desired to the kernel, they are logged in the 2070Sstevel@tonic-gate * configuration log file. If the user commits the changes, then the 2080Sstevel@tonic-gate * log entries are processed in sequence. If rollback is called, the 2090Sstevel@tonic-gate * log is dismissed without being processed. If the commit operation 2100Sstevel@tonic-gate * fails, then the log is "rolled back" to undo the previously 2110Sstevel@tonic-gate * successful operations. 2120Sstevel@tonic-gate */ 2130Sstevel@tonic-gate typedef struct log_item { 2140Sstevel@tonic-gate log_t *li_log; /* Log containing this item */ 2150Sstevel@tonic-gate int li_op; /* Type of operation */ 2160Sstevel@tonic-gate void *li_details; /* Operation details */ 2170Sstevel@tonic-gate struct log_item *li_next; /* List of log items */ 2180Sstevel@tonic-gate struct log_item *li_prev; /* List of log items */ 2190Sstevel@tonic-gate enum log_state li_state; /* Item state */ 2200Sstevel@tonic-gate } log_item_t; 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate /* 2230Sstevel@tonic-gate * log. 2240Sstevel@tonic-gate * 2250Sstevel@tonic-gate * This maintains a list of log items. The sentinel is used to 2260Sstevel@tonic-gate * simplify processing around the "empty list". The state of the log 2270Sstevel@tonic-gate * indicates whether transactions are being processed normally, or 2280Sstevel@tonic-gate * whether recovery is in progress. 2290Sstevel@tonic-gate */ 2300Sstevel@tonic-gate struct log 2310Sstevel@tonic-gate { 2320Sstevel@tonic-gate pool_conf_t *l_conf; /* Configuration for this log */ 2330Sstevel@tonic-gate log_item_t *l_sentinel; /* Log sentinel */ 2340Sstevel@tonic-gate enum log_state l_state; /* Log state */ 2350Sstevel@tonic-gate }; 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate 2380Sstevel@tonic-gate /* 2390Sstevel@tonic-gate * log item action function type 2400Sstevel@tonic-gate */ 2410Sstevel@tonic-gate typedef int (*log_item_action_t)(log_item_t *); 2420Sstevel@tonic-gate 2430Sstevel@tonic-gate /* 2440Sstevel@tonic-gate * Get the max/min/size property value of a resource. 2450Sstevel@tonic-gate */ 2460Sstevel@tonic-gate extern int resource_get_max(const pool_resource_t *, uint64_t *); 2470Sstevel@tonic-gate extern int resource_get_min(const pool_resource_t *, uint64_t *); 2480Sstevel@tonic-gate extern int resource_get_size(const pool_resource_t *, uint64_t *); 2490Sstevel@tonic-gate extern int resource_get_pinned(const pool_resource_t *, 2500Sstevel@tonic-gate uint64_t *); 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate /* 2530Sstevel@tonic-gate * Element utility operations. 2540Sstevel@tonic-gate */ 2550Sstevel@tonic-gate extern char *elem_get_name(const pool_elem_t *); 2560Sstevel@tonic-gate extern id_t elem_get_sysid(const pool_elem_t *); 2570Sstevel@tonic-gate extern int elem_is_default(const pool_elem_t *); 258*3247Sgjelinek extern boolean_t elem_is_tmp(const pool_elem_t *); 2590Sstevel@tonic-gate extern const pool_elem_t *get_default_elem(const pool_elem_t *); 2600Sstevel@tonic-gate extern int qsort_elem_compare(const void *, const void *); 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate /* 2630Sstevel@tonic-gate * Get the class of the supplied element. 2640Sstevel@tonic-gate */ 2650Sstevel@tonic-gate extern const char *pool_elem_class_string(const pool_elem_t *); 2660Sstevel@tonic-gate extern const char *pool_resource_type_string(pool_resource_elem_class_t); 2670Sstevel@tonic-gate extern const char *pool_component_type_string(pool_component_elem_class_t); 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate /* 2700Sstevel@tonic-gate * Commit the supplied configuration to the system. This function 2710Sstevel@tonic-gate * attempts to make the system look like the supplied configuration. 2720Sstevel@tonic-gate */ 2730Sstevel@tonic-gate extern int pool_conf_commit_sys(pool_conf_t *, int); 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate /* 2760Sstevel@tonic-gate * Allocate an XML/kernel connection to a data representation. 2770Sstevel@tonic-gate */ 2780Sstevel@tonic-gate extern int pool_xml_connection_alloc(pool_conf_t *, int); 2790Sstevel@tonic-gate extern int pool_knl_connection_alloc(pool_conf_t *, int); 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate /* 2820Sstevel@tonic-gate * Create/Destroy a pool component belonging to the supplied resource 2830Sstevel@tonic-gate */ 2840Sstevel@tonic-gate extern pool_component_t *pool_component_create(pool_conf_t *, 2850Sstevel@tonic-gate const pool_resource_t *, int64_t); 2860Sstevel@tonic-gate extern int pool_component_destroy(pool_component_t *); 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate /* 2890Sstevel@tonic-gate * Get/Set the owner (container) of a particular configuration 2900Sstevel@tonic-gate * element. 2910Sstevel@tonic-gate */ 2920Sstevel@tonic-gate extern pool_elem_t *pool_get_container(const pool_elem_t *); 2930Sstevel@tonic-gate extern int pool_set_container(pool_elem_t *, pool_elem_t *); 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate /* 2960Sstevel@tonic-gate * These functions are used for debugging. Setting the environment 2970Sstevel@tonic-gate * variable LIBPOOL_DEBUG to 1, enables these functions. 2980Sstevel@tonic-gate */ 2990Sstevel@tonic-gate extern void do_dprintf(const char *, va_list); 3000Sstevel@tonic-gate extern void dprintf(const char *, ...); 3010Sstevel@tonic-gate 3020Sstevel@tonic-gate /* 3030Sstevel@tonic-gate * libpool maintains it's own error value, rather than further pollute 3040Sstevel@tonic-gate * errno, this function is used to set the current error value for 3050Sstevel@tonic-gate * retrieval. 3060Sstevel@tonic-gate */ 3070Sstevel@tonic-gate extern void pool_seterror(int); 3080Sstevel@tonic-gate 3090Sstevel@tonic-gate /* 3100Sstevel@tonic-gate * Element Class 3110Sstevel@tonic-gate */ 3120Sstevel@tonic-gate extern pool_elem_class_t pool_elem_class(const pool_elem_t *); 3130Sstevel@tonic-gate extern pool_resource_elem_class_t pool_resource_elem_class(const pool_elem_t *); 3140Sstevel@tonic-gate extern pool_component_elem_class_t pool_component_elem_class(const 3150Sstevel@tonic-gate pool_elem_t *); 3160Sstevel@tonic-gate extern int pool_elem_same_class(const pool_elem_t *, const pool_elem_t *); 3170Sstevel@tonic-gate extern pool_elem_class_t pool_elem_class_from_string(const char *); 3180Sstevel@tonic-gate extern pool_resource_elem_class_t pool_resource_elem_class_from_string(const 3190Sstevel@tonic-gate char *); 3200Sstevel@tonic-gate extern pool_component_elem_class_t pool_component_elem_class_from_string(const 3210Sstevel@tonic-gate char *); 3220Sstevel@tonic-gate 3230Sstevel@tonic-gate /* 3240Sstevel@tonic-gate * Element Equivalency 3250Sstevel@tonic-gate */ 3260Sstevel@tonic-gate extern int pool_elem_compare(const pool_elem_t *, 3270Sstevel@tonic-gate const pool_elem_t *); 3280Sstevel@tonic-gate extern int pool_elem_compare_name(const pool_elem_t *, 3290Sstevel@tonic-gate const pool_elem_t *); 3300Sstevel@tonic-gate 3310Sstevel@tonic-gate /* 3320Sstevel@tonic-gate * Dynamic character buffers. Limited functionality but enough for our 3330Sstevel@tonic-gate * purposes. 3340Sstevel@tonic-gate */ 3350Sstevel@tonic-gate extern char_buf_t *alloc_char_buf(size_t); 3360Sstevel@tonic-gate extern void free_char_buf(char_buf_t *); 3370Sstevel@tonic-gate extern int set_char_buf(char_buf_t *, const char *, ...); 3380Sstevel@tonic-gate extern int append_char_buf(char_buf_t *, const char *, ...); 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate /* 3410Sstevel@tonic-gate * Internal functions for use with pool values. 3420Sstevel@tonic-gate */ 3430Sstevel@tonic-gate extern int pool_value_equal(pool_value_t *, pool_value_t *); 3440Sstevel@tonic-gate extern int pool_value_from_nvpair(pool_value_t *, nvpair_t *); 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate /* 3470Sstevel@tonic-gate * Check to ensure that the supplied string is a valid name for a pool 3480Sstevel@tonic-gate * element. 3490Sstevel@tonic-gate */ 3500Sstevel@tonic-gate extern int is_valid_name(const char *); 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate /* 3530Sstevel@tonic-gate * Functions related to element prefix manipulation. You can get the 3540Sstevel@tonic-gate * prefix for a supplied element or find out if a supplied string is a 3550Sstevel@tonic-gate * valid prefix for a certain class of element. 3560Sstevel@tonic-gate */ 3570Sstevel@tonic-gate extern const char *elem_get_prefix(const pool_elem_t *); 3580Sstevel@tonic-gate extern const char *is_a_known_prefix(pool_elem_class_t, const char *); 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate /* 3610Sstevel@tonic-gate * Internal property manipulators 3620Sstevel@tonic-gate */ 3630Sstevel@tonic-gate extern int pool_put_ns_property(pool_elem_t *, const char *, 3640Sstevel@tonic-gate const pool_value_t *); 3650Sstevel@tonic-gate extern int pool_put_any_property(pool_elem_t *, const char *, 3660Sstevel@tonic-gate const pool_value_t *); 3670Sstevel@tonic-gate extern int pool_put_any_ns_property(pool_elem_t *, const char *, 3680Sstevel@tonic-gate const pool_value_t *); 3690Sstevel@tonic-gate extern pool_value_class_t pool_get_ns_property(const pool_elem_t *, 3700Sstevel@tonic-gate const char *, pool_value_t *); 3710Sstevel@tonic-gate extern int pool_walk_any_properties(pool_conf_t *, pool_elem_t *, 3720Sstevel@tonic-gate void *, int (*)(pool_conf_t *, pool_elem_t *, const char *, 3730Sstevel@tonic-gate pool_value_t *, void *), int); 374*3247Sgjelinek extern int pool_set_temporary(pool_conf_t *, pool_elem_t *); 3750Sstevel@tonic-gate 3760Sstevel@tonic-gate /* 3770Sstevel@tonic-gate * Namespace aware utility functions. 3780Sstevel@tonic-gate */ 3790Sstevel@tonic-gate extern const char *is_ns_property(const pool_elem_t *, const char *); 3800Sstevel@tonic-gate extern const char *property_name_minus_ns(const pool_elem_t *, 3810Sstevel@tonic-gate const char *); 3820Sstevel@tonic-gate 3830Sstevel@tonic-gate /* 3840Sstevel@tonic-gate * Initialisation routines. 3850Sstevel@tonic-gate */ 3860Sstevel@tonic-gate extern void internal_init(void); 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate /* 3890Sstevel@tonic-gate * Is the supplied configuration the dynamic configuration? 3900Sstevel@tonic-gate */ 3910Sstevel@tonic-gate extern int conf_is_dynamic(const pool_conf_t *); 3920Sstevel@tonic-gate 3930Sstevel@tonic-gate /* 3940Sstevel@tonic-gate * Update the library snapshot from the kernel 3950Sstevel@tonic-gate */ 3960Sstevel@tonic-gate extern int pool_knl_update(pool_conf_t *, int *); 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate /* 3990Sstevel@tonic-gate * Resource property functions 4000Sstevel@tonic-gate */ 4010Sstevel@tonic-gate extern int resource_is_default(const pool_resource_t *); 4020Sstevel@tonic-gate extern int resource_is_system(const pool_resource_t *); 4030Sstevel@tonic-gate extern int resource_can_associate(const pool_resource_t *); 4040Sstevel@tonic-gate extern const pool_resource_t *get_default_resource(const pool_resource_t *); 4050Sstevel@tonic-gate extern pool_resource_t *resource_by_sysid(const pool_conf_t *, id_t, 4060Sstevel@tonic-gate const char *); 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate /* 4090Sstevel@tonic-gate * Resource property provider functions 4100Sstevel@tonic-gate */ 4110Sstevel@tonic-gate extern uint_t pool_get_provider_count(void); 4120Sstevel@tonic-gate extern const pool_prop_t *provider_get_props(const pool_elem_t *); 4130Sstevel@tonic-gate extern const pool_prop_t *provider_get_prop(const pool_elem_t *, 4140Sstevel@tonic-gate const char *); 4150Sstevel@tonic-gate extern int prop_is_stored(const pool_prop_t *); 4160Sstevel@tonic-gate extern int prop_is_readonly(const pool_prop_t *); 4170Sstevel@tonic-gate extern int prop_is_init(const pool_prop_t *); 4180Sstevel@tonic-gate extern int prop_is_hidden(const pool_prop_t *); 4190Sstevel@tonic-gate extern int prop_is_optional(const pool_prop_t *); 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate /* 4220Sstevel@tonic-gate * Component property functions 4230Sstevel@tonic-gate */ 4240Sstevel@tonic-gate extern int cpu_is_requested(pool_component_t *); 4250Sstevel@tonic-gate 4260Sstevel@tonic-gate /* 4270Sstevel@tonic-gate * Simple initialisation routines for values used when initialising the 4280Sstevel@tonic-gate * property arrays for each plugin 4290Sstevel@tonic-gate * Return PO_SUCCESS/PO_FAIL to indicate success/failure 4300Sstevel@tonic-gate */ 4310Sstevel@tonic-gate extern int uint_init(pool_prop_t *, uint64_t); 4320Sstevel@tonic-gate extern int int_init(pool_prop_t *, int64_t); 4330Sstevel@tonic-gate extern int double_init(pool_prop_t *, double); 4340Sstevel@tonic-gate extern int bool_init(pool_prop_t *, uchar_t); 4350Sstevel@tonic-gate extern int string_init(pool_prop_t *, const char *); 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate 4380Sstevel@tonic-gate /* 4390Sstevel@tonic-gate * log functions 4400Sstevel@tonic-gate */ 4410Sstevel@tonic-gate extern log_t *log_alloc(pool_conf_t *); 4420Sstevel@tonic-gate extern void log_free(log_t *); 4430Sstevel@tonic-gate extern void log_empty(log_t *); 4440Sstevel@tonic-gate extern int log_walk(log_t *, log_item_action_t); 4450Sstevel@tonic-gate extern int log_reverse_walk(log_t *, log_item_action_t); 4460Sstevel@tonic-gate extern uint_t log_size(log_t *); 4470Sstevel@tonic-gate extern int log_append(log_t *, int, void *); 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate /* 4500Sstevel@tonic-gate * log item functions 4510Sstevel@tonic-gate */ 4520Sstevel@tonic-gate extern log_item_t *log_item_alloc(log_t *, int, void *); 4530Sstevel@tonic-gate extern int log_item_free(log_item_t *); 4540Sstevel@tonic-gate 4550Sstevel@tonic-gate extern int pool_validate_resource(const pool_conf_t *, 4560Sstevel@tonic-gate const char *, const char *, int64_t); 4570Sstevel@tonic-gate 4580Sstevel@tonic-gate /* 4590Sstevel@tonic-gate * String atom functions 4600Sstevel@tonic-gate */ 4610Sstevel@tonic-gate extern const char *atom_string(const char *); 4620Sstevel@tonic-gate extern void atom_free(const char *); 4630Sstevel@tonic-gate /* 4640Sstevel@tonic-gate * debugging functions 4650Sstevel@tonic-gate */ 4660Sstevel@tonic-gate #ifdef DEBUG 4670Sstevel@tonic-gate extern void log_item_dprintf(log_item_t *); 4680Sstevel@tonic-gate extern void pool_value_dprintf(const pool_value_t *); 4690Sstevel@tonic-gate extern void pool_elem_dprintf(const pool_elem_t *); 4700Sstevel@tonic-gate #endif 4710Sstevel@tonic-gate 4720Sstevel@tonic-gate #ifdef __cplusplus 4730Sstevel@tonic-gate } 4740Sstevel@tonic-gate #endif 4750Sstevel@tonic-gate 4760Sstevel@tonic-gate #endif /* _POOL_INTERNAL_H */ 477