Struct Unmount

Source
pub struct Unmount { /* private fields */ }
Expand description

Object to unmount a device.

Implementations§

Source§

impl Unmount

Source

pub fn builder() -> UnmountBuilder

Creates a UnmountBuilder to configure and construct a new Unmount instance.

Call the UnmountBuilder’s build() method to construct a new Unmount instance.

Source

pub fn unmount_device(&mut self) -> Result<ExitStatus, UnmountError>

Unmounts a device using the umount syscall and/or umount helpers.

Equivalent to running the following functions in succession:

Source

pub fn prepare_unmount(&mut self) -> Result<(), UnmountError>

Validates this Unmount’s parameters before it tries to unmount a device.

Note: you do not need to call this method if you are using Unmount::unmount_device, it will take care of parameter validation.

Source

pub fn call_umount_syscall(&mut self) -> Result<ExitStatus, UnmountError>

Runs the umount syscall and/or umount helpers.

Note: you do not need to call this method if you are using Unmount::unmount_device, it will take care of everything for you.

Source

pub fn finalize_umount(&mut self) -> Result<(), UnmountError>

Updates the system’s mount tables to take the last modifications into account. You should call this function after invoking Unmount::call_umount_syscall.

Note: you do not need to call this method if you are using Unmount::unmount_device, it will take care of finalizing the unmount.

Source

pub fn set_syscall_exit_status( &mut self, exit_status: i32, ) -> Result<(), UnmountError>

Sets umount’s syscall exit status if the function was called outside of libmount.

The exit_status should be 0 on success, and a negative number on error (e.g. -errno).

Source

pub fn reset_syscall_exit_status(&mut self) -> Result<(), UnmountError>

Resets umount exit status so that umount methods can be called again.

Source

pub fn switch_to_namespace( &mut self, namespace: UMountNamespace<'_>, ) -> Option<UMountNamespace<'_>>

Switches to the provided namespace, and returns the namespace used previously.

Source

pub fn switch_to_original_namespace(&mut self) -> Option<UMountNamespace<'_>>

Switches to the namespace at creation, and returns the replacement namespace used up to this point.

Source

pub fn switch_to_target_namespace(&mut self) -> Option<UMountNamespace<'_>>

Switches to the target’s namespace, and returns the namespace used previously.

Source

pub fn source(&self) -> Option<String>

Returns the identifier of the device to mount, or None if it was not provided.

Source

pub fn target(&self) -> Option<PathBuf>

Returns the configured device mount point, or None if it was not provided.

Source

pub fn target_namespace(&self) -> Option<UMountNamespace<'_>>

Returns the mount point’s UMountNamespace, or None if it is not set.

Source

pub fn umount_helper_exit_status(&self) -> i32

Returns the exit status of a mount helper (mount.filesytem) called by the user. The resulting value is pertinent only when the method Unmount::has_run_umount_helper returns true.

Source

pub fn umount_syscall_errno(&self) -> Option<i32>

Returns the number of the last error, errno, if invoking the mount syscall syscall resulted in a failure.

Source

pub fn seq_unmount(&mut self) -> UMountIter<'_>

Tries to sequentially umount entries in /proc/self/mountinfo.

To filter devices to umount by file system type and/or mount options, use the methods UnmountBuilder::match_file_systems and/or UnmountBuilder::match_mount_options when instantiating a new Mount object.

Source

pub fn is_dry_run(&self) -> bool

Returns true if this Unmount is configured to perform a dry run.

Source

pub fn is_verbose(&self) -> bool

Returns true if this Unmount is configured to be verbose.

Source

pub fn detaches_loop_device(&self) -> bool

Returns true if this Unmount is configured to delete loop devices after unmounting them.

Source

pub fn disabled_path_canonicalization(&self) -> bool

Returns true if this Unmount is configured NOT to canonicalize paths.

Source

pub fn disabled_mount_point_lookup(&self) -> bool

Returns true if this Unmount is configured NOT to lookup a device or mount point in /etc/fstab if one is not provided when setting this Unmount’s source or target.

Source

pub fn has_called_umount_syscall(&self) -> bool

Returns true if the umount syscall was invoked.

Source

pub fn has_disabled_helpers(&self) -> bool

Returns true if this Unmount is configured NOT to use umount helpers.

Source

pub fn has_run_umount_helper(&self) -> bool

Returns true if a umount helper was run.

Source

pub fn does_not_update_utab(&self) -> bool

Returns true if this Unmount is configured to disable userpace mount table updates.

Source

pub fn does_lazy_unmount(&self) -> bool

Returns true if this Unmount is configured to unmount devices lazily.

Source

pub fn forces_unmount(&self) -> bool

Returns true if this Unmount is configured to force device to unmount.

Source

pub fn on_fail_remounts_read_only(&self) -> bool

Returns true if this Unmount is configured to remount a device in read-only mode after a failed unmount.

Trait Implementations§

Source§

impl AsRef<Unmount> for Unmount

Source§

fn as_ref(&self) -> &Unmount

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for Unmount

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Unmount

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.