pub trait BlockTools: Send + Sync {
// Required methods
fn attach_loop(
&self,
backing: &Path,
read_only: bool,
) -> Result<String, SnapshotError>;
fn detach_loop(&self, device: &str) -> Result<(), SnapshotError>;
fn device_sectors(&self, device: &str) -> Result<u64, SnapshotError>;
}Expand description
Loop-device and block-size operations, supplied by the composer.
Every method is synchronous and may block on a subprocess or an ioctl;
CowManager calls them from spawn_blocking.
Implementations are shared across sandboxes and tasks, hence
Send + Sync.
Required Methods§
Sourcefn attach_loop(
&self,
backing: &Path,
read_only: bool,
) -> Result<String, SnapshotError>
fn attach_loop( &self, backing: &Path, read_only: bool, ) -> Result<String, SnapshotError>
Attach backing as a loop device and return the device path
(/dev/loopN). Must hold up against concurrent callers in other
processes: either allocate and attach in one atomic step
(LOOP_CONFIGURE, util-linux losetup -f --show) or, when the tool
cannot, query a free device, attach to it, and retry when another
process claimed it in between (what BusyboxBlockTools does).
Sourcefn detach_loop(&self, device: &str) -> Result<(), SnapshotError>
fn detach_loop(&self, device: &str) -> Result<(), SnapshotError>
Detach a loop device.
Sourcefn device_sectors(&self, device: &str) -> Result<u64, SnapshotError>
fn device_sectors(&self, device: &str) -> Result<u64, SnapshotError>
Size of a block device in 512-byte sectors.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".