Commit 9dfbe96d authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

Ported commits from castor/master:

83ab8201100d1bcdd5c6d056fd5a395c24bcb885
  Get detailed Firmware Version
    - Differentiate SCSI Inquiry for Oracle to get firmware version
      minor version
    - Change getDriveFirmwareVersion() to get firmware version from SCSI
      backend

6481bcabc4907c8a1813253fe9a2d40cd67d07fe
  Provide DriveGeneric inquiry implementation for DriveMHVTL

2033932f133b9eb7469190972a4f228dd8b16396
  Move Oracle inquiry structure handling inside
  DriveT10000::getDeviceInfo()

a8be8c16a4e3af2f952676f1138213d7e5584705
  Merge branch 'tape-firmware' into 'master'
    Get detailed Firmware Version
    ## Description
      - Differentiate SCSI Inquiry for Oracle to get firmware version
        minor version
      - Change getDriveFirmwareVersion() to get firmware version from SCSI
        backend
    ## Change in logs
      Old version:
        firmwareVersion="468E" # IBM
        firmwareVersion="4.11" # Oracle
      New version:
        firmwareVersion="468E" # IBM
        firmwareVersion="4.11.111" # Oracle
parent 8a84cc86
......@@ -124,6 +124,63 @@ drive::deviceInfo drive::DriveGeneric::getDeviceInfo() {
return devInfo;
}
drive::deviceInfo drive::DriveT10000::getDeviceInfo() {
SCSI::Structures::inquiryCDB_t cdb;
SCSI::Structures::inquiryData_t inquiryData;
SCSI::Structures::senseData_t<255> senseBuff;
SCSI::Structures::LinuxSGIO_t sgh;
deviceInfo devInfo;
SCSI::Structures::setU16(cdb.allocationLength, sizeof(inquiryData));
sgh.setCDB(&cdb);
sgh.setDataBuffer(&inquiryData);
sgh.setSenseBuffer(&senseBuff);
sgh.dxfer_direction = SG_DXFER_FROM_DEV;
/* Manage both system error and SCSI errors. */
cta::exception::Errnum::throwOnMinusOne(
m_sysWrapper.ioctl(m_tapeFD, SG_IO, &sgh),
"Failed SG_IO ioctl in DriveT10000::getDeviceInfo");
SCSI::ExceptionLauncher(sgh, "SCSI error in getDeviceInfo:");
devInfo.product = SCSI::Structures::toString(inquiryData.prodId);
std::string productRevisionMinor = SCSI::Structures::toString(inquiryData.vendorSpecific1).substr(0,4);
devInfo.productRevisionLevel = SCSI::Structures::toString(inquiryData.prodRevLvl) + productRevisionMinor;
devInfo.vendor = SCSI::Structures::toString(inquiryData.T10Vendor);
devInfo.serialNumber = getSerialNumber();
devInfo.isPIsupported = inquiryData.protect;
return devInfo;
}
drive::deviceInfo drive::DriveMHVTL::getDeviceInfo() {
SCSI::Structures::inquiryCDB_t cdb;
SCSI::Structures::inquiryData_t inquiryData;
SCSI::Structures::senseData_t<255> senseBuff;
SCSI::Structures::LinuxSGIO_t sgh;
deviceInfo devInfo;
SCSI::Structures::setU16(cdb.allocationLength, sizeof(inquiryData));
sgh.setCDB(&cdb);
sgh.setDataBuffer(&inquiryData);
sgh.setSenseBuffer(&senseBuff);
sgh.dxfer_direction = SG_DXFER_FROM_DEV;
/* Manage both system error and SCSI errors. */
cta::exception::Errnum::throwOnMinusOne(
m_sysWrapper.ioctl(m_tapeFD, SG_IO, &sgh),
"Failed SG_IO ioctl in DriveMHVTL::getDeviceInfo");
SCSI::ExceptionLauncher(sgh, "SCSI error in getDeviceInfo:");
devInfo.product = SCSI::Structures::toString(inquiryData.prodId);
devInfo.productRevisionLevel = SCSI::Structures::toString(inquiryData.prodRevLvl);
devInfo.vendor = SCSI::Structures::toString(inquiryData.T10Vendor);
devInfo.serialNumber = getSerialNumber();
devInfo.isPIsupported = inquiryData.protect;
return devInfo;
}
/**
* Information about the serial number of the drive.
* @return Right-aligned ASCII data for the vendor-assigned serial number.
......@@ -2041,33 +2098,7 @@ std::map<std::string,uint32_t> drive::DriveT10000::getDriveStats() {
}
std::string drive::DriveGeneric::getDriveFirmwareVersion() {
std::ifstream scsiProcFile;
try {
scsiProcFile.open("/proc/scsi/scsi", std::ios::in);
int currentLineNo = 0;
std::string line;
bool found = false;
while (getline(scsiProcFile, line)) {
if (std::string::npos != line.find("Type: Sequential-Access", 0)) {
found = true;
break;
}
++currentLineNo;
}
if (found) {
scsiProcFile.seekg(0, std::ios::beg);
for (int i = 0; i < currentLineNo - 2; ++i) {
// skipping lines
scsiProcFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
}
getline(scsiProcFile, line);
scsiProcFile.close();
return line.substr(line.find("Rev:") + 5);
}
catch(std::ios_base::failure) {
return std::string("");
}
return this->getDeviceInfo().productRevisionLevel;
}
/*
......
......@@ -442,6 +442,7 @@ namespace drive {
virtual std::map<std::string,uint32_t> getVolumeStats();
virtual std::map<std::string,float> getQualityStats();
virtual std::map<std::string,uint32_t> getDriveStats();
virtual drive::deviceInfo getDeviceInfo();
};
/**
......@@ -466,6 +467,7 @@ namespace drive {
virtual std::map<std::string,float> getQualityStats();
virtual std::map<std::string,uint32_t> getDriveStats();
virtual std::map<std::string,uint32_t> getVolumeStats();
virtual drive::deviceInfo getDeviceInfo();
};
class DriveLTO : public DriveGeneric {
......
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