dm_drive.h revision cee0fb94c0d4227de0a00efc162fb2739844b641
/*
* 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
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef __DM_DRIVE_H
#define __DM_DRIVE_H
#include <mms_dmd.h>
#include <mms_sym.h>
#include <mms_list.h>
#include <mms_scsi.h>
#include <mms_trace.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Issueing the load command */
/*
*/
typedef struct drv_req {
} drv_req_t;
/*
* For DRIVECARTRIDGEACCESS object
*/
typedef struct drv_cart_access {
int dca_flags;
char *dca_side_name;
char *dca_part_name;
char *dca_app_name;
char *dca_cart_id;
char *dca_mounted_last;
char *dca_cart_shape_name;
char *dca_drv_shape_name;
char *dca_pcl;
/* by app */
/* from medium */
/* by app */
/* on medium */
int dca_read_err;
int dca_rcvd_read_err;
int dca_write_err;
int dca_rcvd_write_err;
/*
* Hold dm mount request attributes
*/
typedef struct drv_mount {
int mnt_blksize; /* blocksize in mount cmd */
int mnt_dflt_blksize; /* default blksize */
int mnt_lbl_type; /* label type - al, sl, nl */
int mnt_fseq;
int mnt_retention;
/*
* Don't free the following
*/
/*
* End of don't free
*/
/*
* Must free the following from here to ...
*/
char *mnt_volumename;
char *mnt_vid;
char *mnt_pcl;
char *mnt_fname; /* filename */
char *mnt_user;
char *mnt_dencode;
char *mnt_shape; /* cartridge shape */
/*
* End of must free
*/
} drv_mount_t;
#define DRV_IOBUF_LEN 10240
#define DRV_LBN_LEN 17
/*
* Uscsi request
*/
typedef struct drv_scsi_err {
int se_flags;
int se_cdblen;
union {
struct scsi_extended_sense se_xsense;
} se_u_sense;
int se_senlen;
int se_errno;
char *se_err_text;
/*
* Define error class
*/
typedef enum {
DRV_EC_ERROR = 1,
/* Add additional erorr classes before this line */
DRV_EC_UNKNOWN_ERR /* End of table */
typedef struct drv_skaa {
char *drv_text;
} drv_skaa_t;
#define DRV_IMPID "SUNMICRO MMS "
#define DRV_IMPID2 "SUNMICRO SMMS"
typedef struct drv_vol1 {
char vol1_acc; /* Accessability */
char vol1_reserved[13];
char vol1_reserved2[28];
char vol1_ver; /* Standard Version (4) */
} drv_vol1_t;
#define VOL1_ID "VOL1"
#define VOL1_OWNER "SUNMICROSYSTEM"
#define VOL1_VER "4 "
typedef struct drv_hdr1 {
char hdr1_acc; /* File accessability */
char hdr1_reserved[7];
} drv_hdr1_t;
#define HDR1_ID "HDR1"
typedef struct drv_hdr2 {
char hdr2_id[4];
char hdr2_rformat;
char hdr2_blklen[5];
char hdr2_rcdlen[5];
union {
char hdr2_off[2];
char hdr2_reserved[28];
} drv_hdr2_t;
#define HDR2_ID "HDR2"
typedef struct drv_eof1 {
char eof1_acc; /* File accessability */
char eof1_reserved[7];
} drv_eof1_t;
#define EOF1_ID "EOF1"
typedef struct drv_eof2 {
char eof2_id[4];
char eof2_rformat;
char eof2_blklen[5];
char eof2_rcdlen[5];
union {
char eof2_off[2];
char eof2_reserved[28];
} drv_eof2_t;
#define EOF2_ID "EOF2"
typedef struct drv_eov1 {
char eov1_acc; /* File accessability */
char eov1_reserved[7];
} drv_eov1_t;
#define EOV1_ID "EOV1"
typedef struct drv_eov2 {
char eov2_id[4];
char eov2_rformat;
char eov2_blklen[5];
char eov2_rcdlen[5];
union {
char eov2_off[2];
char eov2_reserved[28];
} drv_eov2_t;
#define EOV2_ID "EOV2"
typedef struct drv_timeout {
short drv_long_timeout; /* For really long commands */
short drv_timeout; /* Normal commands */
short drv_short_timeout; /* short commands */
/*
* Define a structure that specifies which density can be written on a shape
*/
typedef struct drv_shape_density {
char *drv_shape; /* shape name */
char *drv_bit; /* density on cartridge */
char *drv_den; /* write density */
/*
* drv_drive - states of drive with volume mounted
*/
typedef struct drv_drive {
char drv_typename[65];
char drv_vend[9];
char drv_prod[17];
int drv_fd; /* file descriptor of drive */
int drv_numopens; /* num. of opens since loaded */
int drv_fseq;
int drv_lbl_type; /* label type */
int drv_file_blksize; /* block size of file */
int drv_cur_blksize; /* current blocksize */
int drv_lbl_blksize; /* block size on the label */
int drv_dflt_blksize;
int drv_retention;
int drv_xdate; /* expiration date */
int drv_cur_den;
char **drv_shape;
char **drv_mounted;
char *drv_dmname;
char *drv_drvname;
char *drv_dev_dir;
char *drv_drive_type; /* drive type */
char drv_vid[10];
char drv_fid[18];
/* serial num from DRIVE obj */
int drv_mtee_stat_len; /* mtee status len */
int drv_num_sen_bytes;
int *drv_disallowed_cmds;
int *drv_num_disallowed_cmds;
int *drv_disallowed_ioctls;
int *drv_prsv_supported;
} drv_drive_t;
/*
* Drive Flags
*/
#define DRV_LOADED (1LL << 0)
#define DRV_SAVE_STAT 1
/*
* Define label type
*/
#define DRV_AL 1
#define DRV_SL 2
#define DRV_NL 3
#define DRV_BLP 4
typedef void (drv_init_dev_t)(void);
typedef int (drv_set_blksize_t)(uint64_t);
typedef int (drv_get_blksize_t)(uint64_t *);
typedef int (drv_get_density_t)(int *, int *);
typedef int (drv_set_density_t)(int);
typedef int (drv_read_t)(char *, int);
typedef int (drv_write_t)(char *, int);
typedef int (drv_get_capacity_t)(mms_capacity_t *);
typedef int64_t (drv_get_avail_capacity_t)(void);
typedef int (drv_clrerr_t)(void);
typedef void (drv_proc_error_t)(void);
typedef int (drv_inquiry_t)(void);
typedef int (drv_req_sense_t)(int);
typedef int (drv_tur_t)(void);
typedef int (drv_load_t)(void);
typedef int (drv_unload_t)(void);
typedef int (drv_rewind_t)(void);
typedef int (drv_mode_sense_t)(int, int, int);
typedef int (drv_mode_select_t)(int, int);
typedef int (drv_seek_t)(uint64_t);
typedef int (drv_tell_t)(uint64_t *);
typedef int (drv_eom_t)(void);
typedef int (drv_get_pos_t)(tapepos_t *);
typedef int (drv_mtgetpos_t)(tapepos_t *);
typedef int (drv_mtrestpos_t)(tapepos_t *);
typedef int (drv_get_statistics_t)(void);
typedef int (drv_locate_t)(tapepos_t *);
typedef int (drv_log_sense_t)(uchar_t *, int, int, int);
typedef int (drv_blk_limit_t)(mms_blk_limit_t *);
typedef int (drv_reserve_t)(void);
typedef int (drv_release_t)(void);
typedef int (drv_get_serial_num_t)(char *);
typedef int (drv_get_write_protect_t)(int *);
typedef int (drv_prsv_register_t)(void);
typedef int (drv_prsv_reserve_t)(void);
typedef int (drv_prsv_release_t)(void);
typedef int (drv_prsv_clear_t)(void);
typedef int (drv_prsv_preempt_t)(char *);
typedef int (drv_prsv_read_keys_t)(char *, int);
typedef int (drv_prsv_read_rsv_t)(char *, int);
typedef int (drv_set_compression_t)(int);
typedef char ** (drv_get_mounted_t)(void);
typedef int (drv_get_drivetype_t)(void);
typedef int (drv_rebind_target_t)(void);
typedef void (drv_mk_prsv_key_t)(void);
typedef void (drv_disallowed_t)(void);
typedef int (drv_bind_raw_dev_t)(int);
typedef struct drv_jtab {
} drv_jtab_t;
extern drv_jtab_t *jtab;
extern drv_mount_t *mnt;
extern drv_drive_t *drv;
extern drv_scsi_err_t *serr;
extern drv_cart_access_t *dca;
void dm_get_mtstat(int);
void dm_err_trace(void);
void dm_disallowed(void);
void dm_mk_prsv_key(void);
int dm_rebind_target(void);
int dm_bind_raw_dev(int);
void dm_get_mt_error(int err);
int dm_send_clean_request(void);
int dm_send_error(void);
int dm_send_drive_broken(void);
int dm_send_cartridge_media_error(void);
#define CONF_TASK "$taskid$"
#define CONF_DMNAME "$dmname$"
#define CONF_SHAPE "$shape$"
#define CONF_SHAPE_RW "$shape_rw$"
#define CONF_SHAPE_RO "$shape_ro$"
#define CONF_DENSITY_RW "$density_rw$"
#define CONF_DENSITY_RO "$density_ro$"
#define CONF_DENSITY_WO "$density_wo$"
#define CONF_DRIVE_SPEC "$drivespec$"
#define CONF_DRIVE_TYPE "$drivetype$"
#define CONF_BITFORMAT "$bitformat$"
#define CONF_BITFORMAT_RW "$bitformat_rw$"
#define CONF_BITFORMAT_RO "$bitformat_ro$"
#define CONF_BITFORMAT_WO "$bitformat_writeover$"
#define CONF_BIT_CLAUSE "$bitformat_clause$"
#define CONF_SHAPE_PRIORITY "$shape_priority$"
#define CONF_DEN_PRIORITY "$den_priority$"
#define CUR_SHAPE_RW "$cur_shape_rw$"
#define CUR_DENSITY_RW "$cur_density_rw$"
#define CUR_DENSITY_RO "$cur_density_ro$"
#define CUR_BITFORMAT_RW "$cur_bitformat_rw$"
#define CUR_BITFORMAT_WO "$cur_bitformat_wo$"
#define CONF_CAP_READWRITE "$conf_cap_readwrite$"
#define CONF_CAP_DENSITY_CLAUSE "$conf_cap_density_clause$"
#define CONF_MOUNT_POINT "$conf_mount_point$"
#define DRV_CAP_WRITEOVER "" \
/* \
* Device that uses specific densities \
* to overwrite existing density \
*/ \
\
"cap ['writeover-" \
" caplist [ 'mms' \n" \
" '*nocompression' 'compression' \n" \
" '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \
" 'variable' 'block' 'fixed' \n" \
" '*load' 'noload'\n" \
" '*oflag' 'creat' 'old' 'trunc' 'append' \n" \
" '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \
" '*rewind' 'norewind' \n" \
" '*dflt_vldt_filename' 'validate_filename' " \
" 'no_validate_filename' \n" \
" '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \
" '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \
" '*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \
" 'no_switch_lbl'\n" \
" '*dflt_writeover' 'writeover' 'ask_writeover' " \
" 'no_writeover'\n" \
" '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \
" 'no_preempt_rsv'\n" \
" '*readwrite' 'readwrite' \n" \
" ]] \n"
#define DRV_CAP_READWRITE "" \
/* \
* Device that uses specific densities \
* for readwrite \
*/ \
\
"cap ['readwrite-" \
" caplist [ 'mms' \n" \
" '*nocompression' 'compression' \n" \
" '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \
" 'variable' 'block' 'fixed' \n" \
" '*load' 'noload'\n" \
" '*oflag' 'creat' 'old' 'trunc' 'append' \n" \
" '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \
" '*rewind' 'norewind' \n" \
" '*dflt_vldt_filename' 'validate_filename' " \
" 'no_validate_filename' \n" \
" '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \
" '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \
" '*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \
" 'no_switch_lbl'\n" \
" '*dflt_writeover' 'writeover' 'ask_writeover' " \
" 'no_writeover'\n" \
" '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \
" 'no_preempt_rsv'\n" \
" '*readwrite' 'readwrite' \n" \
" ]] \n"
/*
* format of config command
* Default capabilities that begin with '*' are default capabilities which
* are meant to be hidden from the user and should not be documented in user
* manuals.
*/
#define DRV_CONFIG "" \
\
"group ['st-device' 'interchange' " \
"'*nocompression' 'compression' 'high' 'low' 'medium' 'ultra' ] \n" \
\
"group ['specific-density' 'interchange' " \
"'*auto_density' " \
\
"group ['bitformat-list' 'interchange' " \
\
"group ['data-block-format' 'access' " \
"'variable' 'block' 'fixed']\n" \
\
"group ['shape' 'access' " \
\
"group ['do-load' 'access' " \
"'*load' 'noload']\n" \
\
"group ['tm-behavor' 'access' " \
"'*default_tm' 'mms_tm' 'st_nobsd' 'st_bsd' ]\n" \
\
"group ['specific-drive' 'access' " \
\
"group ['file-disposition' 'access' " \
"'*oflag' 'old' 'creat' 'new' 'trunc' 'append'] \n" \
\
"group ['operation-mode' 'access' " \
"'mms' 'raw'] \n" \
\
"group ['lable-type' 'access' " \
"'*default_lbl' 'al' 'nl' 'sl' 'blp'] \n" \
\
"group ['readwrite-mode' 'access' " \
"'*readwrite' 'readwrite' 'readonly'] \n" \
\
"group ['rewind-at-close' 'access' " \
"'*rewind' 'norewind' ] \n" \
\
"group ['filename-validation' 'access' " \
"'*dflt_vldt_filename' 'validate_filename' 'no_validate_filename'] \n" \
\
"group ['vid-validation' 'access' " \
"'*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' ]\n" \
\
"group ['xdate-validation' 'access' " \
"'*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate' ]\n" \
\
"group ['switch-label' 'access' " \
"'*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \
"'no_switch_lbl' ]\n" \
\
"group ['write-over' 'access' " \
"'*dflt_writeover' 'writeover' 'ask_writeover' 'no_writeover' ]\n" \
\
"group ['preempt-reservation' 'access' " \
"'*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \
"'no_preempt_rsv' ]\n" \
\
CONF_BIT_CLAUSE "\n" \
\
/* \
* Raw devices - readwrite \
*/ \
" 'raw' \n" \
" '*nocompression' 'compression' " \
" 'high' 'low' 'medium' 'ultra' \n" \
" '*auto_density' \n" \
" 'variable' \n" \
" '*default_tm' 'st_bsd' 'st_nobsd' \n" \
" '*load' \n" \
" '*oflag' \n" \
" '*default_lbl' \n" \
" '*rewind' 'norewind' \n" \
" '*dflt_vldt_filename' \n" \
" '*dflt_vldt_vid' \n" \
" '*dflt_vldt_xdate' \n" \
" '*dflt_switch_lbl' \n" \
" '*dflt_writeover' \n" \
" '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' \n" \
" '*readwrite' 'readwrite' \n" \
" ]] \n" \
\
/* \
* Raw devices - readonly \
*/ \
" 'raw' \n" \
" '*nocompression' 'compression' " \
" 'high' 'low' 'medium' 'ultra' \n" \
" '*auto_density' \n" \
" 'variable' \n" \
" '*default_tm' 'st_bsd' \n" \
" '*load' \n" \
" '*oflag' \n" \
" '*default_lbl' \n" \
" '*rewind' 'norewind' \n" \
" '*dflt_vldt_filename' \n" \
" '*dflt_vldt_vid' \n" \
" '*dflt_vldt_xdate' \n" \
" '*dflt_switch_lbl' \n" \
" '*dflt_writeover' \n" \
" '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' \n" \
" 'readonly' \n" \
" ]] \n" \
\
/* \
* MMS device that uses st densities \
* for readwrite \
*/ \
\
" 'mms' \n" \
" '*nocompression' 'compression' " \
" 'low' 'medium' 'high' 'ultra' \n" \
" '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \
" 'variable' 'block' 'fixed' \n" \
" '*load' 'noload'\n" \
" '*oflag' 'old' 'trunc' 'append' \n" \
" '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \
" '*rewind' 'norewind' \n" \
" '*dflt_vldt_filename' 'validate_filename' " \
" 'no_validate_filename' \n" \
" '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \
" '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \
" '*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \
" 'no_switch_lbl'\n" \
" '*dflt_writeover' 'writeover' 'ask_writeover' " \
" 'no_writeover'\n" \
" '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \
" 'no_preempt_rsv'\n" \
" '*readwrite' 'readwrite' \n" \
" '*auto_density' \n" \
" '*bit_unknown' " \
" ]]\n" \
\
" 'mms' \n" \
" '*nocompression' 'compression' " \
" 'low' 'medium' 'high' 'ultra' \n" \
" '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \
" 'variable' 'block' 'fixed' \n" \
" '*load' 'noload'\n" \
" 'creat' \n" \
" '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \
" '*rewind' 'norewind' \n" \
" '*dflt_vldt_filename' 'validate_filename' " \
" 'no_validate_filename' \n" \
" '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \
" '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \
" '*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \
" 'no_switch_lbl'\n" \
" '*dflt_writeover' 'writeover' 'ask_writeover' " \
" 'no_writeover'\n" \
" '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \
" 'no_preempt_rsv'\n" \
" '*readwrite' 'readwrite' \n" \
" '*auto_density' \n" \
" '*bit_unknown' " \
" ]]\n" \
\
/* \
* MMS device that uses st densities \
* for readonly bitformat \
*/ \
\
" 'mms' \n" \
" '*nocompression' 'compression' " \
" 'low' 'medium' 'high' 'ultra' \n" \
" '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \
" 'variable' 'block' 'fixed' \n" \
" '*load' 'noload'\n" \
" '*oflag' 'old' \n" \
" '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \
" '*rewind' 'norewind' \n" \
" '*dflt_vldt_filename' 'validate_filename' " \
" 'no_validate_filename' \n" \
" '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \
" '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \
" '*dflt_switch_lbl'" \
" 'no_switch_lbl'\n" \
" '*dflt_writeover'" \
" '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \
" 'no_preempt_rsv'\n" \
" 'readonly' \n" \
" '*auto_density' \n" \
" '*bit_unknown' " \
" ]]\n" \
\
\
/* \
* Device that uses specific densities \
* for readonly \
*/ \
\
" 'mms' \n" \
" '*nocompression' 'compression' \n" \
" '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \
" 'variable' 'block' 'fixed' \n" \
" '*load' 'noload'\n" \
" '*oflag' 'old' \n" \
" '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \
" '*rewind' 'norewind' \n" \
" '*dflt_vldt_filename' 'validate_filename' " \
" 'no_validate_filename' \n" \
" '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \
" '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \
" '*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \
" 'no_switch_lbl'\n" \
" '*dflt_writeover' 'writeover' 'ask_writeover' " \
" 'no_writeover'\n" \
" '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \
" 'no_preempt_rsv'\n" \
" 'readonly' \n" \
" '*bit_unknown' " \
" ]] \n" \
\
" densitypriority [ " \
" ]\n" \
" ;"
#ifdef DM_MEM_DEBUG
char *
char *
void
#endif
#define DRV_TAPE_DIR "/dev/rmt"
#define DRV_DIR_TAB_SIZE 20
int dm_silent(void);
#define DRV_PRSV_KEY_PFX "_MMS"
#ifdef __cplusplus
}
#endif
#ifdef MMS_MEM_DEBUG
#include <mms_mem_debug.h>
#endif
#endif /* __DM_DRIVE_H */