diff --git a/CHANGELOG.md b/CHANGELOG.md index a166fde9c8..43d122ab10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] - ReleaseDate ### Added +- Add `MntFlags` and `unmount` on all of the BSDs. + ([#1849](https://github.com/nix-rust/nix/pull/1849)) - Added a 'Statfs::flags' method. ([#1849](https://github.com/nix-rust/nix/pull/1849)) - Added `NSFS_MAGIC` FsType on Linux and Android. diff --git a/src/lib.rs b/src/lib.rs index 770258dd36..6b82125761 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -106,7 +106,6 @@ feature! { #[allow(missing_docs)] pub mod kmod; } -#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] feature! { #![feature = "mount"] pub mod mount; diff --git a/src/mount/bsd.rs b/src/mount/bsd.rs index 109522f9fb..a018937cac 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 } +#[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 for io::Error { fn from(err: NmountError) -> Self { err.errno.into() @@ -154,6 +165,7 @@ impl From for io::Error { } /// Result type of [`Nmount::nmount`]. +#[cfg(target_os = "freebsd")] pub type NmountResult = std::result::Result<(), NmountError>; /// Mount a FreeBSD file system.