Package 

Interface BlockDeviceDriver

  • All Implemented Interfaces:

    
    public interface BlockDeviceDriver
    
                        

    This interface describes a simple block device with a certain block size and the ability to read and write at a certain device offset.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Unit init() Initializes the block device for further use.
      abstract Unit read(Long deviceOffset, ByteBuffer buffer) Reads from the block device at a certain offset into the given buffer.
      abstract Unit write(Long deviceOffset, ByteBuffer buffer) Writes to the block device at a certain offset from the given buffer.
      abstract Integer getBlockSize() Returns the block size of the block device.
      abstract Long getBlocks() The size of the block device, in blocks of blockSize bytes,
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • init

         abstract Unit init()

        Initializes the block device for further use. This method should be called before doing anything else on the block device.

      • read

         abstract Unit read(Long deviceOffset, ByteBuffer buffer)

        Reads from the block device at a certain offset into the given buffer. The amount of bytes to be read are determined by java.nio.ByteBuffer.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.
      • write

         abstract Unit write(Long deviceOffset, ByteBuffer buffer)

        Writes to the block device at a certain offset from the given buffer. The amount of bytes to be written are determined by java.nio.ByteBuffer.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.
      • getBlockSize

         abstract Integer 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 whole blocks!

      • getBlocks

         abstract Long getBlocks()

        The size of the block device, in blocks of blockSize bytes,