public interface IStorageModule
All index and length parameters used by the read and write methods are referring to bytes, unlike the
values sent in CommandDescriptorBlock s.
| Modifier and Type | Interface and Description |
|---|---|
static class |
IStorageModule.STORAGEKIND
Enum to denote the modules.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
VIRTUAL_BLOCK_SIZE
A fictitious block size.
|
| Modifier and Type | Method and Description |
|---|---|
int |
checkBounds(long logicalBlockAddress,
int transferLengthInBlocks)
This method can be used for checking if a (series of) I/O operations will
result in an
IOException due to trying to access blocks outside
the medium's boundaries. |
void |
close()
Closing the storage.
|
long |
getSizeInBlocks()
Returns the storage space size in bytes divided by
the block size in bytes (rounded down).
|
void |
read(byte[] bytes,
int bytesOffset,
int length,
long storageIndex)
Copies bytes from storage to the passed byte array.
|
void |
write(byte[] bytes,
int bytesOffset,
int length,
long storageIndex)
Saves part of the passed byte array's content.
|
static final int VIRTUAL_BLOCK_SIZE
int checkBounds(long logicalBlockAddress,
int transferLengthInBlocks)
IOException due to trying to access blocks outside
the medium's boundaries.
The SCSI standard requires checking for these boundary violations right after receiving a read or write command, so that an appropriate error message can be returned to the initiator. Therefore this method must be called prior to each read or write sequence.
The values returned by this method and their meaning with regard to the interval [0,
getSizeInBlocks() - 1] are shown in the following table:
| Return Value | Meaning |
|---|---|
| 0 | no boundaries are violated |
| 1 | the logicalBlockAddress parameter lies outside of the interval |
| 2 | the interval [logicalBlockAddress, logicalBlockAddress +
transferLengthInBlocks] lies outside of the interval, or transferLengthInBlocks is negative |
Note that the parameters of this method are referring to blocks, not to byte indices.
logicalBlockAddress - the index of the first block of data to be read or writtentransferLengthInBlocks - the total number of consecutive blocks about to be read or
writtenlong getSizeInBlocks()
void read(byte[] bytes,
int bytesOffset,
int length,
long storageIndex)
throws IOException
bytes - the array into which the data will be copiedbytesOffset - the position of the first byte in bytes, which
will be filled with data from storagelength - the number of bytes to copystorageIndex - the position of the first byte to be copiedIOExceptionvoid write(byte[] bytes,
int bytesOffset,
int length,
long storageIndex)
throws IOException
bytes - the source of the data to be storedbytesOffset - offset of the first byte to be storedlength - the number of bytes to be copiedstorageIndex - byte offset in the storage areaIOExceptionvoid close()
throws IOException
IOException - to be closedCopyright © 2012 University of Konstanz, Distributed Systems Group. All Rights Reserved.