de.waldheinz.fs
Interface BlockDevice

All Known Implementing Classes:
FileDisk, RamDisk

public interface BlockDevice

This is the abstraction used for a device that can hold a FileSystem.

Author:
Ewout Prangsma <epr at jnode.org>, Matthias Treydte <waldheinz at gmail.com>

Method Summary
 void close()
          Closes this BlockDevice.
 void flush()
          Flushes data in caches to the actual storage.
 int getSectorSize()
          Returns the size of a sector on this device.
 long getSize()
          Gets the total length of this device in bytes.
 boolean isClosed()
          Checks if this device was already closed.
 boolean isReadOnly()
          Checks if this BlockDevice is read-only.
 void read(long devOffset, ByteBuffer dest)
          Read a block of data from this device.
 void write(long devOffset, ByteBuffer src)
          Writes a block of data to this device.
 

Method Detail

getSize

long getSize()
             throws IOException
Gets the total length of this device in bytes.

Returns:
the total number of bytes on this device
Throws:
IOException - on error getting the size of this device

read

void read(long devOffset,
          ByteBuffer dest)
          throws IOException
Read a block of data from this device.

Parameters:
devOffset - the byte offset where to read the data from
dest - the destination buffer where to store the data read
Throws:
IOException - on read error

write

void write(long devOffset,
           ByteBuffer src)
           throws ReadOnlyException,
                  IOException,
                  IllegalArgumentException
Writes a block of data to this device.

Parameters:
devOffset - the byte offset where to store the data
src - the source ByteBuffer to write to the device
Throws:
ReadOnlyException - if this BlockDevice is read-only
IOException - on write error
IllegalArgumentException - if the devOffset is negative or the write would go beyond the end of the device
See Also:
isReadOnly()

flush

void flush()
           throws IOException
Flushes data in caches to the actual storage.

Throws:
IOException - on write error

getSectorSize

int getSectorSize()
                  throws IOException
Returns the size of a sector on this device.

Returns:
the sector size in bytes
Throws:
IOException - on error determining the sector size

close

void close()
           throws IOException
Closes this BlockDevice. No methods of this device may be accesses after this method was called.

Throws:
IOException - on error closing this device
See Also:
isClosed()

isClosed

boolean isClosed()
Checks if this device was already closed. No methods may be called on a closed device (except this method).

Returns:
if this device is closed

isReadOnly

boolean isReadOnly()
Checks if this BlockDevice is read-only.

Returns:
if this BlockDevice is read-only


Copyright © 2014. All rights reserved.