Skip to content

Commit

Permalink
Adds Mount safe type
Browse files Browse the repository at this point in the history
  • Loading branch information
sanpii committed Oct 12, 2021
1 parent 478684c commit 5e8b434
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ impl Container {
cstr!(filesystemtype),
mountflags,
data,
mnt,
mnt.as_mut_ptr(),
);

if result >= 0 {
Expand All @@ -714,7 +714,7 @@ impl Container {
mountflags: u64,
mnt: &mut crate::Mount,
) -> crate::Result<()> {
call!(self.umount(cstr!(target), mountflags, mnt) -> int)
call!(self.umount(cstr!(target), mountflags, mnt.as_mut_ptr()) -> int)
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ mod container;
mod flags;
pub mod log;
mod migrate;
#[cfg(feature = "v3_1")]
mod mount;
mod snapshot;

pub use self::container::Container;
pub use self::flags::{AttchFlags, CloneFlags, CreateFlags};
pub use self::log::Log;
#[cfg(feature = "v3_1")]
pub use self::mount::Mount;
pub use self::snapshot::Snapshot;

pub use lxc_sys::lxc_conf as Conf;
pub use lxc_sys::lxc_lock as Lock;
#[cfg(feature = "v3_1")]
pub use lxc_sys::lxc_mount as Mount;

#[derive(Debug)]
pub struct Error {
Expand Down
30 changes: 30 additions & 0 deletions src/mount.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pub struct Mount {
inner: *mut lxc_sys::lxc_mount,
}

impl Mount {
pub fn version(&self) -> std::os::raw::c_int {
prop!(self.version)
}

/**
* Returns a raw pointer to the snapshot.
*/
pub fn as_ptr(&self) -> *const lxc_sys::lxc_mount {
self.inner
}

/**
* Returns a mutable raw pointer to the snapshot.
*/
pub fn as_mut_ptr(&mut self) -> *mut lxc_sys::lxc_mount {
self.inner
}
}

#[doc(hidden)]
impl Into<Mount> for &*mut lxc_sys::lxc_mount {
fn into(self) -> Mount {
Mount { inner: *self }
}
}

0 comments on commit 5e8b434

Please sign in to comment.