|
|
a2ee99 |
diff --git a/mtxl.c b/mtxl.c
|
|
|
a2ee99 |
index 3ae77a6..12ea157 100644
|
|
|
a2ee99 |
--- a/mtxl.c
|
|
|
a2ee99 |
+++ b/mtxl.c
|
|
|
a2ee99 |
@@ -39,6 +39,9 @@
|
|
|
a2ee99 |
/* zap the following define when we finally add real import/export support */
|
|
|
a2ee99 |
#define IMPORT_EXPORT_HACK 1 /* for the moment, import/export == storage */
|
|
|
a2ee99 |
|
|
|
a2ee99 |
+/* only so many element per SCSI Read Element Status */
|
|
|
a2ee99 |
+#define SCSI_RES_ELEMENTS 5000
|
|
|
a2ee99 |
+
|
|
|
a2ee99 |
/* First, do some SCSI routines: */
|
|
|
a2ee99 |
|
|
|
a2ee99 |
/* the camlib is used on FreeBSD. */
|
|
|
a2ee99 |
@@ -1055,7 +1058,7 @@ static void ParseElementStatus( int *EmptyStorageElementAddress,
|
|
|
a2ee99 |
ElementStatus->DataTransferElementSourceStorageElementNumber[ElementStatus->DataTransferElementCount] =
|
|
|
a2ee99 |
BigEndian16(TransportElementDescriptor->SourceStorageElementAddress);
|
|
|
a2ee99 |
|
|
|
a2ee99 |
-#if DEBUG
|
|
|
a2ee99 |
+#ifdef DEBUG
|
|
|
a2ee99 |
fprintf(stderr, "%d: ElementAddress = %d, Full = %d, SourceElement = %d\n",
|
|
|
a2ee99 |
ElementStatus->DataTransferElementCount,
|
|
|
a2ee99 |
ElementStatus->DataTransferElementAddress[ElementStatus->DataTransferElementCount],
|
|
|
a2ee99 |
@@ -1141,6 +1144,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *
|
|
|
a2ee99 |
int empty_idx = 0;
|
|
|
a2ee99 |
boolean is_attached = false;
|
|
|
a2ee99 |
int i,j;
|
|
|
a2ee99 |
+ int FirstElem, NumElements, NumThisRES;
|
|
|
a2ee99 |
|
|
|
a2ee99 |
ElementModeSense_T *mode_sense = NULL;
|
|
|
a2ee99 |
|
|
|
a2ee99 |
@@ -1205,35 +1209,46 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *
|
|
|
a2ee99 |
{
|
|
|
a2ee99 |
#ifdef DEBUG
|
|
|
a2ee99 |
fprintf(stderr,"Using original element status polling method (storage, import/export, drivers etc independantly)\n");
|
|
|
a2ee99 |
+ fprintf(stderr,"Storage start %d, Num %d, max %d\n", mode_sense->StorageStart, mode_sense->NumStorage - mode_sense->NumImportExport, mode_sense->MaxReadElementStatusData);
|
|
|
a2ee99 |
#endif
|
|
|
a2ee99 |
flags->elementtype = StorageElement; /* sigh! */
|
|
|
a2ee99 |
- DataBuffer = SendElementStatusRequest( MediumChangerFD, RequestSense,
|
|
|
a2ee99 |
+
|
|
|
a2ee99 |
+ NumElements = mode_sense->NumStorage - mode_sense->NumImportExport;
|
|
|
a2ee99 |
+ FirstElem = mode_sense->StorageStart;
|
|
|
a2ee99 |
+
|
|
|
a2ee99 |
+ do
|
|
|
a2ee99 |
+ {
|
|
|
a2ee99 |
+ NumThisRES = (NumElements > SCSI_RES_ELEMENTS ? SCSI_RES_ELEMENTS : NumElements);
|
|
|
a2ee99 |
+ DataBuffer = SendElementStatusRequest( MediumChangerFD, RequestSense,
|
|
|
a2ee99 |
inquiry_info, flags,
|
|
|
a2ee99 |
- mode_sense->StorageStart,
|
|
|
a2ee99 |
+ FirstElem,
|
|
|
a2ee99 |
/* adjust for import/export. */
|
|
|
a2ee99 |
- mode_sense->NumStorage - mode_sense->NumImportExport,
|
|
|
a2ee99 |
- mode_sense->MaxReadElementStatusData);
|
|
|
a2ee99 |
+ NumThisRES,
|
|
|
a2ee99 |
+ SCSI_RES_ELEMENTS * 52 +120);
|
|
|
a2ee99 |
|
|
|
a2ee99 |
- if (!DataBuffer)
|
|
|
a2ee99 |
- {
|
|
|
a2ee99 |
+ if (!DataBuffer)
|
|
|
a2ee99 |
+ {
|
|
|
a2ee99 |
#ifdef DEBUG
|
|
|
a2ee99 |
- fprintf(stderr,"Had no elements!\n");
|
|
|
a2ee99 |
+ fprintf(stderr,"Had no elements!\n");
|
|
|
a2ee99 |
#endif
|
|
|
a2ee99 |
- /* darn. Free up stuff and return. */
|
|
|
a2ee99 |
+ /* darn. Free up stuff and return. */
|
|
|
a2ee99 |
#ifdef DEBUG_MODE_SENSE
|
|
|
a2ee99 |
- PrintRequestSense(RequestSense);
|
|
|
a2ee99 |
+ PrintRequestSense(RequestSense);
|
|
|
a2ee99 |
#endif
|
|
|
a2ee99 |
- FreeElementData(ElementStatus);
|
|
|
a2ee99 |
- return NULL;
|
|
|
a2ee99 |
- }
|
|
|
a2ee99 |
+ FreeElementData(ElementStatus);
|
|
|
a2ee99 |
+ return NULL;
|
|
|
a2ee99 |
+ }
|
|
|
a2ee99 |
|
|
|
a2ee99 |
#ifdef DEBUG
|
|
|
a2ee99 |
- fprintf(stderr, "Parsing storage elements\n");
|
|
|
a2ee99 |
+ fprintf(stderr, "Parsing storage elements\n");
|
|
|
a2ee99 |
#endif
|
|
|
a2ee99 |
- ParseElementStatus(EmptyStorageElementAddress, &EmptyStorageElementCount,
|
|
|
a2ee99 |
- DataBuffer,ElementStatus,mode_sense,NULL);
|
|
|
a2ee99 |
+ ParseElementStatus(EmptyStorageElementAddress, &EmptyStorageElementCount,
|
|
|
a2ee99 |
+ DataBuffer,ElementStatus,mode_sense,NULL);
|
|
|
a2ee99 |
|
|
|
a2ee99 |
- free(DataBuffer); /* sigh! */
|
|
|
a2ee99 |
+ free(DataBuffer); /* sigh! */
|
|
|
a2ee99 |
+ FirstElem += SCSI_RES_ELEMENTS;
|
|
|
a2ee99 |
+ NumElements -= SCSI_RES_ELEMENTS;
|
|
|
a2ee99 |
+ } while ( NumElements > 0 );
|
|
|
a2ee99 |
|
|
|
a2ee99 |
/* --------------IMPORT/EXPORT--------------- */
|
|
|
a2ee99 |
/* Next let's see if we need to do Import/Export: */
|
|
|
a2ee99 |
@@ -1247,8 +1262,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *
|
|
|
a2ee99 |
inquiry_info, flags,
|
|
|
a2ee99 |
mode_sense->ImportExportStart,
|
|
|
a2ee99 |
mode_sense->NumImportExport,
|
|
|
a2ee99 |
- mode_sense->MaxReadElementStatusData);
|
|
|
a2ee99 |
-
|
|
|
a2ee99 |
+ SCSI_RES_ELEMENTS * 52 +120);
|
|
|
a2ee99 |
if (!DataBuffer)
|
|
|
a2ee99 |
{
|
|
|
a2ee99 |
#ifdef DEBUG
|
|
|
a2ee99 |
@@ -1283,7 +1297,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *
|
|
|
a2ee99 |
inquiry_info, flags,
|
|
|
a2ee99 |
mode_sense->DataTransferStart,
|
|
|
a2ee99 |
mode_sense->NumDataTransfer,
|
|
|
a2ee99 |
- mode_sense->MaxReadElementStatusData);
|
|
|
a2ee99 |
+ SCSI_RES_ELEMENTS * 52 +120);
|
|
|
a2ee99 |
if (!DataBuffer)
|
|
|
a2ee99 |
{
|
|
|
a2ee99 |
#ifdef DEBUG
|
|
|
a2ee99 |
@@ -1322,7 +1336,7 @@ ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *
|
|
|
a2ee99 |
inquiry_info, flags,
|
|
|
a2ee99 |
mode_sense->MediumTransportStart,
|
|
|
a2ee99 |
1, /* only get 1, sigh. */
|
|
|
a2ee99 |
- mode_sense->MaxReadElementStatusData);
|
|
|
a2ee99 |
+ SCSI_RES_ELEMENTS * 52 +120);
|
|
|
a2ee99 |
if (!DataBuffer)
|
|
|
a2ee99 |
{
|
|
|
a2ee99 |
#ifdef DEBUG
|
|
|
a2ee99 |
|