Struct loopdev::LoopDevice [−][src]
pub struct LoopDevice { /* fields omitted */ }
Expand description
Interface to a loop device ie /dev/loop0
.
Implementations
Attach the loop device to a file with given options.
Examples
Attach the device to a file.
use loopdev::LoopDevice;
let mut ld = LoopDevice::open("/dev/loop3").unwrap();
ld.with().part_scan(true).attach("disk.img").unwrap();
Attach the loop device to a file that maps to the whole file.
Examples
Attach the device to a file.
use loopdev::LoopDevice;
let ld = LoopDevice::open("/dev/loop4").unwrap();
ld.attach_file("disk.img").unwrap();
Detach a loop device from its backing file.
Note that the device won’t fully detach until a short delay after the underling device file gets closed. This happens when LoopDev goes out of scope so you should ensure the LoopDev lives for a short a time as possible.
Examples
use loopdev::LoopDevice;
let ld = LoopDevice::open("/dev/loop5").unwrap();
ld.detach().unwrap();
Resize a live loop device. If the size of the backing file changes this can be called to inform the loop driver about the new size.