dm_default.c 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.
*/
#include <syslog.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <ctype.h>
#include <dlfcn.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <stropts.h>
#include <mms_dmd.h>
#include <mms_trace.h>
#include <dmd_impl.h>
#include <dm_drive.h>
#include <mms_sym.h>
#include <dda.h>
/*
* specify timeouts for this drive. Time is specified in seconds.
*/
(151 *60), /* For really long commands */
(20 *60), /* Normal commands */
(1 *60), /* short commands */
};
/*
* Specify the drive type.
* Drive type must begin with "dt_"
*/
char drv_drive_type[] = "dt_XXXXX";
/*
* Specify the directory in which this device can be found.
*
* The DM will open each device in this directory and look for a device
* whose serial number matches the serial number specified in
* DRIVE.'DriveSerialNum'.
* If this is a null string, then the full pathname of the device is specified
* in DM.'DMTargetPath'.
*/
char drv_dev_dir[] = "/dev/rmt";
/*
* drv_density[]
* - Specify density names with their density codes supported by this DM.
* - Densities must be specified in the order of their selection priority.
* The ones at the beginning of the list will be selected before those
* at the end of the list.
* - Density names must start with "den_" to avoid conflict with other names.
*/
mms_sym_t drv_density[] = {
NULL, /* Must be the last entry */
};
/*
* drv_shape[]
* - Specify shape names of cartridge types supported by this DM.
* - Shape names must be specified in the order of their selection priority.
* The ones at the beginning of the list will be selected before those
* at the end of the list.
* - Shape name must be a well known and published name.
*/
char *drv_shape[] = {
NULL /* Must be last entry */
};
/*
* drv_shape_den[]
* Specify the shape of a cartridge and the density on it that can be
* written over by a readwrite density.
* All shape names and density names must have been specified in
* drv_density[] and drv_shape[].
* Each entry of the array consists of:
* {shapename, density on cart, readwrite density}.
* If the density on cartridge is the same as the readwrite density, then
* the drive can read and write with that density.
* If the density on cartridge is read only, then the readwrite density
* is NULL.
* If the readwrite density is not NULL and it is different from the density
* on cartridge, then the drive is able to write over the existing data
* starting from the beginning of medium.
*/
/* shapename existing den readwrite density */
/*
* Specify readwrite density
*/
/*
* Specify readonly density
*/
NULL /* Must be last entry */
};
/*
* drv_mounted[]
* Specify mount points of disk files that emulate cartridges.
* Real cartridges do not have mount points.
*/
char *drv_mounted[] = {
"*none", /* Real cartridge has not mount point */
NULL, /* Must be last entry */
};
/*
* Specify SCSI commands that a client may not issue using USCSI
*/
int drv_disallowed_cmds[] = {
SCMD_PROUT, /* persistent reserve out */
SCMD_RESERVE, /* reserve */
SCMD_RELEASE, /* release */
};
int drv_num_disallowed_cmds =
sizeof (drv_disallowed_cmds) / sizeof (int);
/*
* Specify ioctl's that a client may not issue
*/
int drv_disallowed_ioctls[] = {
};
sizeof (drv_disallowed_ioctls) / sizeof (int);
/*
* Sense key, asc and ascq table (skaa)
* 0xff matches any value in lookup operation.
*/
drv_skaa_t drv_skaa_tab[] = {
/*
* Error text must be less than or equal to 80 characters.
*/
"no additional sense information",
"filemark detected",
"end-of-partition/medium detected",
"setmark detected",
"beginning-of-partition/medium detected",
"end-of-data detected",
"I/O process terminated",
"operation in progress",
"cleaning requested",
"erase operation in progress",
"locate operation in progress",
"rewind operation in progress",
"set capacity operation in progress",
"verify operation in progress",
"ATA pass through information available",
"peripheral device write fault",
"no write current",
"excessive write errors",
"logical unit not ready, cause not reportable",
"logical unit is in process of becoming ready",
"logical unit not ready, initializing command required",
"logical unit not ready, manual intervention required",
"logical unit not ready, format in progress",
"logical unit not ready, rebuild in progress",
"logical unit not ready, recalculation in progress",
"logical unit not ready, operation in progress",
"logical unit not ready, self-test in progress",
"logical unit not accessible, asymmetric access state transition",
"logical unit not accessible, target port in standby state",
"logical unit not accessible, target port in unavailable state",
"logical unit not ready, auxiliary memory not accessible",
"logical unit not ready, notify (enable spinup) required",
"logical unit does not respond to selection",
"multiple peripheral devices selected",
"logical unit communication failure",
"logical unit communication time-out",
"logical unit communication parity error",
"logical unit communication crc error (ULTRA-DMA/32)",
"unreachable copy target",
"track following error",
"head select fault",
"error log overflow",
"warning",
"warning - specified temperature exceeded",
"warning - enclosure degraded",
"warning - background self-test failed",
"warning - background pre-scan detected medium error",
"warning - background medium scan detected medium error",
"write error",
"compression check miscompare error",
"data expansion occurred during compression",
"block not compressible",
"auxiliary memory write error",
"write error - unexpected unsolicited data",
"write error - not enough unsolicited data",
"error detected by third party temporary initiator",
"third party device failure",
"copy target device not reachable",
"incorrect copy target device type",
"copy target device data underrun",
"copy target device data overrun",
"invalid information unit",
"information unit too short",
"information unit too long",
"invalid field in command information unit",
"logical block guard check failed",
"logical block application tag check failed",
"logical block reference tag check failed",
"unrecovered read error",
"read retries exhausted",
"error too long to correct",
"multiple read errors",
"incomplete block read",
"no gap found",
"miscorrected error",
"de-compression crc error",
"cannot decompress using declared algorithm",
"auxiliary memory read error",
"read error - failed retransmission request",
"recorded entity not found",
"record not found",
"filemark or setmark not found",
"end-of-data not found",
"block sequence error",
"record not found - recommend reassignment",
"record not found - data auto-reallocated",
"locate operation failure",
"random positioning error",
"mechanical positioning error",
"positioning error detected by read of medium",
"recovered data with no error correction applied",
"recovered data with retries",
"recovered data with positive head offset",
"recovered data with negative head offset",
"recovered data with error correction applied",
"parameter list length error",
"synchronous data transfer error",
"miscompare during verify operation",
"invalid command operation code",
"access denied - initiator pending-enrolled",
"access denied - no access rights",
"access denied - invalid mgmt id key",
"illegal command while in write capable state",
"obsolete",
"illegal command while in explicit mms_address mode",
"illegal command while in implicit mms_address mode",
"access denied - enrollment conflict",
"access denied - invalid lu identifier",
"access denied - invalid proxy token",
"access denied - acl lun conflict",
"logical block mms_address out of range",
"invalid element mms_address",
"invalid field in cdb",
"cdb decryption error",
"obsolete",
"obsolete",
"logical unit not supported",
"invalid field in parameter list",
"parameter not supported",
"parameter value invalid",
"threshold parameters not supported",
"invalid release of persistent reservation",
"data decryption error",
"too many target descriptors",
"unsupported target descriptor type code",
"too many segment descriptors",
"unsupported segment descriptor type code",
"unexpected inexact segment",
"inline data length exceeded",
"invalid operation for copy source or destination",
"copy segment granularity violation",
"invalid parameter while port is enabled",
"data decryption key fail limit reached",
"incomplete key-associated data set",
"vendor specific key reference not found",
"write protected",
"hardware write protected",
"logical unit software write protected",
"associated write protect",
"persistent write protect",
"permanent write protect",
"not ready to ready change, medium may have changed",
"import or export element accessed",
"power on, reset, or bus device reset occurred",
"power on occurred",
"scsi bus reset occurred",
"bus device reset function occurred",
"device internal reset",
"transceiver mode changed to single-ended",
"transceiver mode changed to lvd",
"i_t nexus loss occurred",
"parameters changed",
"mode parameters changed",
"log parameters changed",
"reservations preempted",
"reservations released",
"registrations preempted",
"asymmetric access state changed",
"implicit asymmetric access state transition failed",
"priority changed",
"timestamp changed",
"data encryption parameters changed by another i_t nexus",
"data encryption parameters changed by vendor specific event",
"data encryption key instance counter has changed",
"copy cannot execute since host cannot disconnect",
"command sequence error",
"previous busy status",
"previous task set full status",
"previous reservation conflict status",
"not reserved",
"overwrite error on update in place",
"commands cleared by another initiator",
"commands cleared by device server",
"incompatible medium installed",
"cannot read medium - unknown format",
"cannot read medium - incompatible format",
"cleaning cartridge installed",
"cannot write medium - unknown format",
"cannot write medium - incompatible format",
"cannot format medium - incompatible medium",
"cleaning failure",
"cleaning request rejected",
"worm medium - overwrite attempted",
"worm medium - integrity check",
"medium format corrupted",
"tape length error",
"enclosure failure",
"enclosure services failure",
"unsupported enclosure function",
"enclosure services unavailable",
"enclosure services transfer failure",
"enclosure services transfer refused",
"enclosure services checksum error",
"rounded parameter",
"saving parameters not supported",
"medium not present",
"medium not present - tray closed",
"medium not present - tray open",
"medium not present - loadable",
"medium not present - medium auxiliary memory accessible",
"sequential positioning error",
"tape position error at beginning-of-medium",
"tape position error at end-of-medium",
"reposition error",
"position past beginning of medium",
"medium destination element full",
"medium source element empty",
"medium magazine not accessible",
"medium magazine removed",
"medium magazine inserted",
"medium magazine locked",
"medium magazine unlocked",
"invalid bits in identify message",
"logical unit has not self-configured yet",
"logical unit failure",
"timeout on logical unit",
"logical unit failed self-test",
"logical unit unable to update self-test log",
"target operating conditions have changed",
"microcode has been changed",
"changed operating definition",
"inquiry data has changed",
"component device attached",
"device identifier changed",
"redundancy group created or modified",
"redundancy group deleted",
"spare created or modified",
"spare deleted",
"volume set created or modified",
"volume set deleted",
"volume set deassigned",
"volume set reassigned",
"reported luns data has changed",
"echo buffer overwritten",
"medium loadable",
"medium auxiliary memory accessible",
"iscsi ip mms_address added",
"iscsi ip mms_address removed",
"iscsi ip mms_address changed",
"diagnostic failure on component nn (80h-ffh)",
"message error",
"internal target failure",
"ata device failed set features",
"select or reselect failure",
"unsuccessful soft reset",
"scsi parity error",
"data phase crc error detected",
"scsi parity error detected during st data phase",
"information unit iucrc error detected",
"asynchronous information protection error detected",
"protocol service crc error",
"phy test function in progress",
"some commands cleared by iscsi protocol event",
"initiator detected error message received",
"invalid message error",
"command phase error",
"data phase error",
"invalid target port transfer tag received",
"too much write data",
"nak received",
"data offset error",
"initiator response timeout",
"logical unit failed self-configuration",
"tagged overlapped commands (nn = task tag)",
"overlapped commands attempted",
"write append error",
"write append position error",
"position error related to timing",
"erase failure",
"cartridge fault",
"media load or eject failed",
"unload tape failure",
"medium removal prevented",
"medium thread or unthread failure",
"insufficient reservation resources",
"insufficient resources",
"insufficient registration resources",
"insufficient access control resources",
"auxiliary memory out of space",
"maximum number of supplemental decryption keys exceeded",
"operator request or state change input",
"operator medium removal request",
"operator selected write protect",
"operator selected write permit",
"log exception",
"threshold condition met",
"log counter at maximum",
"log list codes exhausted",
"failure prediction threshold exceeded",
"failure prediction threshold exceeded (false)",
"low power condition on",
"idle condition activated by timer",
"standby condition activated by timer",
"idle condition activated by command",
"standby condition activated by command",
"voltage fault",
"set target port groups command failed",
"ata device feature not enabled",
"decompression exception short algorithm id of nn",
"decompression exception long algorithm id",
"security error",
"unable to decrypt data",
"unencrypted data encountered while decrypting",
"incorrect data encryption key",
"cryptographic integrity validation failed",
"error decrypting data",
"unknown signature verification key",
"encryption parameters not useable",
"digital signature validation failure",
"encryption mode mismatch on read",
"encrypted block not raw read enabled",
"incorrect encryption parameters",
"logical unit access not authorized",
/*
* Sense keys
*/
"no sense",
"recovered error",
"not ready",
"medium error",
"hardware error",
"illegal request",
"unit attention",
"data protect",
"blank check",
"vendor specific",
"copy aborted",
"aborted command",
"volume overflow",
"data miscompare",
/*
* This must be the last entry
*/
"Unknown error",
};
/*
* Initialize device.
* Real drives don't use this.
*/
void
drv_init_dev(void)
{
}
/*
* Return array of mounted FS for disk archiving.
* Real devices don't have mounted FS for disk archiving.x
*/
char **
drv_get_mounted(void)
{
return (&drv_mounted[0]);
}
/*
* drv_set_blksize - set blocksize
*/
int
{
int one = 1;
if (dm_mtiocltop(&op) != 0) {
return (EIO);
}
/*
* Supresse SILI
*/
if (size == 0) {
}
return (0);
}
/*
* drv_set_blksize - set blocksize
*/
int
{
if (dm_mtiocltop(&op) != 0) {
return (EIO);
}
return (0);
}
drv_get_avail_capacity(void)
{
return (EIO);
}
}
int
{
int off;
int i;
if (DRV_CALL(drv_log_sense,
return (EIO);
}
for (i = 0; i < 4; i++) {
break;
}
}
for (i = 0; i < 4; i++) {
break;
}
}
if (max > 0) {
cap->mms_pc_avail = 0;
}
} else {
cap->mms_pc_avail = 0;
}
return (0);
}
/*
* drv_mode_sense - issue mode sense
* - page - page code
* - len - allocation length
*
* - always return block descriptor block
* - always get current value
*/
int
{
return (EIO);
}
return (EIO);
}
return (0);
}
/*
* drv_mode_select - issue mode select
* - pf - page format - 0, no page data, or 1, send page data
* - len - allocation length
*/
int
{
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_inquiry(void)
{
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_req_sense(int len)
{
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_get_drivetype(void)
{
struct mtdrivetype type;
/*
* This is necessary because the MTIOCGETDRIVETYPE ioctl does not
* return the full length of the product id and we need the full
* product id.
*/
if (DRV_CALL(drv_inquiry, ()) == 0) {
}
/*
* Try doing MTIOCGETDRIVETYPE
*/
return (EIO);
}
}
return (0);
}
int
drv_clrerr(void)
{
int rc = 0;
if (dm_ioctl(MTIOCLRERR, 0) < 0) {
}
return (rc);
}
int
{
int rc;
int err;
char dumpbuf[1024];
if (rc <= 0) {
dm_get_mtstat(0);
DRV_CALL(drv_proc_error, ());
/* set DriveBroken to "yes" */
(void) dm_send_drive_broken();
/* Set CartridgeMediaError to "yes" */
(void) dm_send_cartridge_media_error();
}
} else {
}
return (rc);
}
int
{
int rc = 0;
int err;
while (rc == 0) {
/*
* If rc == 0, then we are in EOT and have to try again
*/
}
dm_get_mtstat(0);
/* at EOT and block was written */
return (len);
}
DRV_CALL(drv_proc_error, ());
/* set DriveBroken to "yes" */
(void) dm_send_drive_broken();
/* Set CartridgeMediaError to "yes" */
(void) dm_send_cartridge_media_error();
}
}
return (rc);
}
/*
* drv_wtm - write tapemarks
* return residual
*/
int
{
int rc;
}
rc = 0;
}
return (rc);
}
int
drv_tur(void)
{
us.uscsi_buflen = 0;
for (;;) {
/* ignore attention for now and try again */
continue;
}
return (EIO);
}
break;
}
return (0);
}
int
drv_load(void)
{
us.uscsi_buflen = 0;
for (;;) {
/* Drive became ready */
break;
}
/* ignore attention and try again */
continue;
}
return (EIO);
}
}
break;
}
return (0);
}
int
drv_unload(void)
{
if (dm_mtiocltop(&op) != 0) {
return (EIO);
}
}
return (0);
}
int
drv_rewind(void)
{
if (dm_mtiocltop(&op) != 0) {
return (EIO);
}
return (0);
}
int
{
if (dm_mtiocltop(&op) != 0) {
return (EIO);
}
return (0);
}
int
{
if (dm_mtiocltop(&op) != 0) {
return (EIO);
}
return (0);
}
int
{
if (dm_mtiocltop(&op) != 0) {
return (EIO);
}
return (0);
}
int
{
if (dm_mtiocltop(&op) != 0) {
return (EIO);
}
return (0);
}
int
{
int err = 0;
int rc = 0;
if (dm_mtiocltop(&op) != 0) {
/* Hit a tapemark */
if (cross == DRV_LOGICAL_CROSS_TM) {
}
}
}
return (rc);
}
int
{
int err = 0;
int rc = 0;
if (dm_mtiocltop(&op) != 0) {
/* Hit a tapemark */
if (cross == DRV_LOGICAL_CROSS_TM) {
}
}
}
return (rc);
}
int
drv_eom(void)
{
if (dm_mtiocltop(&op) != 0) {
return (EIO);
}
return (0);
}
int
{
#if 1
return (EIO);
}
return (0);
#else
int rc;
{ 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
return (EIO);
}
return (EIO);
}
return (0);
#endif
}
int
{
#if 1
return (EIO);
}
return (0);
#else
int rc;
{ 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
return (EIO);
}
us.uscsi_flags |= 0;
us.uscsi_buflen = 0;
return (EIO);
}
return (EIO);
}
return (0);
#endif
}
int
{
{ 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
return (EIO);
}
return (EIO);
}
return (0);
}
int
{
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_release(void)
{
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_prsv_register(void)
{
{ 0x5f, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 };
char parm[24];
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_prsv_reserve(void)
{
{ 0x5f, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 };
char parm[24];
/*
* Set reservation key
*/
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_prsv_release(void)
{
{ 0x5f, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 };
char parm[24];
/*
* Set reservation key
*/
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_prsv_preempt(char *curkey)
{
{ 0x5f, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 };
char parm[24];
/*
* Set reservation key
*/
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_prsv_clear(void)
{
{ 0x5f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 };
char parm[24];
/*
* Set reservation key
*/
return (EIO);
}
return (EIO);
}
return (0);
}
int
{
{ 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
return (EIO);
}
return (EIO);
}
return (0);
}
int
{
{ 0x5e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_reserve(void)
{
return (EIO);
}
return (EIO);
}
return (0);
}
int
drv_get_serial_num(char *ser)
{
int i;
int len;
return (EIO);
}
return (EIO);
}
for (i = len - 1; i >= 0; i--) {
ser[i] = '\0';
} else {
break;
}
}
return (0);
}
int
drv_get_write_protect(int *wp)
{
char dumpbuf[512];
/*
* Read mode sense data
*/
return (EIO);
}
return (0);
}
int
drv_set_compression(int comp)
{
char dumpbuf[512];
int len;
/*
* Read mode sense data and switch to desired density
*/
return (EIO);
}
sizeof (dumpbuf));
/*
* Set compression
*/
if (comp) {
} else {
}
sizeof (dumpbuf));
len = 28;
/*
* If enabling compression, set select data compression algorithm
* in sequencial access device config page (0x10) to 1
*/
if (comp) {
return (EIO);
}
sizeof (dumpbuf));
sizeof (dumpbuf));
len += 16;
}
return (EIO);
}
return (0);
}
void
drv_disallowed(void)
{
}
void
drv_mk_prsv_key(void)
{
}
int
drv_rebind_target(void)
{
return (dm_rebind_target());
}
int
drv_bind_raw_dev(int oflags)
{
return (dm_bind_raw_dev(oflags));
}
void
drv_proc_error(void)
{
/*
* Check SCSI command status
*/
/*
* Handle USCSI error
*/
case DRV_EC_ERROR :
break;
case DRV_EC_NOT_READY :
break;
case DRV_EC_NO_SENSE :
break;
case DRV_EC_TM :
break;
case DRV_EC_EOD :
break;
case DRV_EC_EOM :
break;
case DRV_EC_BOM :
break;
case DRV_EC_NEEDS_CLEANING :
break;
case DRV_EC_FORMAT :
break;
case DRV_EC_INTER_REQ :
break;
case DRV_EC_RESET :
break;
case DRV_EC_UNIT_ATTN :
break;
case DRV_EC_LOST_PRSV :
break;
case DRV_EC_RCVD_ERR :
break;
case DRV_EC_MEDIUM_ERR :
break;
case DRV_EC_HW_ERR :
break;
case DRV_EC_ILLEGAL_REQ :
break;
case DRV_EC_DATA_PROTECT :
break;
case DRV_EC_BLANK_CHECK :
break;
case DRV_EC_VENDOR :
break;
case DRV_EC_COPY_ABORTED :
break;
case DRV_EC_ABORTED :
break;
case DRV_EC_VOL_OVERFLOW :
break;
case DRV_EC_MISCOMPARE :
break;
case DRV_EC_NREADY_TO_READY :
break;
default :
break;
}
}
}
int
drv_get_statistics(void)
{
char dumpbuf[1024];
/*
* log sense pages needed 0x02, 0x03, 0x0c
*/
/*
* write error counts
*/
sizeof (dumpbuf));
sizeof (dumpbuf));
sizeof (dumpbuf));
return (0);
}
int
{
char dumpbuf[512];
int cmp;
/*
* Read mode sense data and switch to desired density
*/
return (EIO);
}
}
return (0);
}
int
drv_set_density(int den)
{
char dumpbuf[512];
/*
* Read mode sense data and switch to desired density
*/
return (EIO);
}
sizeof (dumpbuf));
/*
* Set density
*/
sizeof (dumpbuf));
return (EIO);
}
return (0);
}