17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50209230bSgjelinek * Common Development and Distribution License (the "License"). 60209230bSgjelinek * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 220209230bSgjelinek * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _POOL_INTERNAL_H 277c478bd9Sstevel@tonic-gate #define _POOL_INTERNAL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <libnvpair.h> 307c478bd9Sstevel@tonic-gate #include <stdarg.h> 317c478bd9Sstevel@tonic-gate #include <sys/pool.h> 327c478bd9Sstevel@tonic-gate #include <sys/pool_impl.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * This file contains the libpool internal definitions which are not 407c478bd9Sstevel@tonic-gate * directly related to the data access abstraction logic. 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * Define the various query specifiers for use in the 457c478bd9Sstevel@tonic-gate * pool_connection_t query function, pc_exec_query. 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate #define PEC_QRY_ANY (PEC_QRY_SYSTEM | PEC_QRY_POOL | PEC_QRY_RES | \ 497c478bd9Sstevel@tonic-gate PEC_QRY_COMP) 507c478bd9Sstevel@tonic-gate #define PEC_QRY_SYSTEM (1 << PEC_SYSTEM) 517c478bd9Sstevel@tonic-gate #define PEC_QRY_POOL (1 << PEC_POOL) 527c478bd9Sstevel@tonic-gate #define PEC_QRY_RES (PEC_QRY_RES_COMP | PEC_QRY_RES_AGG) 537c478bd9Sstevel@tonic-gate #define PEC_QRY_RES_COMP (1 << PEC_RES_COMP) 547c478bd9Sstevel@tonic-gate #define PEC_QRY_RES_AGG (1 << PEC_RES_AGG) 557c478bd9Sstevel@tonic-gate #define PEC_QRY_COMP (1 << PEC_COMP) 567c478bd9Sstevel@tonic-gate #define PEC_QRY_ELEM(e) (1 << pool_elem_class(e)) 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * Internal type conversion macros 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate #define TO_ELEM(s) ((pool_elem_t *)s) 627c478bd9Sstevel@tonic-gate /* 637c478bd9Sstevel@tonic-gate * Get the configuration to which the supplied element belongs. 647c478bd9Sstevel@tonic-gate */ 657c478bd9Sstevel@tonic-gate #define TO_CONF(s) (s->pe_conf) 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* 687c478bd9Sstevel@tonic-gate * Known Data Store Types 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate #define XML_DATA_STORE 0 727c478bd9Sstevel@tonic-gate #define KERNEL_DATA_STORE 1 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * Limits on pool values names and strings 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate #define PV_NAME_MAX_LEN 1024 787c478bd9Sstevel@tonic-gate #define PV_VALUE_MAX_LEN 1024 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* 817c478bd9Sstevel@tonic-gate * CB_TAB_BUF_SIZE represents the maximum number of indents to which a 827c478bd9Sstevel@tonic-gate * char_buf_t is expected to grow. This value would need to be raised 837c478bd9Sstevel@tonic-gate * if it was ever exceeded. It is an arbitrary limit, but currently 847c478bd9Sstevel@tonic-gate * the implementation does not exceed a depth of 4. 857c478bd9Sstevel@tonic-gate */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate #define CB_TAB_BUF_SIZE 8 887c478bd9Sstevel@tonic-gate #define CB_DEFAULT_LEN 256 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate /* 917c478bd9Sstevel@tonic-gate * Helpful pset macros 927c478bd9Sstevel@tonic-gate */ 937c478bd9Sstevel@tonic-gate #define PSID_IS_SYSSET(psid) (psid == PS_NONE) 947c478bd9Sstevel@tonic-gate #define POOL_SYSID_BAD (-2) 957c478bd9Sstevel@tonic-gate #define POOL_SYSID_BAD_STRING "-2" 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * Size of generated ref_id buffer 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate #define KEY_BUFFER_SIZE 48 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * Various useful constant strings which are often encountered 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate extern const char *c_a_dtype; 1077c478bd9Sstevel@tonic-gate extern const char *c_name; 1087c478bd9Sstevel@tonic-gate extern const char *c_type; 1097c478bd9Sstevel@tonic-gate extern const char *c_ref_id; 1107c478bd9Sstevel@tonic-gate extern const char *c_max_prop; 1117c478bd9Sstevel@tonic-gate extern const char *c_min_prop; 1127c478bd9Sstevel@tonic-gate extern const char *c_size_prop; 1137c478bd9Sstevel@tonic-gate extern const char *c_sys_prop; 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate /* 1167c478bd9Sstevel@tonic-gate * The char_buf_t type is a very simple string implementation which 1177c478bd9Sstevel@tonic-gate * makes it easier to manipulate complex character data. 1187c478bd9Sstevel@tonic-gate */ 1197c478bd9Sstevel@tonic-gate typedef struct char_buf 1207c478bd9Sstevel@tonic-gate { 1217c478bd9Sstevel@tonic-gate size_t cb_size; 1227c478bd9Sstevel@tonic-gate char *cb_buf; 1237c478bd9Sstevel@tonic-gate char cb_tab_buf[CB_TAB_BUF_SIZE]; 1247c478bd9Sstevel@tonic-gate } char_buf_t; 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * libpool uses an opaque discriminated union type, pool_value_t, to 1287c478bd9Sstevel@tonic-gate * contain values which are used to get/set properties on 1297c478bd9Sstevel@tonic-gate * configuration components. Each value is strictly typed and the 1307c478bd9Sstevel@tonic-gate * functions to manipulate these types are exported through the 1317c478bd9Sstevel@tonic-gate * external interface. 1327c478bd9Sstevel@tonic-gate */ 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * Initialize a pool_value_t 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate #define POOL_VALUE_INITIALIZER /* = DEFAULT POOL VALUE */ \ 138*29d92041SToomas Soome {POC_INVAL, NULL, 0 } 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate struct pool_value { 1417c478bd9Sstevel@tonic-gate pool_value_class_t pv_class; /* Value type */ 1427c478bd9Sstevel@tonic-gate const char *pv_name; /* Value name */ 1437c478bd9Sstevel@tonic-gate union 1447c478bd9Sstevel@tonic-gate { 1457c478bd9Sstevel@tonic-gate uint64_t u; 1467c478bd9Sstevel@tonic-gate int64_t i; 1477c478bd9Sstevel@tonic-gate double d; 1487c478bd9Sstevel@tonic-gate uchar_t b; 1497c478bd9Sstevel@tonic-gate const char *s; 1507c478bd9Sstevel@tonic-gate } pv_u; 1517c478bd9Sstevel@tonic-gate }; 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* 1547c478bd9Sstevel@tonic-gate * The pool_prop_op_t structure is used to perform property specific validation 1557c478bd9Sstevel@tonic-gate * when setting the values of properties in a plugin and when getting a property 1567c478bd9Sstevel@tonic-gate * value which is not stored (i.e. it is generated dynamically by the plugin at 1577c478bd9Sstevel@tonic-gate * access. 1587c478bd9Sstevel@tonic-gate * 1597c478bd9Sstevel@tonic-gate * - ppo_get_value will provide a value for the specified property 1607c478bd9Sstevel@tonic-gate * - ppo_set_value will allow a provider to validate a value before setting it 1617c478bd9Sstevel@tonic-gate */ 1627c478bd9Sstevel@tonic-gate typedef struct pool_prop_op { 1637c478bd9Sstevel@tonic-gate int (*ppo_get_value)(const pool_elem_t *, pool_value_t *); 1647c478bd9Sstevel@tonic-gate int (*ppo_set_value)(pool_elem_t *, const pool_value_t *); 1657c478bd9Sstevel@tonic-gate } pool_prop_op_t; 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate /* 1687c478bd9Sstevel@tonic-gate * The pool_prop_t structure is used to hold all property related information 1697c478bd9Sstevel@tonic-gate * for each property that a provider is interested in. 1707c478bd9Sstevel@tonic-gate * 1717c478bd9Sstevel@tonic-gate * - pp_pname is the name of the property 1727c478bd9Sstevel@tonic-gate * - pp_value is the initial value of the property 1737c478bd9Sstevel@tonic-gate * - pp_perms is an OR'd bitmap of the access characteristics for the property 1747c478bd9Sstevel@tonic-gate * - pp_init is a function which initialises the value member of the property 1757c478bd9Sstevel@tonic-gate * - pp_op is optional and supports access and validation of property values 1767c478bd9Sstevel@tonic-gate */ 1777c478bd9Sstevel@tonic-gate typedef struct pool_prop { 1787c478bd9Sstevel@tonic-gate const char *pp_pname; 1797c478bd9Sstevel@tonic-gate pool_value_t pp_value; 1807c478bd9Sstevel@tonic-gate uint_t pp_perms; 1817c478bd9Sstevel@tonic-gate int (*pp_init)(struct pool_prop *); 1827c478bd9Sstevel@tonic-gate pool_prop_op_t pp_op; 1837c478bd9Sstevel@tonic-gate } pool_prop_t; 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate /* 1867c478bd9Sstevel@tonic-gate * log state 1877c478bd9Sstevel@tonic-gate */ 1887c478bd9Sstevel@tonic-gate enum log_state { 1897c478bd9Sstevel@tonic-gate LS_DO, 1907c478bd9Sstevel@tonic-gate LS_UNDO, 1917c478bd9Sstevel@tonic-gate LS_RECOVER, 1927c478bd9Sstevel@tonic-gate LS_FAIL 1937c478bd9Sstevel@tonic-gate }; 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate /* 1967c478bd9Sstevel@tonic-gate * Forward declaration 1977c478bd9Sstevel@tonic-gate */ 1987c478bd9Sstevel@tonic-gate typedef struct log log_t; 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* 2017c478bd9Sstevel@tonic-gate * log item. 2027c478bd9Sstevel@tonic-gate * 2037c478bd9Sstevel@tonic-gate * Used to describe each operation which needs to be logged. When 2047c478bd9Sstevel@tonic-gate * modifications are desired to the kernel, they are logged in the 2057c478bd9Sstevel@tonic-gate * configuration log file. If the user commits the changes, then the 2067c478bd9Sstevel@tonic-gate * log entries are processed in sequence. If rollback is called, the 2077c478bd9Sstevel@tonic-gate * log is dismissed without being processed. If the commit operation 2087c478bd9Sstevel@tonic-gate * fails, then the log is "rolled back" to undo the previously 2097c478bd9Sstevel@tonic-gate * successful operations. 2107c478bd9Sstevel@tonic-gate */ 2117c478bd9Sstevel@tonic-gate typedef struct log_item { 2127c478bd9Sstevel@tonic-gate log_t *li_log; /* Log containing this item */ 2137c478bd9Sstevel@tonic-gate int li_op; /* Type of operation */ 2147c478bd9Sstevel@tonic-gate void *li_details; /* Operation details */ 2157c478bd9Sstevel@tonic-gate struct log_item *li_next; /* List of log items */ 2167c478bd9Sstevel@tonic-gate struct log_item *li_prev; /* List of log items */ 2177c478bd9Sstevel@tonic-gate enum log_state li_state; /* Item state */ 2187c478bd9Sstevel@tonic-gate } log_item_t; 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate /* 2217c478bd9Sstevel@tonic-gate * log. 2227c478bd9Sstevel@tonic-gate * 2237c478bd9Sstevel@tonic-gate * This maintains a list of log items. The sentinel is used to 2247c478bd9Sstevel@tonic-gate * simplify processing around the "empty list". The state of the log 2257c478bd9Sstevel@tonic-gate * indicates whether transactions are being processed normally, or 2267c478bd9Sstevel@tonic-gate * whether recovery is in progress. 2277c478bd9Sstevel@tonic-gate */ 2287c478bd9Sstevel@tonic-gate struct log 2297c478bd9Sstevel@tonic-gate { 2307c478bd9Sstevel@tonic-gate pool_conf_t *l_conf; /* Configuration for this log */ 2317c478bd9Sstevel@tonic-gate log_item_t *l_sentinel; /* Log sentinel */ 2327c478bd9Sstevel@tonic-gate enum log_state l_state; /* Log state */ 2337c478bd9Sstevel@tonic-gate }; 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate /* 2377c478bd9Sstevel@tonic-gate * log item action function type 2387c478bd9Sstevel@tonic-gate */ 2397c478bd9Sstevel@tonic-gate typedef int (*log_item_action_t)(log_item_t *); 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate /* 2427c478bd9Sstevel@tonic-gate * Get the max/min/size property value of a resource. 2437c478bd9Sstevel@tonic-gate */ 2447c478bd9Sstevel@tonic-gate extern int resource_get_max(const pool_resource_t *, uint64_t *); 2457c478bd9Sstevel@tonic-gate extern int resource_get_min(const pool_resource_t *, uint64_t *); 2467c478bd9Sstevel@tonic-gate extern int resource_get_size(const pool_resource_t *, uint64_t *); 2477c478bd9Sstevel@tonic-gate extern int resource_get_pinned(const pool_resource_t *, 2487c478bd9Sstevel@tonic-gate uint64_t *); 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate /* 2517c478bd9Sstevel@tonic-gate * Element utility operations. 2527c478bd9Sstevel@tonic-gate */ 2537c478bd9Sstevel@tonic-gate extern char *elem_get_name(const pool_elem_t *); 2547c478bd9Sstevel@tonic-gate extern id_t elem_get_sysid(const pool_elem_t *); 255*29d92041SToomas Soome extern int elem_is_default(const pool_elem_t *); 2560209230bSgjelinek extern boolean_t elem_is_tmp(const pool_elem_t *); 2577c478bd9Sstevel@tonic-gate extern const pool_elem_t *get_default_elem(const pool_elem_t *); 2587c478bd9Sstevel@tonic-gate extern int qsort_elem_compare(const void *, const void *); 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate /* 2617c478bd9Sstevel@tonic-gate * Get the class of the supplied element. 2627c478bd9Sstevel@tonic-gate */ 2637c478bd9Sstevel@tonic-gate extern const char *pool_elem_class_string(const pool_elem_t *); 2647c478bd9Sstevel@tonic-gate extern const char *pool_resource_type_string(pool_resource_elem_class_t); 2657c478bd9Sstevel@tonic-gate extern const char *pool_component_type_string(pool_component_elem_class_t); 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate /* 2687c478bd9Sstevel@tonic-gate * Commit the supplied configuration to the system. This function 2697c478bd9Sstevel@tonic-gate * attempts to make the system look like the supplied configuration. 2707c478bd9Sstevel@tonic-gate */ 2717c478bd9Sstevel@tonic-gate extern int pool_conf_commit_sys(pool_conf_t *, int); 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate /* 2747c478bd9Sstevel@tonic-gate * Allocate an XML/kernel connection to a data representation. 2757c478bd9Sstevel@tonic-gate */ 2767c478bd9Sstevel@tonic-gate extern int pool_xml_connection_alloc(pool_conf_t *, int); 2777c478bd9Sstevel@tonic-gate extern int pool_knl_connection_alloc(pool_conf_t *, int); 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate /* 2807c478bd9Sstevel@tonic-gate * Create/Destroy a pool component belonging to the supplied resource 2817c478bd9Sstevel@tonic-gate */ 2827c478bd9Sstevel@tonic-gate extern pool_component_t *pool_component_create(pool_conf_t *, 2837c478bd9Sstevel@tonic-gate const pool_resource_t *, int64_t); 2847c478bd9Sstevel@tonic-gate extern int pool_component_destroy(pool_component_t *); 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate /* 2877c478bd9Sstevel@tonic-gate * Get/Set the owner (container) of a particular configuration 2887c478bd9Sstevel@tonic-gate * element. 2897c478bd9Sstevel@tonic-gate */ 2907c478bd9Sstevel@tonic-gate extern pool_elem_t *pool_get_container(const pool_elem_t *); 2917c478bd9Sstevel@tonic-gate extern int pool_set_container(pool_elem_t *, pool_elem_t *); 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate /* 2947c478bd9Sstevel@tonic-gate * These functions are used for debugging. Setting the environment 2957c478bd9Sstevel@tonic-gate * variable LIBPOOL_DEBUG to 1, enables these functions. 2967c478bd9Sstevel@tonic-gate */ 2977c478bd9Sstevel@tonic-gate extern void do_dprintf(const char *, va_list); 2987c478bd9Sstevel@tonic-gate extern void dprintf(const char *, ...); 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate /* 3017c478bd9Sstevel@tonic-gate * libpool maintains it's own error value, rather than further pollute 3027c478bd9Sstevel@tonic-gate * errno, this function is used to set the current error value for 3037c478bd9Sstevel@tonic-gate * retrieval. 3047c478bd9Sstevel@tonic-gate */ 3057c478bd9Sstevel@tonic-gate extern void pool_seterror(int); 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate /* 3087c478bd9Sstevel@tonic-gate * Element Class 3097c478bd9Sstevel@tonic-gate */ 3107c478bd9Sstevel@tonic-gate extern pool_elem_class_t pool_elem_class(const pool_elem_t *); 3117c478bd9Sstevel@tonic-gate extern pool_resource_elem_class_t pool_resource_elem_class(const pool_elem_t *); 3127c478bd9Sstevel@tonic-gate extern pool_component_elem_class_t pool_component_elem_class(const 3137c478bd9Sstevel@tonic-gate pool_elem_t *); 3147c478bd9Sstevel@tonic-gate extern int pool_elem_same_class(const pool_elem_t *, const pool_elem_t *); 3157c478bd9Sstevel@tonic-gate extern pool_elem_class_t pool_elem_class_from_string(const char *); 3167c478bd9Sstevel@tonic-gate extern pool_resource_elem_class_t pool_resource_elem_class_from_string(const 3177c478bd9Sstevel@tonic-gate char *); 3187c478bd9Sstevel@tonic-gate extern pool_component_elem_class_t pool_component_elem_class_from_string(const 3197c478bd9Sstevel@tonic-gate char *); 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate /* 3227c478bd9Sstevel@tonic-gate * Element Equivalency 3237c478bd9Sstevel@tonic-gate */ 3247c478bd9Sstevel@tonic-gate extern int pool_elem_compare(const pool_elem_t *, 3257c478bd9Sstevel@tonic-gate const pool_elem_t *); 3267c478bd9Sstevel@tonic-gate extern int pool_elem_compare_name(const pool_elem_t *, 3277c478bd9Sstevel@tonic-gate const pool_elem_t *); 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate /* 3307c478bd9Sstevel@tonic-gate * Dynamic character buffers. Limited functionality but enough for our 3317c478bd9Sstevel@tonic-gate * purposes. 3327c478bd9Sstevel@tonic-gate */ 3337c478bd9Sstevel@tonic-gate extern char_buf_t *alloc_char_buf(size_t); 3347c478bd9Sstevel@tonic-gate extern void free_char_buf(char_buf_t *); 3357c478bd9Sstevel@tonic-gate extern int set_char_buf(char_buf_t *, const char *, ...); 3367c478bd9Sstevel@tonic-gate extern int append_char_buf(char_buf_t *, const char *, ...); 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate /* 3397c478bd9Sstevel@tonic-gate * Internal functions for use with pool values. 3407c478bd9Sstevel@tonic-gate */ 3417c478bd9Sstevel@tonic-gate extern int pool_value_equal(pool_value_t *, pool_value_t *); 342*29d92041SToomas Soome extern int pool_value_from_nvpair(pool_value_t *, nvpair_t *); 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate /* 3457c478bd9Sstevel@tonic-gate * Check to ensure that the supplied string is a valid name for a pool 3467c478bd9Sstevel@tonic-gate * element. 3477c478bd9Sstevel@tonic-gate */ 3487c478bd9Sstevel@tonic-gate extern int is_valid_name(const char *); 3497c478bd9Sstevel@tonic-gate 3507c478bd9Sstevel@tonic-gate /* 3517c478bd9Sstevel@tonic-gate * Functions related to element prefix manipulation. You can get the 3527c478bd9Sstevel@tonic-gate * prefix for a supplied element or find out if a supplied string is a 3537c478bd9Sstevel@tonic-gate * valid prefix for a certain class of element. 3547c478bd9Sstevel@tonic-gate */ 3557c478bd9Sstevel@tonic-gate extern const char *elem_get_prefix(const pool_elem_t *); 3567c478bd9Sstevel@tonic-gate extern const char *is_a_known_prefix(pool_elem_class_t, const char *); 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate /* 3597c478bd9Sstevel@tonic-gate * Internal property manipulators 3607c478bd9Sstevel@tonic-gate */ 3617c478bd9Sstevel@tonic-gate extern int pool_put_ns_property(pool_elem_t *, const char *, 3627c478bd9Sstevel@tonic-gate const pool_value_t *); 3637c478bd9Sstevel@tonic-gate extern int pool_put_any_property(pool_elem_t *, const char *, 3647c478bd9Sstevel@tonic-gate const pool_value_t *); 3657c478bd9Sstevel@tonic-gate extern int pool_put_any_ns_property(pool_elem_t *, const char *, 3667c478bd9Sstevel@tonic-gate const pool_value_t *); 3677c478bd9Sstevel@tonic-gate extern pool_value_class_t pool_get_ns_property(const pool_elem_t *, 3687c478bd9Sstevel@tonic-gate const char *, pool_value_t *); 3697c478bd9Sstevel@tonic-gate extern int pool_walk_any_properties(pool_conf_t *, pool_elem_t *, 3707c478bd9Sstevel@tonic-gate void *, int (*)(pool_conf_t *, pool_elem_t *, const char *, 3717c478bd9Sstevel@tonic-gate pool_value_t *, void *), int); 3720209230bSgjelinek extern int pool_set_temporary(pool_conf_t *, pool_elem_t *); 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate /* 3757c478bd9Sstevel@tonic-gate * Namespace aware utility functions. 3767c478bd9Sstevel@tonic-gate */ 3777c478bd9Sstevel@tonic-gate extern const char *is_ns_property(const pool_elem_t *, const char *); 3787c478bd9Sstevel@tonic-gate extern const char *property_name_minus_ns(const pool_elem_t *, 3797c478bd9Sstevel@tonic-gate const char *); 3807c478bd9Sstevel@tonic-gate 3817c478bd9Sstevel@tonic-gate /* 3827c478bd9Sstevel@tonic-gate * Initialisation routines. 3837c478bd9Sstevel@tonic-gate */ 3847c478bd9Sstevel@tonic-gate extern void internal_init(void); 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate /* 3877c478bd9Sstevel@tonic-gate * Is the supplied configuration the dynamic configuration? 3887c478bd9Sstevel@tonic-gate */ 3897c478bd9Sstevel@tonic-gate extern int conf_is_dynamic(const pool_conf_t *); 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate /* 3927c478bd9Sstevel@tonic-gate * Update the library snapshot from the kernel 3937c478bd9Sstevel@tonic-gate */ 3947c478bd9Sstevel@tonic-gate extern int pool_knl_update(pool_conf_t *, int *); 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate /* 3977c478bd9Sstevel@tonic-gate * Resource property functions 3987c478bd9Sstevel@tonic-gate */ 399*29d92041SToomas Soome extern int resource_is_default(const pool_resource_t *); 400*29d92041SToomas Soome extern int resource_is_system(const pool_resource_t *); 401*29d92041SToomas Soome extern int resource_can_associate(const pool_resource_t *); 4027c478bd9Sstevel@tonic-gate extern const pool_resource_t *get_default_resource(const pool_resource_t *); 403*29d92041SToomas Soome extern pool_resource_t *resource_by_sysid(const pool_conf_t *, id_t, 4047c478bd9Sstevel@tonic-gate const char *); 4057c478bd9Sstevel@tonic-gate 4067c478bd9Sstevel@tonic-gate /* 4077c478bd9Sstevel@tonic-gate * Resource property provider functions 4087c478bd9Sstevel@tonic-gate */ 4097c478bd9Sstevel@tonic-gate extern uint_t pool_get_provider_count(void); 4107c478bd9Sstevel@tonic-gate extern const pool_prop_t *provider_get_props(const pool_elem_t *); 4117c478bd9Sstevel@tonic-gate extern const pool_prop_t *provider_get_prop(const pool_elem_t *, 4127c478bd9Sstevel@tonic-gate const char *); 4137c478bd9Sstevel@tonic-gate extern int prop_is_stored(const pool_prop_t *); 4147c478bd9Sstevel@tonic-gate extern int prop_is_readonly(const pool_prop_t *); 4157c478bd9Sstevel@tonic-gate extern int prop_is_init(const pool_prop_t *); 4167c478bd9Sstevel@tonic-gate extern int prop_is_hidden(const pool_prop_t *); 4177c478bd9Sstevel@tonic-gate extern int prop_is_optional(const pool_prop_t *); 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate /* 4207c478bd9Sstevel@tonic-gate * Component property functions 4217c478bd9Sstevel@tonic-gate */ 4227c478bd9Sstevel@tonic-gate extern int cpu_is_requested(pool_component_t *); 4237c478bd9Sstevel@tonic-gate 4247c478bd9Sstevel@tonic-gate /* 4257c478bd9Sstevel@tonic-gate * Simple initialisation routines for values used when initialising the 4267c478bd9Sstevel@tonic-gate * property arrays for each plugin 4277c478bd9Sstevel@tonic-gate * Return PO_SUCCESS/PO_FAIL to indicate success/failure 4287c478bd9Sstevel@tonic-gate */ 4297c478bd9Sstevel@tonic-gate extern int uint_init(pool_prop_t *, uint64_t); 4307c478bd9Sstevel@tonic-gate extern int int_init(pool_prop_t *, int64_t); 4317c478bd9Sstevel@tonic-gate extern int double_init(pool_prop_t *, double); 4327c478bd9Sstevel@tonic-gate extern int bool_init(pool_prop_t *, uchar_t); 4337c478bd9Sstevel@tonic-gate extern int string_init(pool_prop_t *, const char *); 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate /* 4377c478bd9Sstevel@tonic-gate * log functions 4387c478bd9Sstevel@tonic-gate */ 4397c478bd9Sstevel@tonic-gate extern log_t *log_alloc(pool_conf_t *); 4407c478bd9Sstevel@tonic-gate extern void log_free(log_t *); 4417c478bd9Sstevel@tonic-gate extern void log_empty(log_t *); 4427c478bd9Sstevel@tonic-gate extern int log_walk(log_t *, log_item_action_t); 4437c478bd9Sstevel@tonic-gate extern int log_reverse_walk(log_t *, log_item_action_t); 4447c478bd9Sstevel@tonic-gate extern uint_t log_size(log_t *); 4457c478bd9Sstevel@tonic-gate extern int log_append(log_t *, int, void *); 4467c478bd9Sstevel@tonic-gate 4477c478bd9Sstevel@tonic-gate /* 4487c478bd9Sstevel@tonic-gate * log item functions 4497c478bd9Sstevel@tonic-gate */ 4507c478bd9Sstevel@tonic-gate extern log_item_t *log_item_alloc(log_t *, int, void *); 4517c478bd9Sstevel@tonic-gate extern int log_item_free(log_item_t *); 4527c478bd9Sstevel@tonic-gate 4537c478bd9Sstevel@tonic-gate extern int pool_validate_resource(const pool_conf_t *, 4547c478bd9Sstevel@tonic-gate const char *, const char *, int64_t); 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate /* 4577c478bd9Sstevel@tonic-gate * String atom functions 4587c478bd9Sstevel@tonic-gate */ 4597c478bd9Sstevel@tonic-gate extern const char *atom_string(const char *); 4607c478bd9Sstevel@tonic-gate extern void atom_free(const char *); 4617c478bd9Sstevel@tonic-gate /* 4627c478bd9Sstevel@tonic-gate * debugging functions 4637c478bd9Sstevel@tonic-gate */ 4647c478bd9Sstevel@tonic-gate #ifdef DEBUG 4657c478bd9Sstevel@tonic-gate extern void log_item_dprintf(log_item_t *); 4667c478bd9Sstevel@tonic-gate extern void pool_value_dprintf(const pool_value_t *); 4677c478bd9Sstevel@tonic-gate extern void pool_elem_dprintf(const pool_elem_t *); 4687c478bd9Sstevel@tonic-gate #endif 4697c478bd9Sstevel@tonic-gate 4707c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4717c478bd9Sstevel@tonic-gate } 4727c478bd9Sstevel@tonic-gate #endif 4737c478bd9Sstevel@tonic-gate 4747c478bd9Sstevel@tonic-gate #endif /* _POOL_INTERNAL_H */ 475