pub struct LoopDevice { /* private fields */ }
Expand description
Interface to a loop device ie /dev/loop0
.
Implementations§
Source§impl LoopDevice
impl LoopDevice
Sourcepub fn with(&self) -> AttachOptions<'_>
pub fn with(&self) -> AttachOptions<'_>
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();
Sourcepub fn attach_file<P: AsRef<Path>>(&self, backing_file: P) -> Result<()>
pub fn attach_file<P: AsRef<Path>>(&self, backing_file: P) -> Result<()>
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();
Sourcepub fn detach(&self) -> Result<()>
pub fn detach(&self) -> Result<()>
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();
Sourcepub fn set_capacity(&self) -> Result<()>
pub fn set_capacity(&self) -> Result<()>
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.
Trait Implementations§
Source§impl AsRawFd for LoopDevice
impl AsRawFd for LoopDevice
Source§impl Debug for LoopDevice
impl Debug for LoopDevice
Source§impl IntoRawFd for LoopDevice
impl IntoRawFd for LoopDevice
Source§fn into_raw_fd(self) -> RawFd
fn into_raw_fd(self) -> RawFd
Consumes this object, returning the raw underlying file descriptor. Read more
Auto Trait Implementations§
impl Freeze for LoopDevice
impl RefUnwindSafe for LoopDevice
impl Send for LoopDevice
impl Sync for LoopDevice
impl Unpin for LoopDevice
impl UnwindSafe for LoopDevice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more