pub struct Unmount { /* private fields */ }Expand description
Object to unmount a device.
Implementations§
Source§impl Unmount
impl Unmount
Sourcepub fn builder() -> UnmountBuilder
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.
Sourcepub fn unmount_device(&mut self) -> Result<ExitStatus, UnmountError>
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:
Sourcepub fn prepare_unmount(&mut self) -> Result<(), UnmountError>
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.
Sourcepub fn call_umount_syscall(&mut self) -> Result<ExitStatus, UnmountError>
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.
Sourcepub fn finalize_umount(&mut self) -> Result<(), UnmountError>
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.
Sourcepub fn set_syscall_exit_status(
&mut self,
exit_status: i32,
) -> Result<(), UnmountError>
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).
Sourcepub fn reset_syscall_exit_status(&mut self) -> Result<(), UnmountError>
pub fn reset_syscall_exit_status(&mut self) -> Result<(), UnmountError>
Resets umount exit status so that umount methods can be called again.
Sourcepub fn switch_to_namespace(
&mut self,
namespace: UMountNamespace<'_>,
) -> Option<UMountNamespace<'_>>
pub fn switch_to_namespace( &mut self, namespace: UMountNamespace<'_>, ) -> Option<UMountNamespace<'_>>
Switches to the provided namespace, and returns the namespace used previously.
Sourcepub fn switch_to_original_namespace(&mut self) -> Option<UMountNamespace<'_>>
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.
Sourcepub fn switch_to_target_namespace(&mut self) -> Option<UMountNamespace<'_>>
pub fn switch_to_target_namespace(&mut self) -> Option<UMountNamespace<'_>>
Switches to the target’s namespace, and returns the namespace used previously.
Sourcepub fn source(&self) -> Option<String>
pub fn source(&self) -> Option<String>
Returns the identifier of the device to mount, or None if it was not provided.
Sourcepub fn target(&self) -> Option<PathBuf>
pub fn target(&self) -> Option<PathBuf>
Returns the configured device mount point, or None if it was not provided.
Sourcepub fn target_namespace(&self) -> Option<UMountNamespace<'_>>
pub fn target_namespace(&self) -> Option<UMountNamespace<'_>>
Returns the mount point’s UMountNamespace, or None if it is
not set.
Sourcepub fn umount_helper_exit_status(&self) -> i32
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.
Sourcepub fn umount_syscall_errno(&self) -> Option<i32>
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.
Sourcepub fn seq_unmount(&mut self) -> UMountIter<'_> ⓘ
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.
Sourcepub fn is_dry_run(&self) -> bool
pub fn is_dry_run(&self) -> bool
Returns true if this Unmount is configured to perform a dry run.
Sourcepub fn is_verbose(&self) -> bool
pub fn is_verbose(&self) -> bool
Returns true if this Unmount is configured to be verbose.
Sourcepub fn detaches_loop_device(&self) -> bool
pub fn detaches_loop_device(&self) -> bool
Returns true if this Unmount is configured to delete loop devices after unmounting them.
Sourcepub fn disabled_path_canonicalization(&self) -> bool
pub fn disabled_path_canonicalization(&self) -> bool
Returns true if this Unmount is configured NOT to canonicalize paths.
Sourcepub fn disabled_mount_point_lookup(&self) -> bool
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.
Sourcepub fn has_called_umount_syscall(&self) -> bool
pub fn has_called_umount_syscall(&self) -> bool
Returns true if the umount syscall
was invoked.
Sourcepub fn has_disabled_helpers(&self) -> bool
pub fn has_disabled_helpers(&self) -> bool
Returns true if this Unmount is configured NOT to use umount helpers.
Sourcepub fn has_run_umount_helper(&self) -> bool
pub fn has_run_umount_helper(&self) -> bool
Returns true if a umount helper was run.
Sourcepub fn does_not_update_utab(&self) -> bool
pub fn does_not_update_utab(&self) -> bool
Returns true if this Unmount is configured to disable userpace mount table updates.
Sourcepub fn does_lazy_unmount(&self) -> bool
pub fn does_lazy_unmount(&self) -> bool
Returns true if this Unmount is configured to unmount devices lazily.
Sourcepub fn forces_unmount(&self) -> bool
pub fn forces_unmount(&self) -> bool
Returns true if this Unmount is configured to force device to unmount.
Sourcepub fn on_fail_remounts_read_only(&self) -> bool
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.