CentOS last version with applied patches.

This commit is contained in:
Alexander Moibenko
2018-07-31 17:07:29 -05:00
parent efde4187b4
commit 3718d257b2
8 changed files with 173 additions and 93 deletions

View File

@@ -33,6 +33,7 @@ INSTALL_DOC = $(INSTALL) -m 644
INSTALL_BIN = $(INSTALL) -m 755 INSTALL_BIN = $(INSTALL) -m 755
INSTALL_DIR = $(INSTALL) -m 755 -d INSTALL_DIR = $(INSTALL) -m 755 -d
DESTDIR =
prefix = @prefix@ prefix = @prefix@
exec_prefix = @exec_prefix@ exec_prefix = @exec_prefix@
sbindir = @sbindir@ sbindir = @sbindir@
@@ -109,13 +110,13 @@ all: $(BINS)
dbgs: $(DBGS) dbgs: $(DBGS)
install: $(BINS) install: $(BINS)
$(INSTALL_DIR) $(sbindir) $(INSTALL_DIR) $(DESTDIR)$(sbindir)
for file in $(BINS); do \ for file in $(BINS); do \
$(INSTALL_BIN) "$$file" $(sbindir) ; \ $(INSTALL_BIN) "$$file" $(DESTDIR)$(sbindir) ; \
done done
$(INSTALL_DIR) $(mandir) $(mandir)/man1 $(INSTALL_DIR) $(DESTDIR)$(mandir) $(DESTDIR)$(mandir)/man1
for file in mtx.1 tapeinfo.1 scsitape.1 scsieject.1 loaderinfo.1 ; do \ for file in mtx.1 tapeinfo.1 scsitape.1 scsieject.1 loaderinfo.1 ; do \
$(INSTALL_DOC) "$$file" $(mandir)/man1 ; \ $(INSTALL_DOC) "$$file" $(DESTDIR)$(mandir)/man1 ; \
done done
clean: clean:

View File

@@ -488,7 +488,6 @@ int main(int argc, char **argv)
argv0=argv[0]; argv0=argv[0];
if (argc != 3) if (argc != 3)
{ {
fprintf(stderr,"argc=%d",argc);
usage(); usage();
} }

View File

@@ -131,13 +131,16 @@ may need to eject the tape using your OS's tape control commands
first). Note that this command may not be what you want on large first). Note that this command may not be what you want on large
tape libraries -- e.g. on Exabyte 220, the first slot is usually a tape libraries -- e.g. on Exabyte 220, the first slot is usually a
cleaning tape. If <drivenum> is omitted, defaults to first drive. cleaning tape. If <drivenum> is omitted, defaults to first drive.
.TP 10 .TP 10
.B last [<drivenum>] .B last [<drivenum>]
Loads drive <drivenum> from the last slot in the media changer. Unloads Loads drive <drivenum> from the last slot in the media changer. Unloads
the drive if there is already a tape in it. (Note: you may need to eject the drive if there is already a tape in it. (Note: you may need to eject
the tape using your OS's tape control commands first). the tape using your OS's tape control commands first).
.TP 10 .TP 10
.B previous [<drivenum>]
Unloads the drive and loads the previous tape in sequence. If the drive
was empty, loads the first tape into the drive.
.TP 10
.B next [<drivenum>] .B next [<drivenum>]
Unloads the drive and loads the next tape in sequence. If the drive was Unloads the drive and loads the next tape in sequence. If the drive was
empty, loads the first tape into the drive. empty, loads the first tape into the drive.
@@ -145,6 +148,9 @@ empty, loads the first tape into the drive.
.B position <slotnum> .B position <slotnum>
Positions the robot at a specific slot. Needed by some changers to Positions the robot at a specific slot. Needed by some changers to
move to and open the import/export, or mailbox, slot. move to and open the import/export, or mailbox, slot.
.TP 10
.B eject
Eject the tape currently in the drive.
.SH AUTHORS .SH AUTHORS
The original 'mtx' program was written by Leonard Zubkoff and extensively The original 'mtx' program was written by Leonard Zubkoff and extensively

View File

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

View File

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

View File

@@ -1,62 +0,0 @@
--- ../mtx-1.3.12/Makefile.in 2018-07-27 17:19:28.789345628 -0500
+++ ./Makefile.in 2018-07-30 13:48:52.794193274 -0500
@@ -13,6 +13,7 @@
BINS = mtx@EXEEXT@ tapeinfo@EXEEXT@ loaderinfo@EXEEXT@ scsitape@EXEEXT@ scsieject@EXEEXT@
EXTRA_BINS = nsmhack@EXEEXT@
+LIB=libmtx.a
DBGS := $(BINS:%@EXEEXT@=%.dbg)
MAN = mtx.1 tapeinfo.1 loaderinfo.1 scsitape.1 scsieject.1
MAN_HTML := $(MAN:%.1=%.html)
@@ -32,6 +33,7 @@
INSTALL_DOC = $(INSTALL) -m 644
INSTALL_BIN = $(INSTALL) -m 755
INSTALL_DIR = $(INSTALL) -m 755 -d
+INSTALL_LIB = $(INSTALL) -m 755
DESTDIR =
prefix = @prefix@
@@ -39,6 +41,7 @@
sbindir = @sbindir@
mandir = @mandir@
srcdir = @srcdir@
+libdir = @libdir@
VPATH = $(srcdir)
@@ -105,7 +108,7 @@
strip $< -o $@
endif
-all: $(BINS)
+all: $(BINS) $(LIB)
dbgs: $(DBGS)
@@ -118,6 +121,7 @@
for file in mtx.1 tapeinfo.1 scsitape.1 scsieject.1 loaderinfo.1 ; do \
$(INSTALL_DOC) "$$file" $(DESTDIR)$(mandir)/man1 ; \
done
+ $(INSTALL_LIB) $(LIB) $ $(DESTDIR(libdir);
clean:
rm -f *.o *~ mtx-*.zip
@@ -134,6 +138,8 @@
dist: distclean
./makedist $(VERSION)
+libmtx: libmtx.a
+
loaderinfo@EXEEXT@: loaderinfo.o mtxl.o mtxl.h mtx.h $(EXTRA)
$(CC) $(LDFLAGS) -o loaderinfo@EXEEXT@ loaderinfo.o mtxl.o $(EXTRA) $(LIBS)
@@ -160,6 +166,9 @@
scsieject@EXEEXT@: scsieject.o mtxl.o mtxl.h mtx.h $(EXTRA)
$(CC) $(LDFLAGS) -o scsieject@EXEEXT@ scsieject.o mtxl.o $(EXTRA) $(LIBS)
+$(LIB): mtx.o mtxl.o
+ ar qvs $(LIB) mtx.o mtxl.o
+
scsieject.o: scsieject.c mtx.h mtxl.h
loaderinfo.o: loaderinfo.c mtx.h mtxl.h

View File

@@ -63,7 +63,7 @@
#endif #endif
void Usage(void) { void Usage(void) {
FatalError("Usage: scsitape -f <generic-device> <command> where <command> is:\n setblk <n> | fsf <n> | bsf <n> | eod | rewind | eject | mark <n> |\n seek <n> | read [<blksize> [<numblocks]] | write [<blocksize>] \n"); FatalError("Usage: scsitape -f <generic-device> <command> where <command> is:\n setblk <n> | fsf <n> | bsf <n> | eod | rewind | eject | erase |\n mark <n> | seek <n> | read [<blksize> [<numblocks]] |\n write [<blocksize>]\n");
} }
#define arg1 (arg[0]) /* for backward compatibility, sigh */ #define arg1 (arg[0]) /* for backward compatibility, sigh */

View File

@@ -933,7 +933,6 @@ int main(int argc, char **argv)
if (argc != 3) if (argc != 3)
{ {
fprintf(stderr,"argc=%d",argc);
usage(); usage();
} }