pub struct UtilLinuxBlockTools { /* private fields */ }Expand description
BlockTools over util-linux, the block tooling a stock distro ships.
Where BusyboxBlockTools drives one
multi-call binary with applet names, this drives two separate programs,
and it attaches in a single command rather than two: util-linux’s
losetup -f --show FILE allocates, attaches, and prints the device it
used, retrying EBUSY/EAGAIN itself (64 tries, 200 ms apart, in its
own create_loop) when another process claims the device it picked. So
there is no query-then-attach window here and no host-side retry loop —
the difference that makes this a separate implementation rather than
BusyboxBlockTools pointed at another path.
blockdev --getsz is byte-identical between the two, and losetup -r /
losetup -d DEVICE mean the same thing in both.
Implementations§
Source§impl UtilLinuxBlockTools
impl UtilLinuxBlockTools
Sourcepub fn new(
losetup: impl Into<PathBuf>,
blockdev: impl Into<PathBuf>,
) -> UtilLinuxBlockTools
pub fn new( losetup: impl Into<PathBuf>, blockdev: impl Into<PathBuf>, ) -> UtilLinuxBlockTools
Use the binaries at losetup and blockdev as given. Nothing is
probed: a composer that knows where its userland lives (a bundled
copy, a non-standard prefix) says so and is believed.
Sourcepub fn discover() -> Result<UtilLinuxBlockTools, SnapshotError>
pub fn discover() -> Result<UtilLinuxBlockTools, SnapshotError>
Find both binaries in the reference search lists, failing when either is absent or is not util-linux.
PATH is deliberately not searched — the crate never does (see
snapshot_cow), and a node agent’s PATH is
whatever its unit file happened to inherit.
Trait Implementations§
Source§impl BlockTools for UtilLinuxBlockTools
impl BlockTools for UtilLinuxBlockTools
Source§fn attach_loop(
&self,
backing: &Path,
read_only: bool,
) -> Result<String, SnapshotError>
fn attach_loop( &self, backing: &Path, read_only: bool, ) -> Result<String, SnapshotError>
losetup -f --show [-r] -- FILE, whose stdout is the device that
was attached. The path is passed after -- so a backing file whose
name starts with - cannot be read as an option.
Source§fn detach_loop(&self, device: &str) -> Result<(), SnapshotError>
fn detach_loop(&self, device: &str) -> Result<(), SnapshotError>
Source§fn device_sectors(&self, device: &str) -> Result<u64, SnapshotError>
fn device_sectors(&self, device: &str) -> Result<u64, SnapshotError>
Source§impl Clone for UtilLinuxBlockTools
impl Clone for UtilLinuxBlockTools
Source§fn clone(&self) -> UtilLinuxBlockTools
fn clone(&self) -> UtilLinuxBlockTools
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more