| 1 |
//! # libmount |
| 2 |
//! |
| 3 |
//! [Documentation](https://docs.rs/libmount) | |
| 4 |
//! [Github](https://github.com/tailhook/libmount) | |
| 5 |
//! [Crate](https://crates.io/crates/libmount) |
| 6 |
//! |
| 7 |
//! This library has two major goals: |
| 8 |
//! |
| 9 |
//! 1. Add type-safe interface for mount() system call |
| 10 |
//! 2. Add very good explanation of what's wrong when the call fails |
| 11 |
//! |
| 12 |
//! So we have two error types: |
| 13 |
//! |
| 14 |
//! 1. `OSError` holds mount info and errno |
| 15 |
//! 2. `Error` is returned by `OSError::explain()` |
| 16 |
//! |
| 17 |
//! The first one is returned by `bare_mount()` the second by `mount()`, and |
| 18 |
//! using latter is preffered for most situations. Unless performance is |
| 19 |
//! too critical (i.e. you are doing thousands of *failing* mounts per second). |
| 20 |
//! On the success path there is no overhead. |
| 21 |
//! |
| 22 |
#![warn(missing_debug_implementations)] |
| 23 |
#![warn(missing_docs)] |
| 24 |
|
| 25 |
extern crate libcrust-analyzer cargo libmount 0.1.15 libc/; |
| 26 |
extern crate nixrust-analyzer cargo libmount 0.1.15 nix/; |
| 27 |
#[macro_use] extern crate quick_errorrust-analyzer cargo libmount 0.1.15 quick_error/; |
| 28 |
|
| 29 |
mod utilrust-analyzer cargo libmount 0.1.15 util/; |
| 30 |
mod errorrust-analyzer cargo libmount 0.1.15 error/; |
| 31 |
mod explainrust-analyzer cargo libmount 0.1.15 explain/; |
| 32 |
mod bindrust-analyzer cargo libmount 0.1.15 bind/; |
| 33 |
mod overlayrust-analyzer cargo libmount 0.1.15 overlay/; |
| 34 |
mod tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/; |
| 35 |
mod modifyrust-analyzer cargo libmount 0.1.15 modify/; |
| 36 |
mod remountrust-analyzer cargo libmount 0.1.15 remount/; |
| 37 |
pub mod mountinforust-analyzer cargo libmount 0.1.15 mountinfo/; |
| 38 |
|
| 39 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/; |
| 40 |
|
| 41 |
use explainrust-analyzer cargo libmount 0.1.15 explain/::Explainablerust-analyzer cargo libmount 0.1.15 explain/Explainable#; |
| 42 |
use remountrust-analyzer cargo libmount 0.1.15 remount/::RemountErrorrust-analyzer cargo libmount 0.1.15 remount/RemountError#; |
| 43 |
pub use bindrust-analyzer cargo libmount 0.1.15 bind/::BindMountrust-analyzer cargo libmount 0.1.15 bind/BindMount#; |
| 44 |
pub use overlayrust-analyzer cargo libmount 0.1.15 overlay/::Overlayrust-analyzer cargo libmount 0.1.15 overlay/Overlay#; |
| 45 |
pub use tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/::Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#; |
| 46 |
pub use modifyrust-analyzer cargo libmount 0.1.15 modify/::Moverust-analyzer cargo libmount 0.1.15 modify/Move#; |
| 47 |
pub use remountrust-analyzer cargo libmount 0.1.15 remount/::Remountrust-analyzer cargo libmount 0.1.15 remount/Remount#; |
| 48 |
|
| 49 |
quick_errorrust-analyzer cargo quick-error 2.0.1 quick_error!! { |
| 50 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 51 |
enum MountErrorrust-analyzer cargo libmount 0.1.15 MountError# { |
| 52 |
Iorust-analyzer cargo libmount 0.1.15 MountError#Io#(err: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#) { |
| •53 |
source(err) |
| 54 |
from() |
| 55 |
} |
| 56 |
Remountrust-analyzer cargo libmount 0.1.15 MountError#Remount#(err: RemountErrorrust-analyzer cargo libmount 0.1.15 remount/RemountError#) { |
| •57 |
source(err) |
| 58 |
from() |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
/// The raw os error |
| 64 |
/// |
| 65 |
/// This is a wrapper around `io::Error` providing `explain()` method |
| 66 |
/// |
| 67 |
/// Note: you need to explain as fast as possible, because during explain |
| 68 |
/// library makes some probes for different things in filesystem, and if |
| 69 |
/// anything changes it may give incorrect results. |
| 70 |
/// |
| 71 |
/// You should always `explain()` the errors, unless you are trying lots of |
| 72 |
/// mounts for bruteforcing or other similar thing and you are concerned of |
| 73 |
/// performance. Usually library does `stat()` and similar things which are |
| 74 |
/// much faster than mount anyway. Also explaining is zero-cost in the success |
| 75 |
/// path. |
| 76 |
/// |
| 77 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 78 |
pub struct OSErrorrust-analyzer cargo libmount 0.1.15 OSError#(MountErrorrust-analyzer cargo libmount 0.1.15 MountError#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Explainablerust-analyzer cargo libmount 0.1.15 explain/Explainable#>); |
| 79 |
|
| 80 |
impl OSErrorrust-analyzer cargo libmount 0.1.15 OSError# { |
| 81 |
fn from_remountrust-analyzer cargo libmount 0.1.15 impl#[OSError]from_remount().(err: RemountErrorrust-analyzer cargo libmount 0.1.15 remount/RemountError#, explain: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Explainablerust-analyzer cargo libmount 0.1.15 explain/Explainable#>) -> OSErrorrust-analyzer cargo libmount 0.1.15 OSError# { |
| 82 |
OSErrorrust-analyzer cargo libmount 0.1.15 OSError#(MountErrorrust-analyzer cargo libmount 0.1.15 MountError#::Remountrust-analyzer cargo libmount 0.1.15 MountError#Remount#(err), explain) |
| 83 |
} |
| 84 |
|
| 85 |
fn from_nixrust-analyzer cargo libmount 0.1.15 impl#[OSError]from_nix().(err: nixrust-analyzer cargo nix 0.31.3 crate/::Errorrust-analyzer cargo nix 0.31.3 Error#, explain: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Explainablerust-analyzer cargo libmount 0.1.15 explain/Explainable#>) -> OSErrorrust-analyzer cargo libmount 0.1.15 OSError# { |
| 86 |
OSErrorrust-analyzer cargo libmount 0.1.15 OSError#( |
| 87 |
MountErrorrust-analyzer cargo libmount 0.1.15 MountError#::Iorust-analyzer cargo libmount 0.1.15 MountError#Io#( |
| •88 |
iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::fromrust-analyzer cargo nix 0.31.3 errno/impl#[`io::Error`][`From<Errno>`]from().(err), |
| 89 |
), |
| 90 |
explain, |
| 91 |
) |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
/// The error holder which contains as much information about why failure |
| 96 |
/// happens as the library implementors could gain |
| 97 |
/// |
| 98 |
/// This type only provides `Display` for now, but some programmatic interface |
| 99 |
/// is expected in future. |
| 100 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 101 |
pub struct Errorrust-analyzer cargo libmount 0.1.15 Error#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Explainablerust-analyzer cargo libmount 0.1.15 explain/Explainable#>, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#); |