libscsi.h revision ac88567a7a5bb7f01cf22cf366bc9d6203e24d7a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
*/
#ifndef _LIBSCSI_H
#define _LIBSCSI_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/sysmacros.h>
#include <stdarg.h>
#define LIBSCSI_VERSION 1
#define LIBSCSI_DEFAULT_ENGINE "uscsi"
/*
* Flags for action creation. Selected to avoid overlap with the uscsi
* flags with similar or identical meaning.
*/
#define LIBSCSI_AF_READ 0x80000000
#define LIBSCSI_AF_WRITE 0x40000000
#define LIBSCSI_AF_SILENT 0x20000000
#define LIBSCSI_AF_DIAGNOSE 0x10000000
#define LIBSCSI_AF_ISOLATE 0x08000000
#define LIBSCSI_AF_RQSENSE 0x04000000
typedef enum libscsi_errno {
ESCSI_NONE, /* no error */
ESCSI_NOMEM, /* no memory */
ESCSI_ZERO_LENGTH, /* zero-length allocation requested */
ESCSI_VERSION, /* library version mismatch */
ESCSI_BADTARGET, /* invalid target specification */
ESCSI_BADCMD, /* invalid SCSI command */
ESCSI_BADENGINE, /* engine library corrupt */
ESCSI_NOENGINE, /* engine library not found */
ESCSI_ENGINE_INIT, /* engine initialization failed */
ESCSI_ENGINE_VER, /* engine version mismatch */
ESCSI_ENGINE_BADPATH, /* engine path contains no usable components */
ESCSI_BADFLAGS, /* incorrect action flags */
ESCSI_BOGUSFLAGS, /* unknown flag value */
ESCSI_BADLENGTH, /* buffer length overflow */
ESCSI_NEEDBUF, /* missing required buffer */
ESCSI_IO, /* I/O operation failed */
ESCSI_SYS, /* system call failed */
ESCSI_PERM, /* insufficient permissions */
ESCSI_RANGE, /* parameter outside valid range */
ESCSI_NOTSUP, /* operation not supported */
ESCSI_UNKNOWN, /* error of unknown type */
ESCSI_INQUIRY_FAILED, /* initial inquiry command failed */
ESCSI_MAX /* maximum libscsi errno value */
struct libscsi_hdl;
typedef struct libscsi_hdl libscsi_hdl_t;
struct libscsi_target;
typedef struct libscsi_target libscsi_target_t;
typedef struct libscsi_status {
struct libscsi_action;
typedef struct libscsi_action libscsi_action_t;
typedef struct libscsi_engine_ops {
void *(*lseo_open)(libscsi_hdl_t *, const void *);
void (*lseo_close)(libscsi_hdl_t *, void *);
typedef struct libscsi_engine {
const char *lse_name;
const libscsi_engine_ops_t *lse_ops;
extern void libscsi_fini(libscsi_hdl_t *);
const void *);
extern const char *libscsi_vendor(libscsi_target_t *);
extern const char *libscsi_product(libscsi_target_t *);
extern const char *libscsi_revision(libscsi_target_t *);
extern const char *libscsi_errmsg(libscsi_hdl_t *);
extern const char *libscsi_strerror(libscsi_errno_t);
extern const char *libscsi_errname(libscsi_errno_t);
extern libscsi_errno_t libscsi_errcode(const char *);
extern int libscsi_action_get_buffer(const libscsi_action_t *,
extern int libscsi_action_get_sense(const libscsi_action_t *,
extern void libscsi_action_free(libscsi_action_t *);
extern const char *libscsi_sense_key_name(uint64_t);
/*
* Interfaces for engine providers
*/
extern char *libscsi_strdup(libscsi_hdl_t *, const char *);
extern void libscsi_free(libscsi_hdl_t *, void *);
va_list);
/*
* Generic SCSI utility functions.
*/
#ifdef __cplusplus
}
#endif
#endif /* _LIBSCSI_H */