diff --git a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp index f1411e54d6e6e35798ef2973d87d81fadaccd288..5473d9d679f76360ab17c5f2df9ec8441bf2c9df 100644 --- a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp +++ b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp @@ -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; } /* diff --git a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp index 10b99e788ad9b4d25b34e8897b78bce287f97d30..005589621903d4fab770d25db47e17e7229ccd81 100644 --- a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp +++ b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp @@ -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 {