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 (the "License").
2N/A * You may not use this file except in compliance 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/*
2N/A * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _LIBSES_H
2N/A#define _LIBSES_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <sys/types.h>
2N/A
2N/A#include <stdarg.h>
2N/A#include <libnvpair.h>
2N/A#include <pthread.h>
2N/A
2N/A#include <scsi/libscsi.h>
2N/A#include <scsi/plugins/ses/framework/ses2.h>
2N/A#include <scsi/plugins/ses/framework/libses.h>
2N/A
2N/A#define LIBSES_VERSION 1
2N/A
2N/A/*
2N/A * element type prop can be created by any plugin. The ses2 plugin created
2N/A * SES-2 defined element types and SUN plugin defines vendor specific types.
2N/A */
2N/A#define SES_PROP_ELEMENT_TYPE "ses-element-type"
2N/A
2N/Atypedef enum ses_node_type {
2N/A SES_NODE_NONE = 0x0,
2N/A SES_NODE_TARGET = 0x1,
2N/A SES_NODE_ENCLOSURE = 0x2,
2N/A SES_NODE_AGGREGATE = 0x4,
2N/A SES_NODE_ELEMENT = 0x8
2N/A} ses_node_type_t;
2N/A
2N/Atypedef enum ses_errno {
2N/A ESES_NONE, /* no error */
2N/A ESES_NOMEM, /* no memory */
2N/A ESES_ZERO_LENGTH, /* zero-length allocation requested */
2N/A ESES_VERSION, /* library version mismatch */
2N/A ESES_NVL, /* nvlist manipulation error */
2N/A ESES_BAD_NODE, /* bad node */
2N/A ESES_INVALID_OP, /* invalid operation */
2N/A ESES_RANGE, /* value out of range */
2N/A ESES_INVALID_PROP, /* nonexistent or immutable property */
2N/A ESES_BAD_TYPE, /* incorrect property type */
2N/A ESES_BAD_PAGE, /* bad page number */
2N/A ESES_BAD_RESPONSE, /* bad response from target */
2N/A ESES_BUSY, /* target busy */
2N/A ESES_TOOMUCHCHANGE, /* target configuration changing too rapidly */
2N/A ESES_LIBSCSI, /* SCSI error */
2N/A ESES_NOTSUP, /* operation not supported */
2N/A ESES_UNKNOWN, /* error of unknown type */
2N/A ESES_CHANGED, /* generation count has changed */
2N/A ESES_PLUGIN, /* invalid or missing plugin */
2N/A ESES_MAX /* maximum libses errno value */
2N/A} ses_errno_t;
2N/A
2N/Astruct ses_target;
2N/Atypedef struct ses_target ses_target_t;
2N/A
2N/Astruct ses_snap;
2N/Atypedef struct ses_snap ses_snap_t;
2N/A
2N/Astruct ses_node;
2N/Atypedef struct ses_node ses_node_t;
2N/A
2N/Aextern ses_target_t *ses_open(uint_t, const char *);
2N/Aextern ses_target_t *ses_open_scsi(uint_t, libscsi_target_t *);
2N/Aextern void ses_close(ses_target_t *);
2N/A
2N/Aextern libscsi_target_t *ses_scsi_target(ses_target_t *);
2N/A
2N/Atypedef enum ses_walk_action {
2N/A SES_WALK_ACTION_CONTINUE,
2N/A SES_WALK_ACTION_PRUNE,
2N/A SES_WALK_ACTION_TERMINATE
2N/A} ses_walk_action_t;
2N/A
2N/Atypedef ses_walk_action_t (*ses_walk_f)(ses_node_t *, void *);
2N/A
2N/Aextern uint64_t ses_node_id(ses_node_t *);
2N/Aextern ses_node_t *ses_node_lookup(ses_snap_t *, uint64_t);
2N/A
2N/Aextern ses_node_t *ses_root_node(ses_snap_t *);
2N/Aextern ses_node_t *ses_node_sibling(ses_node_t *);
2N/Aextern ses_node_t *ses_node_prev_sibling(ses_node_t *);
2N/Aextern ses_node_t *ses_node_child(ses_node_t *);
2N/Aextern ses_node_t *ses_node_parent(ses_node_t *);
2N/Aextern int ses_walk(ses_snap_t *, ses_walk_f, void *);
2N/A
2N/Aextern ses_snap_t *ses_snap_hold(ses_target_t *);
2N/Aextern void ses_snap_rele(ses_snap_t *);
2N/Aextern ses_snap_t *ses_snap_new(ses_target_t *);
2N/Aextern uint32_t ses_snap_generation(ses_snap_t *);
2N/A
2N/Aextern ses_node_type_t ses_node_type(ses_node_t *);
2N/Aextern nvlist_t *ses_node_props(ses_node_t *);
2N/Aextern int ses_node_ctl(ses_node_t *, const char *, nvlist_t *);
2N/Aextern ses_snap_t *ses_node_snapshot(ses_node_t *);
2N/Aextern ses_target_t *ses_node_target(ses_node_t *);
2N/A
2N/Aextern ses_errno_t ses_errno(void);
2N/Aextern const char *ses_errmsg(void);
2N/Aextern const char *ses_strerror(ses_errno_t);
2N/Aextern const char *ses_nv_error_member(void);
2N/A
2N/Aextern ses_node_t *ses_snap_primary_enclosure(ses_snap_t *);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LIBSES_H */