summaryrefslogtreecommitdiff
path: root/src/mount
diff options
context:
space:
mode:
Diffstat (limited to 'src/mount')
-rw-r--r--src/mount/bsd.rs32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/mount/bsd.rs b/src/mount/bsd.rs
index 109522f9..1ba8b809 100644
--- a/src/mount/bsd.rs
+++ b/src/mount/bsd.rs
@@ -1,16 +1,22 @@
+#[cfg(target_os = "freebsd")]
use crate::{
Error,
+};
+use crate::{
Errno,
NixPath,
Result,
};
-use libc::{c_char, c_int, c_uint, c_void};
+#[cfg(target_os = "freebsd")]
+use libc::{c_char, c_uint, c_void};
+use libc::c_int;
+#[cfg(target_os = "freebsd")]
use std::{
borrow::Cow,
ffi::{CString, CStr},
+ marker::PhantomData,
fmt,
io,
- marker::PhantomData,
};
@@ -110,12 +116,14 @@ libc_bitflags!(
///
/// It wraps an [`Errno`], but also may contain an additional message returned
/// by `nmount(2)`.
+#[cfg(target_os = "freebsd")]
#[derive(Debug)]
pub struct NmountError {
errno: Error,
errmsg: Option<String>
}
+#[cfg(target_os = "freebsd")]
impl NmountError {
/// Returns the additional error string sometimes generated by `nmount(2)`.
pub fn errmsg(&self) -> Option<&str> {
@@ -135,8 +143,10 @@ impl NmountError {
}
}
+#[cfg(target_os = "freebsd")]
impl std::error::Error for NmountError {}
+#[cfg(target_os = "freebsd")]
impl fmt::Display for NmountError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(errmsg) = &self.errmsg {
@@ -147,6 +157,7 @@ impl fmt::Display for NmountError {
}
}
+#[cfg(target_os = "freebsd")]
impl From<NmountError> for io::Error {
fn from(err: NmountError) -> Self {
err.errno.into()
@@ -154,6 +165,7 @@ impl From<NmountError> for io::Error {
}
/// Result type of [`Nmount::nmount`].
+#[cfg(target_os = "freebsd")]
pub type NmountResult = std::result::Result<(), NmountError>;
/// Mount a FreeBSD file system.
@@ -425,13 +437,15 @@ impl<'a> Drop for Nmount<'a> {
///
/// Useful flags include
/// * `MNT_FORCE` - Unmount even if still in use.
-/// * `MNT_BYFSID` - `mountpoint` is not a path, but a file system ID
-/// encoded as `FSID:val0:val1`, where `val0` and `val1`
-/// are the contents of the `fsid_t val[]` array in decimal.
-/// The file system that has the specified file system ID
-/// will be unmounted. See
-/// [`statfs`](crate::sys::statfs::statfs) to determine the
-/// `fsid`.
+#[cfg_attr(target_os = "freebsd", doc = "
+* `MNT_BYFSID` - `mountpoint` is not a path, but a file system ID
+ encoded as `FSID:val0:val1`, where `val0` and `val1`
+ are the contents of the `fsid_t val[]` array in decimal.
+ The file system that has the specified file system ID
+ will be unmounted. See
+ [`statfs`](crate::sys::statfs::statfs) to determine the
+ `fsid`.
+")]
pub fn unmount<P>(mountpoint: &P, flags: MntFlags) -> Result<()>
where P: ?Sized + NixPath
{