diff --git a/mtx-1.3.12/mtx.c b/mtx-1.3.12/mtx.c index 9a28258..210b389 100644 --- a/mtx-1.3.12/mtx.c +++ b/mtx-1.3.12/mtx.c @@ -622,7 +622,22 @@ 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: */ static void Load(void) diff --git a/mtx-1.3.12/mtxl.c b/mtx-1.3.12/mtxl.c index 1066384..b7741e7 100644 --- a/mtx-1.3.12/mtxl.c +++ b/mtx-1.3.12/mtxl.c @@ -1870,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! */ } @@ -1884,6 +1884,27 @@ 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)