[−][src]Trait vblk::BlockDevice
A virtual block device.
Required methods
fn block_size(&self) -> u32
Returns the device block size in bytes.
According to the NBD kernel source code, the block size must currently be a power of two between 512 bytes and the system page size in bytes.
fn blocks(&self) -> u64
Returns the device size in blocks.
Provided methods
fn read(&mut self, offset: u64, bytes: &mut [u8]) -> Result<()>
Reads a byte range from the block device.
Note
If you return an I/O error not associated with an OS errno
, vblk
will automatically return an EIO
error to the caller by default.
fn write(&mut self, offset: u64, bytes: &[u8]) -> Result<()>
Writes a byte range to the block device.
Note
If you return an I/O error not associated with an OS errno
, vblk
will automatically return an EIO
error to the caller by default.
fn flush(&mut self) -> Result<()>
Flushes any cached data to the block device.
Note
If you return an I/O error not associated with an OS errno
, vblk
will automatically return an EIO
error to the caller by default.
Warning
Support for this command depends on your Linux kernel version.
fn trim(&mut self, offset: u64, len: u32) -> Result<()>
Trims a byte range of the block device.
Note
If you return an I/O error not associated with an OS errno
, vblk
will automatically return an EIO
error to the caller by default.
Warning
Support for this command depends on your Linux kernel version.
fn unmount(&mut self)
Called when the block device is unmounted.