Commit 19142144 authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

added exception for an overflow in getPositionInfo

(CASTOR way was just to fill everything with 0)
parent b6ec11f7
......@@ -166,7 +166,7 @@ namespace Tape {
*/
virtual void positionToLogicalObject (uint32_t blockId) throw (Exception) {
SCSI::Structures::locate10CDB_t cdb;
uint32_t blkId = ntohl(blockId);
uint32_t blkId = SCSI::Structures::fromLtoB32(blockId);
memcpy (cdb.logicalObjectID, &blkId, sizeof(cdb.logicalObjectID));
......@@ -220,10 +220,13 @@ namespace Tape {
posInfo.dirtyObjectsCount = SCSI::Structures::toU32(positionData.blocksInBuffer);
posInfo.dirtyBytesCount = SCSI::Structures::toU32(positionData.bytesInBuffer);
} else {
posInfo.currentPosition = 0;
posInfo.oldestDirtyObject = 0;
posInfo.dirtyObjectsCount = 0;
posInfo.dirtyBytesCount = 0;
/* An overflow has occurred in at least one of the returned position
* data fields. The application should use the LONG FORM to obtain the
* current position or the application should use the EXTENDED FORM to
* obtain the current position and number of bytes in the object buffer.
* (note) For T10000 we have only SHORT FORM.
*/
throw Tape::Exception(std::string("An overflow has occurred in getPostitionInfo"));
}
return posInfo;
}
......
......@@ -133,6 +133,17 @@ namespace SCSI {
return (int32_t)(ntohl (*((uint32_t *) t)));
}
/**
* Helper function to convert from little-endian to big-endian.
* @param t a 32 bit number in the little-endian form
* @return a 32 bit number in the big-endian form
*/
inline uint32_t fromLtoB32(uint32_t t)
{
/* Like network, SCSI is BigEndian */
return htonl(t);
}
/**
* Helper function to deal with endianness.
* @param t byte array in SCSI order representing a 16 bits number
......
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