summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/mount
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/rustix/src/mount
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/mount')
-rw-r--r--vendor/rustix/src/mount/fsopen.rs219
-rw-r--r--vendor/rustix/src/mount/mod.rs19
-rw-r--r--vendor/rustix/src/mount/mount_unmount.rs175
-rw-r--r--vendor/rustix/src/mount/types.rs1
4 files changed, 414 insertions, 0 deletions
diff --git a/vendor/rustix/src/mount/fsopen.rs b/vendor/rustix/src/mount/fsopen.rs
new file mode 100644
index 000000000..581f03782
--- /dev/null
+++ b/vendor/rustix/src/mount/fsopen.rs
@@ -0,0 +1,219 @@
+//! `fsopen` and related functions in Linux's `mount` API.
+
+use crate::backend::mount::types::{
+ FsMountFlags, FsOpenFlags, FsPickFlags, MountAttrFlags, MoveMountFlags, OpenTreeFlags,
+};
+use crate::fd::{BorrowedFd, OwnedFd};
+use crate::{backend, io, path};
+
+/// `fsopen(fs_name, flags)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsopen.md
+#[inline]
+pub fn fsopen<Fs: path::Arg>(fs_name: Fs, flags: FsOpenFlags) -> io::Result<OwnedFd> {
+ fs_name.into_with_c_str(|fs_name| backend::mount::syscalls::fsopen(fs_name, flags))
+}
+
+/// `fsmount(fs_fd, flags, attr_flags)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsmount.md
+#[inline]
+pub fn fsmount(
+ fs_fd: BorrowedFd<'_>,
+ flags: FsMountFlags,
+ attr_flags: MountAttrFlags,
+) -> io::Result<()> {
+ backend::mount::syscalls::fsmount(fs_fd, flags, attr_flags)
+}
+
+/// `move_mount(from_dfd, from_pathname, to_dfd, to_pathname, flags)`
+///
+/// This is not the same as `mount` with the `MS_MOVE` flag. If you want to
+/// use that, use [`mount_move`] instead.
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [`mount_move`]: crate::mount::mount_move
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/move_mount.md
+#[inline]
+pub fn move_mount<From: path::Arg, To: path::Arg>(
+ from_dfd: BorrowedFd<'_>,
+ from_pathname: From,
+ to_dfd: BorrowedFd<'_>,
+ to_pathname: To,
+ flags: MoveMountFlags,
+) -> io::Result<()> {
+ from_pathname.into_with_c_str(|from_pathname| {
+ to_pathname.into_with_c_str(|to_pathname| {
+ backend::mount::syscalls::move_mount(
+ from_dfd,
+ from_pathname,
+ to_dfd,
+ to_pathname,
+ flags,
+ )
+ })
+ })
+}
+
+/// `open_tree(dfd, filename, flags)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/open_tree.md
+#[inline]
+pub fn open_tree<Path: path::Arg>(
+ dfd: BorrowedFd<'_>,
+ filename: Path,
+ flags: OpenTreeFlags,
+) -> io::Result<OwnedFd> {
+ filename.into_with_c_str(|filename| backend::mount::syscalls::open_tree(dfd, filename, flags))
+}
+
+/// `fspick(dfd, path, flags)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fspick.md
+#[inline]
+pub fn fspick<Path: path::Arg>(
+ dfd: BorrowedFd<'_>,
+ path: Path,
+ flags: FsPickFlags,
+) -> io::Result<OwnedFd> {
+ path.into_with_c_str(|path| backend::mount::syscalls::fspick(dfd, path, flags))
+}
+
+/// `fsconfig(fs_fd, FSCONFIG_SET_FLAG, key, NULL, 0)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
+#[inline]
+#[doc(alias = "fsconfig")]
+pub fn fsconfig_set_flag<Key: path::Arg>(fs_fd: BorrowedFd<'_>, key: Key) -> io::Result<()> {
+ key.into_with_c_str(|key| backend::mount::syscalls::fsconfig_set_flag(fs_fd, key))
+}
+
+/// `fsconfig(fs_fd, FSCONFIG_SET_STRING, key, value, 0)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
+#[inline]
+#[doc(alias = "fsconfig")]
+pub fn fsconfig_set_string<Key: path::Arg, Value: path::Arg>(
+ fs_fd: BorrowedFd<'_>,
+ key: Key,
+ value: Value,
+) -> io::Result<()> {
+ key.into_with_c_str(|key| {
+ value.into_with_c_str(|value| {
+ backend::mount::syscalls::fsconfig_set_string(fs_fd, key, value)
+ })
+ })
+}
+
+/// `fsconfig(fs_fd, FSCONFIG_SET_BINARY, key, value, value.len())`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
+#[inline]
+#[doc(alias = "fsconfig")]
+pub fn fsconfig_set_binary<Key: path::Arg>(
+ fs_fd: BorrowedFd<'_>,
+ key: Key,
+ value: &[u8],
+) -> io::Result<()> {
+ key.into_with_c_str(|key| backend::mount::syscalls::fsconfig_set_binary(fs_fd, key, value))
+}
+
+/// `fsconfig(fs_fd, FSCONFIG_SET_PATH, key, path, fd)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
+#[inline]
+#[doc(alias = "fsconfig")]
+pub fn fsconfig_set_path<Key: path::Arg, Path: path::Arg>(
+ fs_fd: BorrowedFd<'_>,
+ key: Key,
+ path: Path,
+ fd: BorrowedFd<'_>,
+) -> io::Result<()> {
+ key.into_with_c_str(|key| {
+ path.into_with_c_str(|path| {
+ backend::mount::syscalls::fsconfig_set_path(fs_fd, key, path, fd)
+ })
+ })
+}
+
+/// `fsconfig(fs_fd, FSCONFIG_SET_PATH_EMPTY, key, "", fd)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
+#[inline]
+#[doc(alias = "fsconfig")]
+pub fn fsconfig_set_path_empty<Key: path::Arg>(
+ fs_fd: BorrowedFd<'_>,
+ key: Key,
+ fd: BorrowedFd<'_>,
+) -> io::Result<()> {
+ key.into_with_c_str(|key| backend::mount::syscalls::fsconfig_set_path_empty(fs_fd, key, fd))
+}
+
+/// `fsconfig(fs_fd, FSCONFIG_SET_FD, key, NULL, fd)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
+#[inline]
+#[doc(alias = "fsconfig")]
+pub fn fsconfig_set_fd<Key: path::Arg>(
+ fs_fd: BorrowedFd<'_>,
+ key: Key,
+ fd: BorrowedFd<'_>,
+) -> io::Result<()> {
+ key.into_with_c_str(|key| backend::mount::syscalls::fsconfig_set_fd(fs_fd, key, fd))
+}
+
+/// `fsconfig(fs_fd, FSCONFIG_CMD_CREATE, key, NULL, 0)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
+#[inline]
+#[doc(alias = "fsconfig")]
+pub fn fsconfig_create(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
+ backend::mount::syscalls::fsconfig_create(fs_fd)
+}
+
+/// `fsconfig(fs_fd, FSCONFIG_CMD_RECONFIGURE, key, NULL, 0)`
+///
+/// # References
+/// - [Unfinished draft]
+///
+/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
+#[inline]
+#[doc(alias = "fsconfig")]
+pub fn fsconfig_reconfigure(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
+ backend::mount::syscalls::fsconfig_reconfigure(fs_fd)
+}
diff --git a/vendor/rustix/src/mount/mod.rs b/vendor/rustix/src/mount/mod.rs
new file mode 100644
index 000000000..9b4f6da51
--- /dev/null
+++ b/vendor/rustix/src/mount/mod.rs
@@ -0,0 +1,19 @@
+//! Linux `mount` API.
+
+// The `mount` module includes the `mount` function and related
+// functions which were originally defined in `rustix::fs` but are
+// now replaced by deprecated aliases. After the next semver bump,
+// we can remove the aliases and all the `#[cfg(feature = "mount")]`
+// here and in src/backend/*/mount.
+//
+// The `fsopen` module includes `fsopen` and related functions.
+
+#[cfg(feature = "mount")]
+mod fsopen;
+mod mount_unmount;
+mod types;
+
+#[cfg(feature = "mount")]
+pub use fsopen::*;
+pub use mount_unmount::*;
+pub use types::*;
diff --git a/vendor/rustix/src/mount/mount_unmount.rs b/vendor/rustix/src/mount/mount_unmount.rs
new file mode 100644
index 000000000..ebb517332
--- /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: path::Arg, Target: path::Arg, Fs: path::Arg, Data: path::Arg>(
+ 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: path::Arg, Data: path::Arg>(
+ 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: path::Arg, Target: path::Arg>(
+ 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: path::Arg, Target: path::Arg>(
+ 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: path::Arg>(
+ 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: path::Arg, Target: path::Arg>(
+ 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: path::Arg>(target: Target, flags: UnmountFlags) -> io::Result<()> {
+ target.into_with_c_str(|target| backend::mount::syscalls::unmount(target, flags))
+}
diff --git a/vendor/rustix/src/mount/types.rs b/vendor/rustix/src/mount/types.rs
new file mode 100644
index 000000000..6096e76d2
--- /dev/null
+++ b/vendor/rustix/src/mount/types.rs
@@ -0,0 +1 @@
+pub use crate::backend::mount::types::*;