public class Partition extends java.lang.Object implements BlockDeviceDriver
getFileSystem().
This file system is needed to to access the files and directories of a
partition.
The method getVolumeLabel() returns the volume label for the
partition. Calling the method is equivalent to calling
FileSystem.getVolumeLabel().
| Modifier and Type | Method and Description |
|---|---|
static Partition |
createPartition(PartitionTableEntry entry,
BlockDeviceDriver blockDevice)
Creates a new partition with the information given.
|
int |
getBlockSize()
Returns the block size of the block device.
|
FileSystem |
getFileSystem() |
java.lang.String |
getVolumeLabel()
This method returns the volume label of the file system / partition.
|
void |
init()
Initializes the block device for further use.
|
void |
read(long offset,
java.nio.ByteBuffer dest)
Reads from the block device at a certain offset into the given buffer.
|
void |
write(long offset,
java.nio.ByteBuffer src)
Writes to the block device at a certain offset from the given buffer.
|
public static Partition createPartition(PartitionTableEntry entry, BlockDeviceDriver blockDevice) throws java.io.IOException
entry - The entry the partition shall represent.blockDevice - The underlying block device.java.io.IOException - If reading from the device fails.public FileSystem getFileSystem()
public java.lang.String getVolumeLabel()
FileSystem.getVolumeLabel().public void init()
BlockDeviceDriverinit in interface BlockDeviceDriverpublic void read(long offset,
java.nio.ByteBuffer dest)
throws java.io.IOException
BlockDeviceDriverBuffer.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 *
BlockDeviceDriver.getBlockSize()).
read in interface BlockDeviceDriveroffset - The offset where the reading should begin.dest - The buffer where the data should be read into.java.io.IOException - If reading fails.public void write(long offset,
java.nio.ByteBuffer src)
throws java.io.IOException
BlockDeviceDriverBuffer.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 *
BlockDeviceDriver.getBlockSize()).
write in interface BlockDeviceDriveroffset - The offset where the writing should begin.src - The buffer with the data to be transferred.java.io.IOException - If writing fails.public int getBlockSize()
BlockDeviceDriverThat means that it is only possible to read or write hole blocks!
getBlockSize in interface BlockDeviceDriver