From 1b6a04ca5504955c571d1c97504fb45ea0befee4 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 8 Jan 2024 01:21:28 +0400 Subject: Initial vendor packages Signed-off-by: Valentin Popov --- vendor/rustix/src/mount/mount_unmount.rs | 175 +++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 vendor/rustix/src/mount/mount_unmount.rs (limited to 'vendor/rustix/src/mount/mount_unmount.rs') diff --git a/vendor/rustix/src/mount/mount_unmount.rs b/vendor/rustix/src/mount/mount_unmount.rs new file mode 100644 index 0000000..ebb5173 --- /dev/null +++ b/vendor/rustix/src/mount/mount_unmount.rs @@ -0,0 +1,175 @@ +//! Linux `mount`. + +use crate::backend::mount::types::{ + InternalMountFlags, MountFlags, MountFlagsArg, MountPropagationFlags, UnmountFlags, +}; +use crate::{backend, io, path}; + +/// `mount(source, target, filesystemtype, mountflags, data)` +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html +#[inline] +pub fn mount( + source: Source, + target: Target, + file_system_type: Fs, + flags: MountFlags, + data: Data, +) -> io::Result<()> { + source.into_with_c_str(|source| { + target.into_with_c_str(|target| { + file_system_type.into_with_c_str(|file_system_type| { + data.into_with_c_str(|data| { + backend::mount::syscalls::mount( + Some(source), + target, + Some(file_system_type), + MountFlagsArg(flags.bits()), + Some(data), + ) + }) + }) + }) + }) +} + +/// `mount(NULL, target, NULL, MS_REMOUNT | mountflags, data)` +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html +#[inline] +#[doc(alias = "mount")] +#[doc(alias = "MS_REMOUNT")] +pub fn mount_remount( + target: Target, + flags: MountFlags, + data: Data, +) -> io::Result<()> { + target.into_with_c_str(|target| { + data.into_with_c_str(|data| { + backend::mount::syscalls::mount( + None, + target, + None, + MountFlagsArg(InternalMountFlags::REMOUNT.bits() | flags.bits()), + Some(data), + ) + }) + }) +} + +/// `mount(source, target, NULL, MS_BIND, NULL)` +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html +#[inline] +#[doc(alias = "mount")] +#[doc(alias = "MS_BIND")] +pub fn mount_bind( + source: Source, + target: Target, +) -> io::Result<()> { + source.into_with_c_str(|source| { + target.into_with_c_str(|target| { + backend::mount::syscalls::mount( + Some(source), + target, + None, + MountFlagsArg(MountFlags::BIND.bits()), + None, + ) + }) + }) +} + +/// `mount(source, target, NULL, MS_BIND | MS_REC, NULL)` +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html +#[inline] +#[doc(alias = "mount")] +#[doc(alias = "MS_REC")] +pub fn mount_recursive_bind( + source: Source, + target: Target, +) -> io::Result<()> { + source.into_with_c_str(|source| { + target.into_with_c_str(|target| { + backend::mount::syscalls::mount( + Some(source), + target, + None, + MountFlagsArg(MountFlags::BIND.bits() | MountPropagationFlags::REC.bits()), + None, + ) + }) + }) +} + +/// `mount(NULL, target, NULL, mountflags, NULL)` +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html +#[inline] +#[doc(alias = "mount")] +pub fn mount_change( + target: Target, + flags: MountPropagationFlags, +) -> io::Result<()> { + target.into_with_c_str(|target| { + backend::mount::syscalls::mount(None, target, None, MountFlagsArg(flags.bits()), None) + }) +} + +/// `mount(source, target, NULL, MS_MOVE, NULL)` +/// +/// This is not the same as the `move_mount` syscall. If you want to use that, +/// use [`move_mount`] instead. +/// +/// # References +/// - [Linux] +/// +/// [`move_mount`]: crate::mount::move_mount +/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html +#[inline] +#[doc(alias = "mount")] +#[doc(alias = "MS_MOVE")] +pub fn mount_move( + source: Source, + target: Target, +) -> io::Result<()> { + source.into_with_c_str(|source| { + target.into_with_c_str(|target| { + backend::mount::syscalls::mount( + Some(source), + target, + None, + MountFlagsArg(InternalMountFlags::MOVE.bits()), + None, + ) + }) + }) +} + +/// `umount2(target, flags)` +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man2/umount.2.html +#[inline] +#[doc(alias = "umount", alias = "umount2")] +pub fn unmount(target: Target, flags: UnmountFlags) -> io::Result<()> { + target.into_with_c_str(|target| backend::mount::syscalls::unmount(target, flags)) +} -- cgit v1.2.3