2 Commits

Author SHA1 Message Date
Alexander Moibenko
cfc1a886e5 Release 1.3.12-15fnal 2019-01-23 15:20:34 -06:00
Alexander Moibenko
60a1e55727 Refresh elements data.
If absolute_addressing == 1 refresh elements data when status command is executed.
This is needed to update tape library information in the calling application.
2019-01-23 15:07:57 -06:00
6 changed files with 23 additions and 132 deletions

View File

@@ -1,2 +1,2 @@
# mtx
The MTX program controls the robotic mechanism in autoloaders and tape libraries. Taken from Sourceforge, patches from centOS were applied, plus my changes to allow to use mtx over library calls.
The MTX program controls the robotic mechanism in autoloaders and tape libraries. Taken from Souceforge, patches from centOS were applied, plus my changes to allow to use mtx over library calls.

BIN
mtx-1.3.12.tgz Normal file

Binary file not shown.

View File

@@ -35,7 +35,7 @@
*/
char *argv0;
#include <ctype.h>
#include "mtx.h" /* various defines for bit order etc. */
#include "mtxl.h"
@@ -80,7 +80,8 @@ static int argc;
static char **argv;
char *device=NULL; /* the device name passed as argument */
int absolute_addressing=0; /* if not 0 - use absolute adresses of storage and tranport elements as known to the robot */
int absolute_addressing=1; /* if not 0 - use absolute adresses of storage and tranport elements as known to the robot */
/* Unfortunately this must be true for SGI, because SGI does not
use an int :-(.
*/
@@ -503,22 +504,11 @@ static void Status(void)
else {
printf("Data Transfer Element %d ", ElementStatus->DataTransferElementAddress[TransferElementNumber]);
phys_loc = (PhysicalLocation_T *) &ElementStatus->DataTransferElementPhysicalLocation[TransferElementNumber];
if (ElementStatus->DataTransferElementSerialNumber[TransferElementNumber][0] == " ")
{
printf("Phys Loc F%u,C%u,R%u,Z%u SN%s ID %s:",
printf("Phys Loc F%u,C%u,R%u,Z%u SN%s ID %s:",
phys_loc->frame, phys_loc->column, phys_loc->row, phys_loc->zone,
ElementStatus->DataTransferElementSerialNumber[TransferElementNumber],
ElementStatus->DataTransferElementProductId[TransferElementNumber]
);
}
else {
printf("Phys Loc F%u,C%u,R%u,Z%u SN %s ID %s:",
phys_loc->frame, phys_loc->column, phys_loc->row, phys_loc->zone,
ElementStatus->DataTransferElementSerialNumber[TransferElementNumber],
ElementStatus->DataTransferElementProductId[TransferElementNumber]
);
}
}
if (ElementStatus->DataTransferElementFull[TransferElementNumber])
{
@@ -565,24 +555,6 @@ static void Status(void)
(ElementStatus->StorageElementFull[StorageElementNumber] ? "Full " : "Empty"));
}
else {
/* some libraries return garbage in physical location */
/* see if entry has non-printable character */
int sl = strlen(ElementStatus->StorageElementPhysicalLocation[StorageElementNumber]);
int sind = 0;
if (sl > 1) {
for (sind = 0; sind < sl; sind++)
{
if ( !isprint(ElementStatus->StorageElementPhysicalLocation[StorageElementNumber][sind])) {
ElementStatus->StorageElementPhysicalLocation[StorageElementNumber][0] = 0;
break;
}
}
}
else {
ElementStatus->StorageElementPhysicalLocation[StorageElementNumber][0] = 0;
}
printf( " Storage Element %d Phys Loc %s %s:%s ", ElementStatus->StorageElementAddress[StorageElementNumber],
ElementStatus->StorageElementPhysicalLocation[StorageElementNumber],
(ElementStatus->StorageElementIsImportExport[StorageElementNumber]) ? " IMPORT/EXPORT" : "",
@@ -651,21 +623,6 @@ void Move(int src, int dest) {
}
}
void Test_UnitReady(void)
{
int result;
result = testUnitReady(MediumChangerFD);
if (result == 0)
{
printf("Ready:yes\n");
}
else
{
printf("Ready:no\n");
}
}
/* okay, now for the Load, Unload, etc. logic: */
@@ -1107,15 +1064,6 @@ int parse_args(void)
return 0;
}
void set_scsi_timeout(int timeout) /* in seconds */
{
set_timeout(timeout);
}
int get_scsi_timeout(void)
{
return get_timeout();
}
int main(int ArgCount, char *ArgVector[])

View File

@@ -1103,24 +1103,8 @@ static void ParseElementStatus( int *EmptyStorageElementAddress,
BigEndian16(TransportElementDescriptor->SourceStorageElementAddress);
InquiryShort_T *inqs;
inqs = (InquiryShort_T *) TransportElementDescriptor->PrimaryVolumeTag;
/* This is a hack to differentiate TS4500 and TFinity returned data */
/* For TFinity
inqs->VendorIdentification[0] == 0x0
and inqs->VendorIdentification[1] == 0x20
*/
if (inqs->VendorIdentification[0] == 0x0 && inqs->VendorIdentification[1] == 0x20)
{
unsigned char * cptr;
cptr = (unsigned char *) &inqs->VendorIdentification[2];
copy_char_buffer(cptr, ElementStatus->DataTransferElementSerialNumber[ElementStatus->DataTransferElementCount], 12);
}
else
{
copy_char_buffer(inqs->SerialNumber, ElementStatus->DataTransferElementSerialNumber[ElementStatus->DataTransferElementCount], 12);
copy_char_buffer(inqs->ProductIdentification+2, ElementStatus->DataTransferElementProductId[ElementStatus->DataTransferElementCount], 12);
}
copy_char_buffer(inqs->SerialNumber, ElementStatus->DataTransferElementSerialNumber[ElementStatus->DataTransferElementCount], 12);
copy_char_buffer(inqs->ProductIdentification+2, ElementStatus->DataTransferElementProductId[ElementStatus->DataTransferElementCount], 12);
ElementStatus->DataTransferElementCount++;
break;
}
@@ -1220,8 +1204,6 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *
int FirstElem, NumElements, NumThisRES;
ElementModeSense_T *mode_sense = NULL;
unsigned char no_barcodes_saved;
if (inquiry_info->MChngr && inquiry_info->PeripheralDeviceType != MEDIUM_CHANGER_TYPE)
{
@@ -1371,7 +1353,6 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *
#endif
flags->elementtype = DataTransferElement; /* sigh! */
flags->absolute_addressing = 0;
DataBuffer = SendElementStatusRequest( MediumChangerFD, RequestSense,
inquiry_info, flags,
mode_sense->DataTransferStart,
@@ -1399,14 +1380,11 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *
free(DataBuffer); /* sigh! */
flags->absolute_addressing = 1;
no_barcodes_saved = flags->no_barcodes;
flags->no_barcodes = 1;
DataBuffer = SendElementStatusRequest( MediumChangerFD, RequestSense,
inquiry_info, flags,
mode_sense->DataTransferStart,
mode_sense->NumDataTransfer,
SCSI_RES_ELEMENTS * 52 +120);
flags->no_barcodes = no_barcodes_saved;
if (!DataBuffer)
{
#ifdef DEBUG
@@ -1892,7 +1870,7 @@ int ClearUnitAttention(DEVICE_TYPE fd, RequestSense_T *RequestSense)
&unit_attention_sense, sizeof(unit_attention_sense),
RequestSense) != 0)
{
fprintf(stderr, "RequestSense (0x03) failed\n");
fprintf(stderr, "RequestSense (0x03) failed\n");
return -1; /* could not do! */
}
@@ -1906,27 +1884,6 @@ int ClearUnitAttention(DEVICE_TYPE fd, RequestSense_T *RequestSense)
}
/* Test unit ready: This will tell us whether the tape drive
* is currently ready to read or write.
*/
int testUnitReady(DEVICE_TYPE fd)
{
RequestSense_T sense;
CDB_T CDB;
unsigned char buffer[6];
CDB[0] = 0x00; /* TEST_UNIT_READY */
CDB[1] = 0;
CDB[2] = 0;
CDB[3] = 0; /* 1-5 all unused. */
CDB[4] = 0;
CDB[5] = 0;
slow_bzero((char *)&sense,sizeof(RequestSense_T));
return SCSI_ExecuteCommand(fd,Input,&CDB,6,buffer,0,&sense);
}
static char Spaces[] = " ";
void PrintHex(int Indent, unsigned char *Buffer, int Length)

View File

@@ -1,10 +1,10 @@
/*
/*
MTX -- SCSI Tape Attached Medium Changer Control Program
Copyright 1997-1998 Leonard N. Zubkoff <lnz@dandelion.com>
Copyright 2007-2008 by Robert Nelson <robertn@the-nelsons.org>
This file created by Eric Lee Green <eric@badtux.org>
This program is free software; you may redistribute and/or modify it under
the terms of the GNU General Public License Version 2 as published by the
Free Software Foundation.
@@ -67,8 +67,8 @@ Inquiry_T *RequestInquiry( DEVICE_TYPE fd,
RequestSense_T *MoveMedium( DEVICE_TYPE MediumChangerFD,
int SourceAddress,
int DestinationAddress,
ElementStatus_T *ElementStatus,
int DestinationAddress,
ElementStatus_T *ElementStatus,
Inquiry_T *inquiry_info,
SCSI_Flags_T *flags);
@@ -76,7 +76,7 @@ RequestSense_T *ExchangeMedium( DEVICE_TYPE MediumChangerFD,
int SourceAddress,
int DestinationAddress,
int Dest2Address,
ElementStatus_T *ElementStatus,
ElementStatus_T *ElementStatus,
SCSI_Flags_T *flags);
RequestSense_T *PositionElement(DEVICE_TYPE MediumChangerFD,
@@ -91,9 +91,6 @@ RequestSense_T *Erase(DEVICE_TYPE fd); /* send SHORT erase to drive */
void SCSI_Set_Timeout(int secs); /* set the SCSI timeout */
void SCSI_Default_Timeout(void); /* go back to default timeout */
int testUnitReady(DEVICE_TYPE fd); /* issue Test Unit Ready SCSI command */
void set_timeout(int timeout); /* set scsi operation timeout */
int get_timeout(void); /* get scsi operation timeout */
/* we may not have this function :-(. */
#ifdef HAVE_GET_ID_LUN
@@ -101,12 +98,12 @@ int get_timeout(void); /* get scsi operation timeout */
#endif
/* These two hacks are so that I can stick the tongue out on an
* NSM optical jukebox.
*/
NSM_Result_T *RecNSMHack(DEVICE_TYPE MediumChangerFD,
* NSM optical jukebox.
*/
NSM_Result_T *RecNSMHack(DEVICE_TYPE MediumChangerFD,
int param_len, int timeout);
int SendNSMHack(DEVICE_TYPE MediumChangerFD, NSM_Param_T *nsm_command,
int SendNSMHack(DEVICE_TYPE MediumChangerFD, NSM_Param_T *nsm_command,
int param_len, int timeout);
#endif

View File

@@ -57,21 +57,10 @@ $Revision: 193 $
static int pack_id;
static int sg_timeout;
int sg_scsi_default_timeout = SG_SCSI_DEFAULT_TIMEOUT;
void set_timeout(int timeout)
{
sg_scsi_default_timeout = HZ*timeout;
}
int get_timeout(void)
{
return(sg_scsi_default_timeout/HZ);
}
DEVICE_TYPE SCSI_OpenDevice(char *DeviceName)
{
int timeout = sg_scsi_default_timeout;
int timeout = SG_SCSI_DEFAULT_TIMEOUT;
#ifdef SG_IO
int k; /* version */
#endif
@@ -104,7 +93,7 @@ void SCSI_Set_Timeout(int secs)
void SCSI_Default_Timeout(void)
{
sg_timeout = sg_scsi_default_timeout;
sg_timeout = SG_SCSI_DEFAULT_TIMEOUT;
}
void SCSI_CloseDevice(char *DeviceName, DEVICE_TYPE DeviceFD)
@@ -267,13 +256,13 @@ int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
int write_length = sizeof(struct sg_header)+CDB_Length;
int i; /* a random index... */
int result; /* the result of the write... */
int result; /* the result of the write... */
struct sg_header *Header; /* we actually point this into Command... */
struct sg_header *ResultHeader; /* we point this into ResultBuf... */
/* First, see if we need to set our SCSI timeout to something different */
if (sg_timeout != sg_scsi_default_timeout)
if (sg_timeout != SG_SCSI_DEFAULT_TIMEOUT)
{
/* if not default, set it: */
#ifdef DEBUG_TIMEOUT
@@ -459,9 +448,9 @@ int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
}
/* See if we need to reset our SCSI timeout */
if (sg_timeout != sg_scsi_default_timeout)
if (sg_timeout != SG_SCSI_DEFAULT_TIMEOUT)
{
sg_timeout = sg_scsi_default_timeout; /* reset it back to default */
sg_timeout = SG_SCSI_DEFAULT_TIMEOUT; /* reset it back to default */
#ifdef DEBUG_TIMEOUT
fprintf(stderr,"Setting timeout to %d\n", sg_timeout);