pool.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* NOTE
*
* The following contents of this file are private to the
* implementation of the Solaris system and are subject to change at
* any time without notice. Applications using these interfaces may
* fail to run on future releases.
*/
#ifndef _POOL_H
#define _POOL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Library versioning support (c.f. elf_version(3e)).
*
* You can enquire about the version number of the library
* by passing POOL_VER_NONE. POOL_VER_CURRENT is the current
* (most capable) version.
*
* You can set the version used by the library by passing the
* required version number. If this is not possible, the version
* returned will be POOL_VER_NONE.
*/
#define POOL_VER_CURRENT 1
#define POOL_VER_NONE 0
#ifndef PO_TRUE
#define PO_TRUE 1
#endif
#ifndef PO_FALSE
#define PO_FALSE 0
#endif
#ifndef PO_SUCCESS
#define PO_SUCCESS 0
#endif
#ifndef PO_FAIL
#define PO_FAIL -1
#endif
/* Error codes */
#define POE_OK 0
#define POE_BAD_PROP_TYPE 1
#define POE_INVALID_CONF 2
#define POE_NOTSUP 3
#define POE_INVALID_SEARCH 4
#define POE_BADPARAM 5
#define POE_PUTPROP 6
#define POE_DATASTORE 7
#define POE_SYSTEM 8
#define POE_ACCESS 9
/* Open Flags */
#define PO_RDONLY 0x0
#define PO_RDWR 0x1
#define PO_CREAT 0x2
#define PO_DISCO 0x4
#define PO_UPDATE 0x8
/* Allocation policy */
#define POA_IMPORTANCE "importance based"
#define POA_SURPLUS_TO_DEFAULT "surplus to default"
/* Pools updates */
#define POU_SYSTEM 0x1
#define POU_POOL 0x2
#define POU_PSET 0x4
#define POU_CPU 0x8
/* Data Export Formats */
typedef enum pool_export_format {
POX_NATIVE, /* Native data representation format */
POX_TEXT /* Text */
/* Property data types */
typedef enum pool_value_class {
POC_INVAL = -1,
/* Validation levels */
typedef enum pool_valid_level {
POV_NONE = 0, /* No validation */
POV_LOOSE, /* Loose validation */
POV_STRICT, /* Strict validation */
POV_RUNTIME /* Validate instantiation on current machine */
/* conf states */
typedef enum pool_conf_state {
POF_INVALID = -1,
/* Element data values */
typedef struct pool_value pool_value_t;
/* Elements */
typedef struct pool_elem pool_elem_t;
typedef struct pool_resource pool_resource_t;
typedef struct pool_component pool_component_t;
/*
* Resource management configuration
*/
typedef struct pool_conf pool_conf_t;
extern int pool_error(void);
extern const char *pool_strerror(int);
extern int pool_resource_type_list(const char **, uint_t *);
extern int pool_get_status(int *);
extern int pool_set_status(int);
/* Configuration manipulation */
extern pool_conf_t *pool_conf_alloc(void);
extern void pool_conf_free(pool_conf_t *);
extern int pool_conf_close(pool_conf_t *);
extern int pool_conf_remove(pool_conf_t *);
extern int pool_conf_open(pool_conf_t *, const char *, int);
extern int pool_conf_rollback(pool_conf_t *);
extern int pool_conf_commit(pool_conf_t *, int);
extern int pool_conf_export(const pool_conf_t *, const char *,
extern int pool_conf_update(const pool_conf_t *, int *);
pool_value_t **);
const char *);
pool_value_t **);
pool_value_t **);
extern const char *pool_conf_location(const pool_conf_t *);
extern char *pool_conf_info(const pool_conf_t *, int);
/* Resource manipulation */
const char *);
pool_resource_t *, uint64_t);
pool_resource_t *, pool_component_t **);
int);
/* Pool manipulation */
/* Resource Component Manipulation */
const pool_component_t *);
int);
/* Property manipulation */
const pool_elem_t *, const char *, pool_value_t *);
const pool_value_t *);
/*
* Walk the associated properties of the supplied element calling the supplied
* function for each property in turn. There is no implied order in the walk.
* The arg parameter allows caller-specific data to be passed to the call.
*/
void *));
/* Get the underlying element */
const pool_resource_t *);
const pool_component_t *);
/* Pool Property Value Manipulation */
extern int pool_value_get_double(const pool_value_t *, double *);
extern int pool_value_get_string(const pool_value_t *, const char **);
extern void pool_value_set_double(pool_value_t *, double);
extern int pool_value_set_string(pool_value_t *, const char *);
extern const char *pool_value_get_name(const pool_value_t *);
extern int pool_value_set_name(pool_value_t *, const char *);
/* Pool Property Value Creation/Destruction */
extern pool_value_t *pool_value_alloc(void);
extern void pool_value_free(pool_value_t *);
/* Default pool data store locations */
extern const char *pool_static_location(void);
extern const char *pool_dynamic_location(void);
/* Binding */
extern char *pool_get_binding(pid_t);
extern char *pool_get_resource_binding(const char *, pid_t);
/* Walking */
extern int pool_walk_pools(pool_conf_t *, void *,
int (*)(pool_conf_t *, pool_t *, void *));
int (*)(pool_conf_t *, pool_resource_t *, void *));
int (*)(pool_conf_t *, pool_component_t *, void *));
#ifdef __cplusplus
}
#endif
#endif /* _POOL_H */