Commit 3b0fe762 authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

task #TPSRV-9: Remove Tape::System::tapeGenericDeviceFile

removed tapeGenericDeviceFile
parent 80addb0b
......@@ -23,7 +23,7 @@
#include "Drive.hh"
Tape::Drive::Drive(SCSI::DeviceInfo di, System::virtualWrapper& sw) : m_SCSIInfo(di),
m_tapeFD(-1), m_genericFD(-1), m_sysWrapper(sw) {
m_tapeFD(-1), m_sysWrapper(sw) {
/* Open the device files */
/* We open the tape device file non-blocking as blocking open on rewind tapes (at least)
* will fail after a long timeout when no tape is present (at least with mhvtl)
......@@ -31,13 +31,9 @@ m_tapeFD(-1), m_genericFD(-1), m_sysWrapper(sw) {
m_tapeFD = m_sysWrapper.open(m_SCSIInfo.nst_dev.c_str(), O_RDWR | O_NONBLOCK);
if (-1 == m_tapeFD)
throw Tape::Exceptions::Errnum(std::string("Could not open device file: " + m_SCSIInfo.nst_dev));
m_genericFD = m_sysWrapper.open(m_SCSIInfo.sg_dev.c_str(), O_RDWR);
if (-1 == m_genericFD)
throw Tape::Exceptions::Errnum(std::string("Could not open device file: " + m_SCSIInfo.sg_dev));
/* Read drive status */
if (-1 == m_sysWrapper.ioctl(m_tapeFD, MTIOCGET, &m_mtInfo))
throw Tape::Exceptions::Errnum(std::string("Could not read drive status: " + m_SCSIInfo.nst_dev));
/* Read Generic SCSI information (INQUIRY) */
}
/**
......@@ -491,8 +487,6 @@ void Tape::Drive::readBlock(unsigned char * data, size_t count) throw (Tape::Exc
}
void Tape::Drive::SCSI_inquiry() {
std::cout << "Doing a SCSI inquiry via generic device:" << std::endl;
SCSI_inquiry(m_genericFD);
std::cout << "Re-doing a SCSI inquiry via st device:" << std::endl;
SCSI_inquiry(m_tapeFD);
}
......
......@@ -310,16 +310,13 @@ namespace Tape {
virtual ~Drive() {
if (-1 != m_tapeFD)
m_sysWrapper.close(m_tapeFD);
if (-1 != m_genericFD)
m_sysWrapper.close(m_genericFD);
m_sysWrapper.close(m_tapeFD);
}
void SCSI_inquiry();
protected:
SCSI::DeviceInfo m_SCSIInfo;
int m_tapeFD;
int m_genericFD;
int m_tapeFD;
Tape::System::virtualWrapper & m_sysWrapper;
struct mtget m_mtInfo;
private:
......
......@@ -44,11 +44,11 @@ TEST(TapeDrive, OpensCorrectly) {
EXPECT_CALL(sysWrapper, readdir(_)).Times(AtLeast(30));
EXPECT_CALL(sysWrapper, closedir(_)).Times(AtLeast(3));
EXPECT_CALL(sysWrapper, realpath(_, _)).Times(3);
EXPECT_CALL(sysWrapper, open(_, _)).Times(14);
EXPECT_CALL(sysWrapper, open(_, _)).Times(12);
EXPECT_CALL(sysWrapper, read(_, _, _)).Times(20);
EXPECT_CALL(sysWrapper, write(_, _, _)).Times(0);
EXPECT_CALL(sysWrapper, ioctl(_,_,An<mtget*>())).Times(2);
EXPECT_CALL(sysWrapper, close(_)).Times(14);
EXPECT_CALL(sysWrapper, close(_)).Times(12);
EXPECT_CALL(sysWrapper, readlink(_, _, _)).Times(3);
EXPECT_CALL(sysWrapper, stat(_,_)).Times(7);
......@@ -73,11 +73,11 @@ TEST(TapeDrive, getPositionInfoAndPositionToLogicalObject) {
EXPECT_CALL(sysWrapper, readdir(_)).Times(AtLeast(30));
EXPECT_CALL(sysWrapper, closedir(_)).Times(AtLeast(3));
EXPECT_CALL(sysWrapper, realpath(_, _)).Times(3);
EXPECT_CALL(sysWrapper, open(_, _)).Times(14);
EXPECT_CALL(sysWrapper, open(_, _)).Times(12);
EXPECT_CALL(sysWrapper, read(_, _, _)).Times(20);
EXPECT_CALL(sysWrapper, write(_, _, _)).Times(0);
EXPECT_CALL(sysWrapper, ioctl(_,_,An<mtget*>())).Times(2);
EXPECT_CALL(sysWrapper, close(_)).Times(14);
EXPECT_CALL(sysWrapper, close(_)).Times(12);
EXPECT_CALL(sysWrapper, readlink(_, _, _)).Times(3);
EXPECT_CALL(sysWrapper, stat(_,_)).Times(7);
......@@ -121,11 +121,11 @@ TEST(TapeDrive, setDensityAndCompression) {
EXPECT_CALL(sysWrapper, readdir(_)).Times(AtLeast(30));
EXPECT_CALL(sysWrapper, closedir(_)).Times(AtLeast(3));
EXPECT_CALL(sysWrapper, realpath(_, _)).Times(3);
EXPECT_CALL(sysWrapper, open(_, _)).Times(14);
EXPECT_CALL(sysWrapper, open(_, _)).Times(12);
EXPECT_CALL(sysWrapper, read(_, _, _)).Times(20);
EXPECT_CALL(sysWrapper, write(_, _, _)).Times(0);
EXPECT_CALL(sysWrapper, ioctl(_,_,An<mtget*>())).Times(2);
EXPECT_CALL(sysWrapper, close(_)).Times(14);
EXPECT_CALL(sysWrapper, close(_)).Times(12);
EXPECT_CALL(sysWrapper, readlink(_, _, _)).Times(3);
EXPECT_CALL(sysWrapper, stat(_,_)).Times(7);
......@@ -165,11 +165,11 @@ TEST(TapeDrive, setStDriverOptions) {
EXPECT_CALL(sysWrapper, readdir(_)).Times(AtLeast(30));
EXPECT_CALL(sysWrapper, closedir(_)).Times(AtLeast(3));
EXPECT_CALL(sysWrapper, realpath(_, _)).Times(3);
EXPECT_CALL(sysWrapper, open(_, _)).Times(14);
EXPECT_CALL(sysWrapper, open(_, _)).Times(12);
EXPECT_CALL(sysWrapper, read(_, _, _)).Times(20);
EXPECT_CALL(sysWrapper, write(_, _, _)).Times(0);
EXPECT_CALL(sysWrapper, ioctl(_,_,An<mtget*>())).Times(2);
EXPECT_CALL(sysWrapper, close(_)).Times(14);
EXPECT_CALL(sysWrapper, close(_)).Times(12);
EXPECT_CALL(sysWrapper, readlink(_, _, _)).Times(3);
EXPECT_CALL(sysWrapper, stat(_,_)).Times(7);
......@@ -199,11 +199,11 @@ TEST(TapeDrive, getDeviceInfo) {
EXPECT_CALL(sysWrapper, readdir(_)).Times(AtLeast(30));
EXPECT_CALL(sysWrapper, closedir(_)).Times(AtLeast(3));
EXPECT_CALL(sysWrapper, realpath(_, _)).Times(3);
EXPECT_CALL(sysWrapper, open(_, _)).Times(14);
EXPECT_CALL(sysWrapper, open(_, _)).Times(12);
EXPECT_CALL(sysWrapper, read(_, _, _)).Times(20);
EXPECT_CALL(sysWrapper, write(_, _, _)).Times(0);
EXPECT_CALL(sysWrapper, ioctl(_,_,An<mtget*>())).Times(2);
EXPECT_CALL(sysWrapper, close(_)).Times(14);
EXPECT_CALL(sysWrapper, close(_)).Times(12);
EXPECT_CALL(sysWrapper, readlink(_, _, _)).Times(3);
EXPECT_CALL(sysWrapper, stat(_,_)).Times(7);
......@@ -237,11 +237,11 @@ TEST(TapeDrive, getCompressionAndClearCompressionStats) {
EXPECT_CALL(sysWrapper, readdir(_)).Times(AtLeast(30));
EXPECT_CALL(sysWrapper, closedir(_)).Times(AtLeast(3));
EXPECT_CALL(sysWrapper, realpath(_, _)).Times(3);
EXPECT_CALL(sysWrapper, open(_, _)).Times(22);
EXPECT_CALL(sysWrapper, open(_, _)).Times(16);
EXPECT_CALL(sysWrapper, read(_, _, _)).Times(20);
EXPECT_CALL(sysWrapper, write(_, _, _)).Times(0);
EXPECT_CALL(sysWrapper, ioctl(_,_,An<mtget*>())).Times(6);
EXPECT_CALL(sysWrapper, close(_)).Times(22);
EXPECT_CALL(sysWrapper, close(_)).Times(16);
EXPECT_CALL(sysWrapper, readlink(_, _, _)).Times(3);
EXPECT_CALL(sysWrapper, stat(_,_)).Times(7);
......@@ -336,11 +336,11 @@ TEST(TapeDrive, getTapeAlerts) {
EXPECT_CALL(sysWrapper, readdir(_)).Times(AtLeast(30));
EXPECT_CALL(sysWrapper, closedir(_)).Times(AtLeast(3));
EXPECT_CALL(sysWrapper, realpath(_, _)).Times(AtLeast(3));
EXPECT_CALL(sysWrapper, open(_, _)).Times(AtLeast(14));
EXPECT_CALL(sysWrapper, open(_, _)).Times(AtLeast(12));
EXPECT_CALL(sysWrapper, read(_, _, _)).Times(AtLeast(20));
EXPECT_CALL(sysWrapper, write(_, _, _)).Times(0);
EXPECT_CALL(sysWrapper, ioctl(_, _, An<mtget*>())).Times(2);
EXPECT_CALL(sysWrapper, close(_)).Times(AtLeast(14));
EXPECT_CALL(sysWrapper, close(_)).Times(AtLeast(12));
EXPECT_CALL(sysWrapper, readlink(_, _, _)).Times(AtLeast(3));
EXPECT_CALL(sysWrapper, stat(_, _)).Times(AtLeast(7));
......
......@@ -512,20 +512,3 @@ int Tape::System::stDeviceFile::ioctlInquiry(sg_io_hdr_t * sgio_h) {
}
return 0;
}
int Tape::System::tapeGenericDeviceFile::ioctl(unsigned long int request, sg_io_hdr_t * sgio_h)
{
/* for the moment, just implement the SG_IO ioctl */
switch (request) {
case SG_IO:
if (sgio_h->interface_id != 'S') {
errno = ENOSYS;
return -1;
}
/* TODO */
return 0;
}
errno = EINVAL;
return -1;
}
......@@ -198,12 +198,5 @@ namespace System {
*/
int logSenseTapeAlerts(sg_io_hdr_t * sgio_h);
};
class tapeGenericDeviceFile: public vfsFile {
public:
tapeGenericDeviceFile() {};
virtual void reset() {};
virtual int ioctl(unsigned long int request, sg_io_hdr_t * sgio_h);
};
} // namespace System
} // namespace Tape
......@@ -193,10 +193,7 @@ void Tape::System::fakeWrapper::referenceFiles() {
m_files[i->first] = &m_regularFiles[i->first];
for (std::map<std::string, stDeviceFile>::iterator i = m_stFiles.begin();
i != m_stFiles.end(); i++)
m_files[i->first] = &m_stFiles[i->first];
for (std::map<std::string, tapeGenericDeviceFile>::iterator i = m_genericFiles.begin();
i != m_genericFiles.end(); i++)
m_files[i->first] = &m_genericFiles[i->first];
m_files[i->first] = &m_stFiles[i->first];
}
Tape::System::mockWrapper::mockWrapper() {
......@@ -354,9 +351,6 @@ void Tape::System::fakeWrapper::setupSLC5() {
m_stats["/dev/nst1"].st_mode = S_IFCHR;
m_stFiles["/dev/nst0"];
m_stFiles["/dev/nst1"];
m_genericFiles["/dev/sg0"];
m_genericFiles["/dev/sg1"];
m_genericFiles["/dev/sg2"];
referenceFiles();
}
......@@ -557,10 +551,6 @@ void Tape::System::fakeWrapper::setupSLC6() {
m_stFiles["/dev/nst0"];
m_stFiles["/dev/nst1"];
m_genericFiles["/dev/sg0"];
m_genericFiles["/dev/sg1"];
m_genericFiles["/dev/sg2"];
m_genericFiles["/dev/sg3"];
referenceFiles();
}
......@@ -124,8 +124,7 @@ namespace System {
std::map<std::string, vfsFile *> m_files;
std::map<std::string, struct stat> m_stats;
std::map<std::string, regularFile> m_regularFiles;
std::map<std::string, stDeviceFile> m_stFiles;
std::map<std::string, tapeGenericDeviceFile> m_genericFiles;
std::map<std::string, stDeviceFile> m_stFiles;
void setupSLC5();
void setupSLC6();
void referenceFiles();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment