Thanks to visit codestin.com
Credit goes to docs.rs

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§

AttachOptions
Used to set options when attaching a device. Created with LoopDevice::with().
LoopControl
Interface to the loop control device: /dev/loop-control.
LoopDevice
Interface to a loop device ie /dev/loop0.