|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.blinkenbyte.io.BlockDeviceFilter org.blinkenbyte.io.BadBlockEmulator
public class BadBlockEmulator
A BadBlockEmulator is a device filter that can filter out read/write requests to particular sectors, throwing a BadBlockException instead. The thrown exception details the filtered block that prevented the I/O from completing successfully.
Nested Class Summary | |
---|---|
static class |
BadBlockEmulator.BadBlockException
An exception class that is thrown when bad blocks are requested to be read or written by BadBlockEmulator. |
Nested classes/interfaces inherited from interface org.blinkenbyte.io.BlockDevice |
---|
BlockDevice.DriveGeometry |
Field Summary |
---|
Fields inherited from class org.blinkenbyte.io.BlockDeviceFilter |
---|
bd |
Constructor Summary | |
---|---|
BadBlockEmulator(BlockDevice _bd)
Constructs a new BadBlockEmulator wrapped around an existing BlockDevice. |
Method Summary | |
---|---|
void |
addBlock(long blockNumber,
long blockLength)
Adds a new range of blocks to this object. |
void |
clearList()
Clears the list of blocks. |
boolean |
getAllowPartials()
Returns whether reads and writes that overlap bad blocks but start with good blocks should be allowed. |
BlockRange |
getBlockRange(int index)
Returns the BlockRange at index index within this object. |
java.util.Iterator<BlockRange> |
iterator()
Returns an iterator for the blocks. |
void |
loadList(java.util.ArrayList<BlockRange> listToAdd)
Appends a list of blocks to the current list. |
void |
loadList(java.io.Reader r)
Loads a list of block ranges from a Reader, appending them to the existing list. |
int |
numBlocks()
Returns the number of BlockRange objects contained in this object. |
int |
read()
Reads a byte from the underlying block device, throwing an exception if the byte is in a bad block range. |
int |
read(byte[] b,
int offset,
int len)
Reads up to len bytes from the underlying block device into a byte array, starting at b[offset]. |
boolean |
removeBlock(long blockNumber,
long blockLength)
Removes a range of blocks from this object. |
void |
setAllowPartials(boolean _allowPartials)
Sets whether partial reads and writes are allowed. |
void |
write(byte[] b,
int offset,
int len)
Writes len bytes to the underlying block device from a byte array, starting at b[offset]. |
void |
write(int b)
Writes a byte to the underlying block device, throwing an exception if the byte is in a bad block range. |
Methods inherited from class org.blinkenbyte.io.BlockDeviceFilter |
---|
close, getAutoSectorAlign, getDriveGeometry, getFilePointer, getSectorSize, getSectorSizeLog, length, open, read, seek, setAutoSectorAlign, setSectorSize, skipBytes, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BadBlockEmulator(BlockDevice _bd)
Method Detail |
---|
public boolean getAllowPartials()
public void setAllowPartials(boolean _allowPartials)
public void loadList(java.io.Reader r) throws java.lang.Exception
java.lang.Exception
public void loadList(java.util.ArrayList<BlockRange> listToAdd)
public void clearList()
public java.util.Iterator<BlockRange> iterator()
public int numBlocks()
public BlockRange getBlockRange(int index)
public void addBlock(long blockNumber, long blockLength) throws java.lang.Exception
blockNumber
- The starting block number of the range.blockLength
- The length of the range.
java.lang.Exception
public boolean removeBlock(long blockNumber, long blockLength) throws java.lang.Exception
blockNumber
- The starting block number of the range.blockLength
- The length of the range.
java.lang.Exception
public int read() throws java.io.IOException
read
in interface BlockDevice
read
in class BlockDeviceFilter
java.io.IOException
public int read(byte[] b, int offset, int len) throws java.io.IOException
read
in interface BlockDevice
read
in class BlockDeviceFilter
java.io.IOException
public void write(byte[] b, int offset, int len) throws java.io.IOException
write
in interface BlockDevice
write
in class BlockDeviceFilter
java.io.IOException
public void write(int b) throws java.io.IOException
write
in interface BlockDevice
write
in class BlockDeviceFilter
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |