Crate loopdev

Source
Expand description

Setup and control loop devices.

Provides rust interface with similar functionality to the Linux utility losetup.

§Examples

Default options:

use loopdev::LoopControl;
let lc = LoopControl::open().unwrap();
let ld = lc.next_free().unwrap();

println!("{}", ld.path().unwrap().display());

ld.attach_file("disk.img").unwrap();
// ...
ld.detach().unwrap();

Custom options:

ld.with()
    .part_scan(true)
    .offset(512 * 1024 * 1024) // 512 MiB
    .size_limit(1024 * 1024 * 1024) // 1GiB
    .attach("disk.img").unwrap();
// ...
ld.detach().unwrap();

Structs§