pub struct LoopControl { /* private fields */ }
Expand description
Interface to the loop control device: /dev/loop-control
.
Implementations§
Source§impl LoopControl
impl LoopControl
Sourcepub fn open() -> Result<Self>
pub fn open() -> Result<Self>
Opens the loop control device.
§Errors
This function will return an error for various reasons when opening
the loop control file /dev/loop-control
. See
OpenOptions::open
for further details.
Sourcepub fn next_free(&self) -> Result<LoopDevice>
pub fn next_free(&self) -> Result<LoopDevice>
Finds and opens the next available loop device.
§Examples
use loopdev::LoopControl;
let lc = LoopControl::open().unwrap();
let ld = lc.next_free().unwrap();
println!("{}", ld.path().unwrap().display());
§Errors
This function will return an error for various reasons when opening
the loop device file /dev/loopX
. See
OpenOptions::open
for further details.
Sourcepub fn add(&self, n: u32) -> Result<LoopDevice>
pub fn add(&self, n: u32) -> Result<LoopDevice>
Add and opens a new loop device.
§Examples
use loopdev::LoopControl;
let lc = LoopControl::open().unwrap();
let ld = lc.add(1).unwrap();
println!("{}", ld.path().unwrap().display());
§Errors
This funcitons will return an error when a loop device with the passed number exists or opening the newly created device fails.
Trait Implementations§
Source§impl AsRawFd for LoopControl
impl AsRawFd for LoopControl
Source§impl Debug for LoopControl
impl Debug for LoopControl
Source§impl IntoRawFd for LoopControl
impl IntoRawFd for LoopControl
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 LoopControl
impl RefUnwindSafe for LoopControl
impl Send for LoopControl
impl Sync for LoopControl
impl Unpin for LoopControl
impl UnwindSafe for LoopControl
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