Class ScsiBlockDevice
- java.lang.Object
-
- com.github.mjdev.libaums.driver.scsi.ScsiBlockDevice
-
- All Implemented Interfaces:
BlockDeviceDriver
public class ScsiBlockDevice extends java.lang.Object implements BlockDeviceDriver
This class is responsible for handling mass storage devices which follow the SCSI standard. This class communicates with the mass storage device via the different SCSI commands.
-
-
Constructor Summary
Constructors Constructor Description ScsiBlockDevice(UsbCommunication usbCommunication)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetBlockSize()Returns the block size of the block device.voidinit()Issues a SCSI Inquiry to determine the connected device.voidread(long devOffset, java.nio.ByteBuffer dest)This method reads from the device at the specific device offset.voidwrite(long devOffset, java.nio.ByteBuffer src)This method writes from the device at the specific device offset.
-
-
-
Constructor Detail
-
ScsiBlockDevice
public ScsiBlockDevice(UsbCommunication usbCommunication)
-
-
Method Detail
-
init
public void init() throws java.io.IOExceptionIssues a SCSI Inquiry to determine the connected device. After that it is checked if the unit is ready. Logs a warning if the unit is not ready. Finally the capacity of the mass storage device is read.- Specified by:
initin interfaceBlockDeviceDriver- Throws:
java.io.IOException- If initialing fails due to an unsupported device or if reading fails.- See Also:
ScsiInquiry,ScsiInquiryResponse,ScsiTestUnitReady,ScsiReadCapacity,ScsiReadCapacityResponse
-
read
public void read(long devOffset, java.nio.ByteBuffer dest) throws java.io.IOExceptionThis method reads from the device at the specific device offset. The devOffset specifies at which block the reading should begin. That means the devOffset is not in bytes!- Specified by:
readin interfaceBlockDeviceDriver- Parameters:
devOffset- The offset where the reading should begin.dest- The buffer where the data should be read into.- Throws:
java.io.IOException- If reading fails.
-
write
public void write(long devOffset, java.nio.ByteBuffer src) throws java.io.IOExceptionThis method writes from the device at the specific device offset. The devOffset specifies at which block the writing should begin. That means the devOffset is not in bytes!- Specified by:
writein interfaceBlockDeviceDriver- Parameters:
devOffset- The offset where the writing should begin.src- The buffer with the data to be transferred.- Throws:
java.io.IOException- If writing fails.
-
getBlockSize
public int getBlockSize()
Description copied from interface:BlockDeviceDriverReturns the block size of the block device. Every block device can only read and store bytes in a specific block with a certain size.That means that it is only possible to read or write hole blocks!
- Specified by:
getBlockSizein interfaceBlockDeviceDriver- Returns:
- The block size in bytes, mostly 512 bytes.
-
-