diff --git a/SOURCES/emc-fix-fail-with-too-high-slot-count_cleanupver.patch b/SOURCES/emc-fix-fail-with-too-high-slot-count_cleanupver.patch new file mode 100644 index 0000000..242b28d --- /dev/null +++ b/SOURCES/emc-fix-fail-with-too-high-slot-count_cleanupver.patch @@ -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 + diff --git a/SOURCES/mtx-1.3.12-fix-resource-leak.patch b/SOURCES/mtx-1.3.12-fix-resource-leak.patch new file mode 100644 index 0000000..9304f64 --- /dev/null +++ b/SOURCES/mtx-1.3.12-fix-resource-leak.patch @@ -0,0 +1,11 @@ +--- a/mtxl.c 2016-03-16 18:53:48.947779146 +0100 ++++ b/mtxl.c 2016-03-16 18:55:15.592873800 +0100 +@@ -1283,7 +1283,7 @@ + #endif + ParseElementStatus( EmptyStorageElementAddress, &EmptyStorageElementCount, + DataBuffer, ElementStatus, mode_sense, NULL); +- ++ free(DataBuffer); + ElementStatus->StorageElementCount += ElementStatus->ImportExportCount; + } + diff --git a/SOURCES/mtx-1.3.12-man-Document-mtx-eject-and-previous-operations.patch b/SOURCES/mtx-1.3.12-man-Document-mtx-eject-and-previous-operations.patch new file mode 100644 index 0000000..2d992f9 --- /dev/null +++ b/SOURCES/mtx-1.3.12-man-Document-mtx-eject-and-previous-operations.patch @@ -0,0 +1,44 @@ +From 26bf6f6794a8a35f69dc2a8a01e69bf50200800f Mon Sep 17 00:00:00 2001 +From: David Sommerseth +Date: Fri, 6 May 2016 21:00:58 +0200 +Subject: [PATCH] man: Document mtx eject and previous operations + +--- + mtx.1 | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/mtx.1 b/mtx.1 +index a5e6cc6..108836e 100644 +--- a/mtx.1 ++++ b/mtx.1 +@@ -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 + tape libraries -- e.g. on Exabyte 220, the first slot is usually a + cleaning tape. If is omitted, defaults to first drive. +- + .TP 10 + .B last [] + Loads drive 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 tape using your OS's tape control commands first). + .TP 10 ++.B previous [] ++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 [] + Unloads the drive and loads the next tape in sequence. If the drive was + empty, loads the first tape into the drive. +@@ -145,6 +148,9 @@ empty, loads the first tape into the drive. + .B position + Positions the robot at a specific slot. Needed by some changers to + move to and open the import/export, or mailbox, slot. ++.TP 10 ++.B eject ++Eject the tape currently in the drive. + + .SH AUTHORS + The original 'mtx' program was written by Leonard Zubkoff and extensively +-- +1.8.3.1 + diff --git a/SOURCES/mtx-1.3.12-scsitape-usage--add-erase.patch b/SOURCES/mtx-1.3.12-scsitape-usage--add-erase.patch new file mode 100644 index 0000000..0015eeb --- /dev/null +++ b/SOURCES/mtx-1.3.12-scsitape-usage--add-erase.patch @@ -0,0 +1,13 @@ +diff --git a/scsitape.c b/scsitape.c +index dd52dd5..63f4977 100644 +--- a/scsitape.c ++++ b/scsitape.c +@@ -63,7 +63,7 @@ + #endif + + void Usage(void) { +- FatalError("Usage: scsitape -f where is:\n setblk | fsf | bsf | eod | rewind | eject | mark |\n seek | read [ [] \n"); ++ FatalError("Usage: scsitape -f where is:\n setblk | fsf | bsf | eod | rewind | eject | erase |\n mark | seek | read [ []\n"); + } + + #define arg1 (arg[0]) /* for backward compatibility, sigh */ diff --git a/SPECS/mtx.spec b/SPECS/mtx.spec index 8fdaf5d..e2bf30d 100644 --- a/SPECS/mtx.spec +++ b/SPECS/mtx.spec @@ -1,6 +1,6 @@ Name: mtx Version: 1.3.12 -Release: 11%{?dist} +Release: 14%{?dist} Summary: SCSI media changer control program License: GPLv2 Group: Applications/System @@ -10,6 +10,10 @@ Patch0: %{name}-1.3.12-destdir.patch # http://mtx.opensource-sw.net/bugs/view.php?id=13 # https://bugzilla.redhat.com/show_bug.cgi?id=538403 Patch1: %{name}-1.3.12-argc.patch +Patch2: emc-fix-fail-with-too-high-slot-count_cleanupver.patch +Patch3: mtx-1.3.12-fix-resource-leak.patch +Patch4: mtx-1.3.12-scsitape-usage--add-erase.patch +Patch5: mtx-1.3.12-man-Document-mtx-eject-and-previous-operations.patch URL: http://mtx.sourceforge.net/ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -30,6 +34,10 @@ tape at a time, you should install MTX. %patch0 -p2 -b .destdir %patch1 -p2 -b .argc +%patch2 -p1 -b .emc_slot_count +%patch3 -p1 -b .fixresourceleak +%patch4 -p1 -b .scsitape_adderase +%patch5 -p1 -b .mtxman1upd # remove exec permission chmod a-x contrib/config_sgen_solaris.sh contrib/mtx-changer @@ -59,6 +67,15 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Mar 16 2016 David Sommerseth - 1.3.12-14 +- Update scsitape --help screen to show the erase command and improved mtx.1 man page (#948459) + +* Wed Mar 16 2016 David Sommerseth - 1.3.12-13 +- Fix resource leak during processing of import/export information + +* Fri Mar 11 2016 David Sommerseth - 1.3.12-12 +- Fix fail with too high slot count (#1298647) + * Fri Jan 24 2014 Daniel Mach - 1.3.12-11 - Mass rebuild 2014-01-24