Package com.github.mjdev.libaums.driver
Interface BlockDeviceDriver
-
- All Known Implementing Classes:
ByteBlockDevice,FileBlockDeviceDriver,Partition,ScsiBlockDevice
public interface BlockDeviceDriverThis interface describes a simple block device with a certain block size and the ability to read and write at a certain device offset.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetBlockSize()Returns the block size of the block device.voidinit()Initializes the block device for further use.voidread(long deviceOffset, java.nio.ByteBuffer buffer)Reads from the block device at a certain offset into the given buffer.voidwrite(long deviceOffset, java.nio.ByteBuffer buffer)Writes to the block device at a certain offset from the given buffer.
-
-
-
Method Detail
-
init
void init() throws java.io.IOException
Initializes the block device for further use. This method should be called before doing anything else on the block device.- Throws:
java.io.IOException- If initializing fails
-
read
void read(long deviceOffset, java.nio.ByteBuffer buffer) throws java.io.IOExceptionReads from the block device at a certain offset into the given buffer. The amount of bytes to be read are determined byBuffer.remaining().The deviceOffset can either be the amount of bytes or a logical block addressing using the block size. To get the bytes in the last case you have to multiply the lba with the block size (offset *
getBlockSize()).- Parameters:
deviceOffset- The offset where the reading should begin.buffer- The buffer where the data should be read into.- Throws:
java.io.IOException- If reading fails.
-
write
void write(long deviceOffset, java.nio.ByteBuffer buffer) throws java.io.IOExceptionWrites to the block device at a certain offset from the given buffer. The amount of bytes to be written are determined byBuffer.remaining().The deviceOffset can either be the amount of bytes or a logical block addressing using the block size. To get the bytes in the last case you have to multiply the lba with the block size (offset *
getBlockSize()).- Parameters:
deviceOffset- The offset where the writing should begin.buffer- The buffer with the data to be transferred.- Throws:
java.io.IOException- If writing fails.
-
getBlockSize
int getBlockSize()
Returns 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!
- Returns:
- The block size in bytes, mostly 512 bytes.
-
-