From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/rustix-0.37.6/src/fs/abs.rs | 55 ---- vendor/rustix-0.37.6/src/fs/at.rs | 408 ------------------------- vendor/rustix-0.37.6/src/fs/constants.rs | 20 -- vendor/rustix-0.37.6/src/fs/copy_file_range.rs | 20 -- vendor/rustix-0.37.6/src/fs/cwd.rs | 32 -- vendor/rustix-0.37.6/src/fs/dir.rs | 5 - vendor/rustix-0.37.6/src/fs/fadvise.rs | 19 -- vendor/rustix-0.37.6/src/fs/fcntl.rs | 123 -------- vendor/rustix-0.37.6/src/fs/fcntl_apple.rs | 24 -- vendor/rustix-0.37.6/src/fs/fcopyfile.rs | 90 ------ vendor/rustix-0.37.6/src/fs/fd.rs | 343 --------------------- vendor/rustix-0.37.6/src/fs/file_type.rs | 4 - vendor/rustix-0.37.6/src/fs/getpath.rs | 14 - vendor/rustix-0.37.6/src/fs/makedev.rs | 37 --- vendor/rustix-0.37.6/src/fs/memfd_create.rs | 15 - vendor/rustix-0.37.6/src/fs/mod.rs | 102 ------- vendor/rustix-0.37.6/src/fs/mount.rs | 166 ---------- vendor/rustix-0.37.6/src/fs/openat2.rs | 23 -- vendor/rustix-0.37.6/src/fs/raw_dir.rs | 224 -------------- vendor/rustix-0.37.6/src/fs/sendfile.rs | 19 -- vendor/rustix-0.37.6/src/fs/statx.rs | 105 ------- vendor/rustix-0.37.6/src/fs/sync.rs | 14 - 22 files changed, 1862 deletions(-) delete mode 100644 vendor/rustix-0.37.6/src/fs/abs.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/at.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/constants.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/copy_file_range.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/cwd.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/dir.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/fadvise.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/fcntl.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/fcntl_apple.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/fcopyfile.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/fd.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/file_type.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/getpath.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/makedev.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/memfd_create.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/mod.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/mount.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/openat2.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/raw_dir.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/sendfile.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/statx.rs delete mode 100644 vendor/rustix-0.37.6/src/fs/sync.rs (limited to 'vendor/rustix-0.37.6/src/fs') diff --git a/vendor/rustix-0.37.6/src/fs/abs.rs b/vendor/rustix-0.37.6/src/fs/abs.rs deleted file mode 100644 index cffcf709b..000000000 --- a/vendor/rustix-0.37.6/src/fs/abs.rs +++ /dev/null @@ -1,55 +0,0 @@ -//! POSIX-style filesystem functions which operate on bare paths. - -#[cfg(not(any( - solarish, - target_os = "haiku", - target_os = "netbsd", - target_os = "redox", - target_os = "wasi", -)))] -use crate::fs::StatFs; -#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))] -use { - crate::fs::StatVfs, - crate::{backend, io, path}, -}; - -/// `statfs`—Queries filesystem metadata. -/// -/// Compared to [`statvfs`], this function often provides more information, -/// though it's less portable. -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/statfs.2.html -#[cfg(not(any( - solarish, - target_os = "haiku", - target_os = "netbsd", - target_os = "redox", - target_os = "wasi", -)))] -#[inline] -pub fn statfs(path: P) -> io::Result { - path.into_with_c_str(backend::fs::syscalls::statfs) -} - -/// `statvfs`—Queries filesystem metadata, POSIX version. -/// -/// Compared to [`statfs`], this function often provides less information, -/// but it is more portable. But even so, filesystems are very diverse and not -/// all the fields are meaningful for every filesystem. And `f_fsid` doesn't -/// seem to have a clear meaning anywhere. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/statvfs.html -/// [Linux]: https://man7.org/linux/man-pages/man2/statvfs.2.html -#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))] -#[inline] -pub fn statvfs(path: P) -> io::Result { - path.into_with_c_str(backend::fs::syscalls::statvfs) -} diff --git a/vendor/rustix-0.37.6/src/fs/at.rs b/vendor/rustix-0.37.6/src/fs/at.rs deleted file mode 100644 index 42bc5f807..000000000 --- a/vendor/rustix-0.37.6/src/fs/at.rs +++ /dev/null @@ -1,408 +0,0 @@ -//! POSIX-style `*at` functions. -//! -//! The `dirfd` argument to these functions may be a file descriptor for a -//! directory, or the special value returned by [`cwd`]. -//! -//! [`cwd`]: crate::fs::cwd - -use crate::fd::OwnedFd; -use crate::ffi::{CStr, CString}; -#[cfg(not(solarish))] -use crate::fs::Access; -#[cfg(apple)] -use crate::fs::CloneFlags; -#[cfg(not(any(apple, target_os = "wasi")))] -use crate::fs::FileType; -#[cfg(any(target_os = "android", target_os = "linux"))] -use crate::fs::RenameFlags; -use crate::fs::{AtFlags, Mode, OFlags, Stat, Timestamps}; -use crate::path::SMALL_PATH_BUFFER_SIZE; -#[cfg(not(target_os = "wasi"))] -use crate::process::{Gid, Uid}; -use crate::{backend, io, path}; -use alloc::vec::Vec; -use backend::fd::{AsFd, BorrowedFd}; -use backend::time::types::Nsecs; - -pub use backend::fs::types::{Dev, RawMode}; - -/// `UTIME_NOW` for use with [`utimensat`]. -/// -/// [`utimensat`]: crate::fs::utimensat -#[cfg(not(target_os = "redox"))] -pub const UTIME_NOW: Nsecs = backend::c::UTIME_NOW as Nsecs; - -/// `UTIME_OMIT` for use with [`utimensat`]. -/// -/// [`utimensat`]: crate::fs::utimensat -#[cfg(not(target_os = "redox"))] -pub const UTIME_OMIT: Nsecs = backend::c::UTIME_OMIT as Nsecs; - -/// `openat(dirfd, path, oflags, mode)`—Opens a file. -/// -/// POSIX guarantees that `openat` will use the lowest unused file descriptor, -/// however it is not safe in general to rely on this, as file descriptors may -/// be unexpectedly allocated on other threads or in libraries. -/// -/// The `Mode` argument is only significant when creating a file. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/openat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/open.2.html -#[inline] -pub fn openat( - dirfd: Fd, - path: P, - oflags: OFlags, - create_mode: Mode, -) -> io::Result { - path.into_with_c_str(|path| { - backend::fs::syscalls::openat(dirfd.as_fd(), path, oflags, create_mode) - }) -} - -/// `readlinkat(fd, path)`—Reads the contents of a symlink. -/// -/// If `reuse` is non-empty, reuse its buffer to store the result if possible. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlinkat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/readlinkat.2.html -#[inline] -pub fn readlinkat>>( - dirfd: Fd, - path: P, - reuse: B, -) -> io::Result { - path.into_with_c_str(|path| _readlinkat(dirfd.as_fd(), path, reuse.into())) -} - -fn _readlinkat(dirfd: BorrowedFd<'_>, path: &CStr, mut buffer: Vec) -> io::Result { - // This code would benefit from having a better way to read into - // uninitialized memory, but that requires `unsafe`. - buffer.clear(); - buffer.reserve(SMALL_PATH_BUFFER_SIZE); - buffer.resize(buffer.capacity(), 0_u8); - - loop { - let nread = backend::fs::syscalls::readlinkat(dirfd.as_fd(), path, &mut buffer)?; - - let nread = nread as usize; - assert!(nread <= buffer.len()); - if nread < buffer.len() { - buffer.resize(nread, 0_u8); - return Ok(CString::new(buffer).unwrap()); - } - buffer.reserve(1); // use `Vec` reallocation strategy to grow capacity exponentially - buffer.resize(buffer.capacity(), 0_u8); - } -} - -/// `mkdirat(fd, path, mode)`—Creates a directory. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdirat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/mkdirat.2.html -#[inline] -pub fn mkdirat(dirfd: Fd, path: P, mode: Mode) -> io::Result<()> { - path.into_with_c_str(|path| backend::fs::syscalls::mkdirat(dirfd.as_fd(), path, mode)) -} - -/// `linkat(old_dirfd, old_path, new_dirfd, new_path, flags)`—Creates a hard -/// link. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/linkat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/linkat.2.html -#[inline] -pub fn linkat( - old_dirfd: PFd, - old_path: P, - new_dirfd: QFd, - new_path: Q, - flags: AtFlags, -) -> io::Result<()> { - old_path.into_with_c_str(|old_path| { - new_path.into_with_c_str(|new_path| { - backend::fs::syscalls::linkat( - old_dirfd.as_fd(), - old_path, - new_dirfd.as_fd(), - new_path, - flags, - ) - }) - }) -} - -/// `unlinkat(fd, path, flags)`—Unlinks a file or remove a directory. -/// -/// With the [`REMOVEDIR`] flag, this removes a directory. This is in place -/// of a `rmdirat` function. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [`REMOVEDIR`]: AtFlags::REMOVEDIR -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/unlinkat.2.html -#[inline] -pub fn unlinkat(dirfd: Fd, path: P, flags: AtFlags) -> io::Result<()> { - path.into_with_c_str(|path| backend::fs::syscalls::unlinkat(dirfd.as_fd(), path, flags)) -} - -/// `renameat(old_dirfd, old_path, new_dirfd, new_path)`—Renames a file or -/// directory. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/renameat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/renameat.2.html -#[inline] -pub fn renameat( - old_dirfd: PFd, - old_path: P, - new_dirfd: QFd, - new_path: Q, -) -> io::Result<()> { - old_path.into_with_c_str(|old_path| { - new_path.into_with_c_str(|new_path| { - backend::fs::syscalls::renameat( - old_dirfd.as_fd(), - old_path, - new_dirfd.as_fd(), - new_path, - ) - }) - }) -} - -/// `renameat2(old_dirfd, old_path, new_dirfd, new_path, flags)`—Renames a -/// file or directory. -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/renameat2.2.html -#[cfg(any(target_os = "android", target_os = "linux"))] -#[inline] -#[doc(alias = "renameat2")] -pub fn renameat_with( - old_dirfd: PFd, - old_path: P, - new_dirfd: QFd, - new_path: Q, - flags: RenameFlags, -) -> io::Result<()> { - old_path.into_with_c_str(|old_path| { - new_path.into_with_c_str(|new_path| { - backend::fs::syscalls::renameat2( - old_dirfd.as_fd(), - old_path, - new_dirfd.as_fd(), - new_path, - flags, - ) - }) - }) -} - -/// `symlinkat(old_path, new_dirfd, new_path)`—Creates a symlink. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/symlinkat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/symlinkat.2.html -#[inline] -pub fn symlinkat( - old_path: P, - new_dirfd: Fd, - new_path: Q, -) -> io::Result<()> { - old_path.into_with_c_str(|old_path| { - new_path.into_with_c_str(|new_path| { - backend::fs::syscalls::symlinkat(old_path, new_dirfd.as_fd(), new_path) - }) - }) -} - -/// `fstatat(dirfd, path, flags)`—Queries metadata for a file or directory. -/// -/// [`Mode::from_raw_mode`] and [`FileType::from_raw_mode`] may be used to -/// interpret the `st_mode` field. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fstatat.2.html -/// [`Mode::from_raw_mode`]: crate::fs::Mode::from_raw_mode -/// [`FileType::from_raw_mode`]: crate::fs::FileType::from_raw_mode -#[inline] -#[doc(alias = "fstatat")] -pub fn statat(dirfd: Fd, path: P, flags: AtFlags) -> io::Result { - path.into_with_c_str(|path| backend::fs::syscalls::statat(dirfd.as_fd(), path, flags)) -} - -/// `faccessat(dirfd, path, access, flags)`—Tests permissions for a file or -/// directory. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/faccessat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/faccessat.2.html -#[cfg(not(solarish))] -#[inline] -#[doc(alias = "faccessat")] -pub fn accessat( - dirfd: Fd, - path: P, - access: Access, - flags: AtFlags, -) -> io::Result<()> { - path.into_with_c_str(|path| backend::fs::syscalls::accessat(dirfd.as_fd(), path, access, flags)) -} - -/// `utimensat(dirfd, path, times, flags)`—Sets file or directory timestamps. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/utimensat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/utimensat.2.html -#[inline] -pub fn utimensat( - dirfd: Fd, - path: P, - times: &Timestamps, - flags: AtFlags, -) -> io::Result<()> { - path.into_with_c_str(|path| backend::fs::syscalls::utimensat(dirfd.as_fd(), path, times, flags)) -} - -/// `fchmodat(dirfd, path, mode, 0)`—Sets file or directory permissions. -/// -/// See `fchmodat_with` for a version that does take flags. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchmodat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fchmodat.2.html -#[cfg(not(target_os = "wasi"))] -#[inline] -#[doc(alias = "fchmodat")] -pub fn chmodat(dirfd: Fd, path: P, mode: Mode) -> io::Result<()> { - chmodat_with(dirfd, path, mode, AtFlags::empty()) -} - -/// `fchmodat(dirfd, path, mode, flags)`—Sets file or directory permissions. -/// -/// Platform support for flags varies widely, for example on Linux -/// [`AtFlags::SYMLINK_NOFOLLOW`] is not implemented and therefore -/// [`io::Errno::OPNOTSUPP`] will be returned. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchmodat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fchmodat.2.html -#[cfg(not(target_os = "wasi"))] -#[inline] -#[doc(alias = "fchmodat_with")] -pub fn chmodat_with( - dirfd: Fd, - path: P, - mode: Mode, - flags: AtFlags, -) -> io::Result<()> { - path.into_with_c_str(|path| backend::fs::syscalls::chmodat(dirfd.as_fd(), path, mode, flags)) -} - -/// `fclonefileat(src, dst_dir, dst, flags)`—Efficiently copies between files. -/// -/// # References -/// - [Apple] -/// -/// [Apple]: https://opensource.apple.com/source/xnu/xnu-3789.21.4/bsd/man/man2/clonefile.2.auto.html -#[cfg(apple)] -#[inline] -pub fn fclonefileat( - src: Fd, - dst_dir: DstFd, - dst: P, - flags: CloneFlags, -) -> io::Result<()> { - dst.into_with_c_str(|dst| { - backend::fs::syscalls::fclonefileat(src.as_fd(), dst_dir.as_fd(), dst, flags) - }) -} - -/// `mknodat(dirfd, path, mode, dev)`—Creates special or normal files. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknodat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/mknodat.2.html -#[cfg(not(any(apple, target_os = "wasi")))] -#[inline] -pub fn mknodat( - dirfd: Fd, - path: P, - file_type: FileType, - mode: Mode, - dev: Dev, -) -> io::Result<()> { - path.into_with_c_str(|path| { - backend::fs::syscalls::mknodat(dirfd.as_fd(), path, file_type, mode, dev) - }) -} - -/// `fchownat(dirfd, path, owner, group, flags)`—Sets file or directory -/// ownership. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchownat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fchownat.2.html -#[cfg(not(target_os = "wasi"))] -#[inline] -#[doc(alias = "fchownat")] -pub fn chownat( - dirfd: Fd, - path: P, - owner: Option, - group: Option, - flags: AtFlags, -) -> io::Result<()> { - path.into_with_c_str(|path| { - backend::fs::syscalls::chownat(dirfd.as_fd(), path, owner, group, flags) - }) -} diff --git a/vendor/rustix-0.37.6/src/fs/constants.rs b/vendor/rustix-0.37.6/src/fs/constants.rs deleted file mode 100644 index c8e261e66..000000000 --- a/vendor/rustix-0.37.6/src/fs/constants.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Filesystem API constants, translated into `bitflags` constants. - -use crate::backend; - -pub use crate::io::FdFlags; -pub use backend::fs::types::{Access, Mode, OFlags}; - -#[cfg(not(target_os = "redox"))] -pub use backend::fs::types::AtFlags; - -#[cfg(apple)] -pub use backend::fs::types::{CloneFlags, CopyfileFlags}; - -#[cfg(any(target_os = "android", target_os = "linux"))] -pub use backend::fs::types::*; - -#[cfg(not(target_os = "redox"))] -pub use backend::fs::types::Dev; - -pub use backend::time::types::{Nsecs, Secs, Timespec}; diff --git a/vendor/rustix-0.37.6/src/fs/copy_file_range.rs b/vendor/rustix-0.37.6/src/fs/copy_file_range.rs deleted file mode 100644 index b927d572b..000000000 --- a/vendor/rustix-0.37.6/src/fs/copy_file_range.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::{backend, io}; -use backend::fd::AsFd; - -/// `copy_file_range(fd_in, off_in, fd_out, off_out, len, 0)`—Copies data -/// from one file to another. -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/copy_file_range.2.html -#[inline] -pub fn copy_file_range( - fd_in: InFd, - off_in: Option<&mut u64>, - fd_out: OutFd, - off_out: Option<&mut u64>, - len: usize, -) -> io::Result { - backend::fs::syscalls::copy_file_range(fd_in.as_fd(), off_in, fd_out.as_fd(), off_out, len) -} diff --git a/vendor/rustix-0.37.6/src/fs/cwd.rs b/vendor/rustix-0.37.6/src/fs/cwd.rs deleted file mode 100644 index 0abd75df6..000000000 --- a/vendor/rustix-0.37.6/src/fs/cwd.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! The `cwd` function, representing the current working directory. -//! -//! # Safety -//! -//! This file uses `AT_FDCWD`, which is a raw file descriptor, but which is -//! always valid. - -#![allow(unsafe_code)] - -use crate::backend; -use backend::fd::{BorrowedFd, RawFd}; - -/// `AT_FDCWD`—Returns a handle representing the current working directory. -/// -/// This returns a file descriptor which refers to the process current -/// directory which can be used as the directory argument in `*at` -/// functions such as [`openat`]. -/// -/// # References -/// - [POSIX] -/// -/// [`openat`]: crate::fs::openat -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html -#[inline] -#[doc(alias = "AT_FDCWD")] -pub const fn cwd() -> BorrowedFd<'static> { - let at_fdcwd = backend::io::types::AT_FDCWD as RawFd; - - // SAFETY: `AT_FDCWD` is a reserved value that is never dynamically - // allocated, so it'll remain valid for the duration of `'static`. - unsafe { BorrowedFd::<'static>::borrow_raw(at_fdcwd) } -} diff --git a/vendor/rustix-0.37.6/src/fs/dir.rs b/vendor/rustix-0.37.6/src/fs/dir.rs deleted file mode 100644 index b3e1e3b99..000000000 --- a/vendor/rustix-0.37.6/src/fs/dir.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! `Dir` and `DirEntry`. - -use crate::backend; - -pub use backend::fs::dir::{Dir, DirEntry}; diff --git a/vendor/rustix-0.37.6/src/fs/fadvise.rs b/vendor/rustix-0.37.6/src/fs/fadvise.rs deleted file mode 100644 index 5bc3a588a..000000000 --- a/vendor/rustix-0.37.6/src/fs/fadvise.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::{backend, io}; -use backend::fd::AsFd; - -pub use backend::fs::types::Advice; - -/// `posix_fadvise(fd, offset, len, advice)`—Declares an expected access -/// pattern for a file. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fadvise.html -/// [Linux]: https://man7.org/linux/man-pages/man2/posix_fadvise.2.html -#[inline] -#[doc(alias = "posix_fadvise")] -pub fn fadvise(fd: Fd, offset: u64, len: u64, advice: Advice) -> io::Result<()> { - backend::fs::syscalls::fadvise(fd.as_fd(), offset, len, advice) -} diff --git a/vendor/rustix-0.37.6/src/fs/fcntl.rs b/vendor/rustix-0.37.6/src/fs/fcntl.rs deleted file mode 100644 index 0f557ef7f..000000000 --- a/vendor/rustix-0.37.6/src/fs/fcntl.rs +++ /dev/null @@ -1,123 +0,0 @@ -//! The Unix `fcntl` function is effectively lots of different functions -//! hidden behind a single dynamic dispatch interface. In order to provide -//! a type-safe API, rustix makes them all separate functions so that they -//! can have dedicated static type signatures. - -#[cfg(not(any( - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", - target_os = "wasi" -)))] -use crate::fs::FlockOperation; -use crate::{backend, io}; -use backend::fd::AsFd; -use backend::fs::types::OFlags; - -// These `fcntl` functions like in the `io` module because they're not specific -// to files, directories, or memfd objects. We re-export them here in the `fs` -// module because the other the `fcntl` functions are here. -#[cfg(not(target_os = "wasi"))] -pub use crate::io::fcntl_dupfd_cloexec; -pub use crate::io::{fcntl_getfd, fcntl_setfd}; - -/// `fcntl(fd, F_GETFL)`—Returns a file descriptor's access mode and status. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fcntl.2.html -#[inline] -#[doc(alias = "F_GETFL")] -pub fn fcntl_getfl(fd: Fd) -> io::Result { - backend::fs::syscalls::fcntl_getfl(fd.as_fd()) -} - -/// `fcntl(fd, F_SETFL, flags)`—Sets a file descriptor's status. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fcntl.2.html -#[inline] -#[doc(alias = "F_SETFL")] -pub fn fcntl_setfl(fd: Fd, flags: OFlags) -> io::Result<()> { - backend::fs::syscalls::fcntl_setfl(fd.as_fd(), flags) -} - -/// `fcntl(fd, F_GET_SEALS)` -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/fcntl.2.html -#[cfg(any( - target_os = "android", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "linux", -))] -#[inline] -#[doc(alias = "F_GET_SEALS")] -pub fn fcntl_get_seals(fd: Fd) -> io::Result { - backend::fs::syscalls::fcntl_get_seals(fd.as_fd()) -} - -#[cfg(any( - target_os = "android", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "linux", -))] -pub use backend::fs::types::SealFlags; - -/// `fcntl(fd, F_ADD_SEALS)` -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/fcntl.2.html -#[cfg(any( - target_os = "android", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "linux", -))] -#[inline] -#[doc(alias = "F_ADD_SEALS")] -pub fn fcntl_add_seals(fd: Fd, seals: SealFlags) -> io::Result<()> { - backend::fs::syscalls::fcntl_add_seals(fd.as_fd(), seals) -} - -/// `fcntl(fd, F_SETLK)`—Acquire or release an `fcntl`-style lock. -/// -/// This function doesn't currently have an offset or len; it currently always -/// sets the `l_len` field to 0, which is a special case that means the entire -/// file should be locked. -/// -/// Unlike `flock`-style locks, `fcntl`-style locks are process-associated, -/// meaning that they don't guard against being acquired by two threads in -/// the same process. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fcntl.2.html -#[cfg(not(any( - target_os = "emscripten", - target_os = "fuchsia", - target_os = "redox", - target_os = "wasi" -)))] -#[inline] -#[doc(alias = "F_SETLK")] -#[doc(alias = "F_SETLKW")] -pub fn fcntl_lock(fd: Fd, operation: FlockOperation) -> io::Result<()> { - backend::fs::syscalls::fcntl_lock(fd.as_fd(), operation) -} diff --git a/vendor/rustix-0.37.6/src/fs/fcntl_apple.rs b/vendor/rustix-0.37.6/src/fs/fcntl_apple.rs deleted file mode 100644 index 6d624ee47..000000000 --- a/vendor/rustix-0.37.6/src/fs/fcntl_apple.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::{backend, io}; -use backend::fd::AsFd; - -/// `fcntl(fd, F_RDADVISE, radvisory { offset, len })` -/// -/// # References -/// - [Apple] -/// -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html -#[inline] -pub fn fcntl_rdadvise(fd: Fd, offset: u64, len: u64) -> io::Result<()> { - backend::fs::syscalls::fcntl_rdadvise(fd.as_fd(), offset, len) -} - -/// `fcntl(fd, F_FULLFSYNC)` -/// -/// # References -/// - [Apple] -/// -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html -#[inline] -pub fn fcntl_fullfsync(fd: Fd) -> io::Result<()> { - backend::fs::syscalls::fcntl_fullfsync(fd.as_fd()) -} diff --git a/vendor/rustix-0.37.6/src/fs/fcopyfile.rs b/vendor/rustix-0.37.6/src/fs/fcopyfile.rs deleted file mode 100644 index d8931733f..000000000 --- a/vendor/rustix-0.37.6/src/fs/fcopyfile.rs +++ /dev/null @@ -1,90 +0,0 @@ -use crate::fs::CopyfileFlags; -use crate::{backend, io}; -use backend::fd::AsFd; - -/// `copyfile_state_t` -pub use backend::fs::types::copyfile_state_t; - -/// `fcopyfile(from, to, state, flags)` -/// -/// # Safety -/// -/// The `state` operand must be allocated with `copyfile_state_alloc` and not -/// yet freed with `copyfile_state_free`. -/// -/// # References -/// - [Apple] -/// -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fcopyfile.3.html -#[inline] -pub unsafe fn fcopyfile( - from: FromFd, - to: ToFd, - state: copyfile_state_t, - flags: CopyfileFlags, -) -> io::Result<()> { - backend::fs::syscalls::fcopyfile(from.as_fd(), to.as_fd(), state, flags) -} - -/// `copyfile_state_alloc()` -/// -/// # References -/// - [Apple] -/// -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fcopyfile.3.html -#[inline] -pub fn copyfile_state_alloc() -> io::Result { - backend::fs::syscalls::copyfile_state_alloc() -} - -/// `copyfile_state_free(state)` -/// -/// # Safety -/// -/// The `state` operand must be allocated with `copyfile_state_alloc` and not -/// yet freed with `copyfile_state_free`. -/// -/// # References -/// - [Apple] -/// -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fcopyfile.3.html -#[inline] -pub unsafe fn copyfile_state_free(state: copyfile_state_t) -> io::Result<()> { - backend::fs::syscalls::copyfile_state_free(state) -} - -/// `copyfile_state_get(state, COPYFILE_STATE_COPIED)` -/// -/// # Safety -/// -/// The `state` operand must be allocated with `copyfile_state_alloc` and not -/// yet freed with `copyfile_state_free`. -/// -/// # References -/// - [Apple] -/// -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fcopyfile.3.html -#[inline] -pub unsafe fn copyfile_state_get_copied(state: copyfile_state_t) -> io::Result { - backend::fs::syscalls::copyfile_state_get_copied(state) -} - -/// `copyfile_state_get(state, flags, dst)` -/// -/// # Safety -/// -/// The `state` operand must be allocated with `copyfile_state_alloc` and not -/// yet freed with `copyfile_state_free`. -/// -/// # References -/// - [Apple] -/// -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fcopyfile.3.html -#[inline] -pub unsafe fn copyfile_state_get( - state: copyfile_state_t, - flag: u32, - dst: *mut core::ffi::c_void, -) -> io::Result<()> { - backend::fs::syscalls::copyfile_state_get(state, flag, dst) -} diff --git a/vendor/rustix-0.37.6/src/fs/fd.rs b/vendor/rustix-0.37.6/src/fs/fd.rs deleted file mode 100644 index 6ce8410b2..000000000 --- a/vendor/rustix-0.37.6/src/fs/fd.rs +++ /dev/null @@ -1,343 +0,0 @@ -//! Functions which operate on file descriptors. - -#[cfg(not(target_os = "wasi"))] -use crate::fs::Mode; -use crate::io::SeekFrom; -#[cfg(not(target_os = "wasi"))] -use crate::process::{Gid, Uid}; -use crate::{backend, io}; -use backend::fd::{AsFd, BorrowedFd}; - -#[cfg(not(target_os = "wasi"))] -pub use backend::fs::types::FlockOperation; - -#[cfg(not(any( - netbsdlike, - solarish, - target_os = "aix", - target_os = "dragonfly", - target_os = "redox", -)))] -pub use backend::fs::types::FallocateFlags; - -pub use backend::fs::types::Stat; - -#[cfg(not(any( - solarish, - target_os = "haiku", - target_os = "netbsd", - target_os = "redox", - target_os = "wasi", -)))] -pub use backend::fs::types::StatFs; - -#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))] -pub use backend::fs::types::{StatVfs, StatVfsMountFlags}; - -#[cfg(any(target_os = "android", target_os = "linux"))] -pub use backend::fs::types::FsWord; - -/// Timestamps used by [`utimensat`] and [`futimens`]. -/// -/// [`utimensat`]: crate::fs::utimensat -/// [`futimens`]: crate::fs::futimens -// This is `repr(C)` and specifically laid out to match the representation used -// by `utimensat` and `futimens`, which expect 2-element arrays of timestamps. -#[repr(C)] -#[derive(Clone, Debug)] -pub struct Timestamps { - /// The timestamp of the last access to a filesystem object. - pub last_access: crate::fs::Timespec, - - /// The timestamp of the last modification of a filesystem object. - pub last_modification: crate::fs::Timespec, -} - -/// The filesystem magic number for procfs. -/// -/// See [the `fstatfs` man page] for more information. -/// -/// [the `fstatfs` man page]: https://man7.org/linux/man-pages/man2/fstatfs.2.html#DESCRIPTION -#[cfg(any(target_os = "android", target_os = "linux"))] -pub const PROC_SUPER_MAGIC: FsWord = backend::c::PROC_SUPER_MAGIC as FsWord; - -/// The filesystem magic number for NFS. -/// -/// See [the `fstatfs` man page] for more information. -/// -/// [the `fstatfs` man page]: https://man7.org/linux/man-pages/man2/fstatfs.2.html#DESCRIPTION -#[cfg(any(target_os = "android", target_os = "linux"))] -pub const NFS_SUPER_MAGIC: FsWord = backend::c::NFS_SUPER_MAGIC as FsWord; - -/// `lseek(fd, offset, whence)`—Repositions a file descriptor within a file. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html -/// [Linux]: https://man7.org/linux/man-pages/man2/lseek.2.html -#[inline] -#[doc(alias = "lseek")] -pub fn seek(fd: Fd, pos: SeekFrom) -> io::Result { - backend::fs::syscalls::seek(fd.as_fd(), pos) -} - -/// `lseek(fd, 0, SEEK_CUR)`—Returns the current position within a file. -/// -/// Return the current position of the file descriptor. This is a subset of -/// the functionality of `seek`, but this interface makes it easier for users -/// to declare their intent not to mutate any state. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html -/// [Linux]: https://man7.org/linux/man-pages/man2/lseek.2.html -#[inline] -#[doc(alias = "lseek")] -pub fn tell(fd: Fd) -> io::Result { - backend::fs::syscalls::tell(fd.as_fd()) -} - -/// `fchmod(fd)`—Sets open file or directory permissions. -/// -/// This implementation does not support `O_PATH` file descriptors, even on -/// platforms where the host libc emulates it. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchmod.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fchmod.2.html -#[cfg(not(target_os = "wasi"))] -#[inline] -pub fn fchmod(fd: Fd, mode: Mode) -> io::Result<()> { - backend::fs::syscalls::fchmod(fd.as_fd(), mode) -} - -/// `fchown(fd)`—Sets open file or directory ownership. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchown.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fchown.2.html -#[cfg(not(target_os = "wasi"))] -#[inline] -pub fn fchown(fd: Fd, owner: Option, group: Option) -> io::Result<()> { - backend::fs::syscalls::fchown(fd.as_fd(), owner, group) -} - -/// `fstat(fd)`—Queries metadata for an open file or directory. -/// -/// [`Mode::from_raw_mode`] and [`FileType::from_raw_mode`] may be used to -/// interpret the `st_mode` field. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstat.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fstat.2.html -/// [`Mode::from_raw_mode`]: crate::fs::Mode::from_raw_mode -/// [`FileType::from_raw_mode`]: crate::fs::FileType::from_raw_mode -#[inline] -pub fn fstat(fd: Fd) -> io::Result { - backend::fs::syscalls::fstat(fd.as_fd()) -} - -/// `fstatfs(fd)`—Queries filesystem statistics for an open file or directory. -/// -/// Compared to [`fstatvfs`], this function often provides more information, -/// though it's less portable. -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/fstatfs.2.html -#[cfg(not(any( - solarish, - target_os = "haiku", - target_os = "netbsd", - target_os = "redox", - target_os = "wasi", -)))] -#[inline] -pub fn fstatfs(fd: Fd) -> io::Result { - backend::fs::syscalls::fstatfs(fd.as_fd()) -} - -/// `fstatvfs(fd)`—Queries filesystem statistics for an open file or -/// directory, POSIX version. -/// -/// Compared to [`fstatfs`], this function often provides less information, -/// but it is more portable. But even so, filesystems are very diverse and not -/// all the fields are meaningful for every filesystem. And `f_fsid` doesn't -/// seem to have a clear meaning anywhere. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatvfs.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fstatvfs.2.html -#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))] -#[inline] -pub fn fstatvfs(fd: Fd) -> io::Result { - backend::fs::syscalls::fstatvfs(fd.as_fd()) -} - -/// `futimens(fd, times)`—Sets timestamps for an open file or directory. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html -/// [Linux]: https://man7.org/linux/man-pages/man2/utimensat.2.html -#[inline] -pub fn futimens(fd: Fd, times: &Timestamps) -> io::Result<()> { - backend::fs::syscalls::futimens(fd.as_fd(), times) -} - -/// `fallocate(fd, mode, offset, len)`—Adjusts file allocation. -/// -/// This is a more general form of `posix_fallocate`, adding a `mode` argument -/// which modifies the behavior. On platforms which only support -/// `posix_fallocate` and not the more general form, no `FallocateFlags` values -/// are defined so it will always be empty. -/// -/// # References -/// - [POSIX] -/// - [Linux `fallocate`] -/// - [Linux `posix_fallocate`] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html -/// [Linux `fallocate`]: https://man7.org/linux/man-pages/man2/fallocate.2.html -/// [Linux `posix_fallocate`]: https://man7.org/linux/man-pages/man3/posix_fallocate.3.html -#[cfg(not(any( - netbsdlike, - solarish, - target_os = "aix", - target_os = "dragonfly", - target_os = "redox", -)))] // not implemented in libc for netbsd yet -#[inline] -#[doc(alias = "posix_fallocate")] -pub fn fallocate(fd: Fd, mode: FallocateFlags, offset: u64, len: u64) -> io::Result<()> { - backend::fs::syscalls::fallocate(fd.as_fd(), mode, offset, len) -} - -/// `fcntl(fd, F_GETFL) & O_ACCMODE` -/// -/// Returns a pair of booleans indicating whether the file descriptor is -/// readable and/or writable, respectively. This is only reliable on files; for -/// example, it doesn't reflect whether sockets have been shut down; for -/// general I/O handle support, use [`io::is_read_write`]. -#[inline] -pub fn is_file_read_write(fd: Fd) -> io::Result<(bool, bool)> { - _is_file_read_write(fd.as_fd()) -} - -pub(crate) fn _is_file_read_write(fd: BorrowedFd<'_>) -> io::Result<(bool, bool)> { - let mode = backend::fs::syscalls::fcntl_getfl(fd)?; - - // Check for `O_PATH`. - #[cfg(any( - target_os = "android", - target_os = "fuchsia", - target_os = "linux", - target_os = "emscripten", - ))] - if mode.contains(crate::fs::OFlags::PATH) { - return Ok((false, false)); - } - - // Use `RWMODE` rather than `ACCMODE` as `ACCMODE` may include `O_PATH`. - // We handled `O_PATH` above. - match mode & crate::fs::OFlags::RWMODE { - crate::fs::OFlags::RDONLY => Ok((true, false)), - crate::fs::OFlags::RDWR => Ok((true, true)), - crate::fs::OFlags::WRONLY => Ok((false, true)), - _ => unreachable!(), - } -} - -/// `fsync(fd)`—Ensures that file data and metadata is written to the -/// underlying storage device. -/// -/// On iOS and macOS this isn't sufficient to ensure that data has reached -/// persistent storage; use [`fcntl_fullfsync`] to ensure that. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fsync.2.html -/// [`fcntl_fullfsync`]: https://docs.rs/rustix/*/x86_64-apple-darwin/rustix/fs/fn.fcntl_fullfsync.html -#[inline] -pub fn fsync(fd: Fd) -> io::Result<()> { - backend::fs::syscalls::fsync(fd.as_fd()) -} - -/// `fdatasync(fd)`—Ensures that file data is written to the underlying -/// storage device. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html -/// [Linux]: https://man7.org/linux/man-pages/man2/fdatasync.2.html -#[cfg(not(any( - apple, - target_os = "dragonfly", - target_os = "haiku", - target_os = "redox", -)))] -#[inline] -pub fn fdatasync(fd: Fd) -> io::Result<()> { - backend::fs::syscalls::fdatasync(fd.as_fd()) -} - -/// `ftruncate(fd, length)`—Sets the length of a file. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html -/// [Linux]: https://man7.org/linux/man-pages/man2/ftruncate.2.html -#[inline] -pub fn ftruncate(fd: Fd, length: u64) -> io::Result<()> { - backend::fs::syscalls::ftruncate(fd.as_fd(), length) -} - -/// `flock(fd, operation)`—Acquire or release an advisory lock on an open file. -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/flock.2.html -#[cfg(not(any(target_os = "solaris", target_os = "wasi")))] -#[inline] -pub fn flock(fd: Fd, operation: FlockOperation) -> io::Result<()> { - backend::fs::syscalls::flock(fd.as_fd(), operation) -} - -/// `syncfs(fd)`—Flush cached filesystem data. -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/syncfs.2.html -#[cfg(any(target_os = "android", target_os = "linux"))] -#[inline] -pub fn syncfs(fd: Fd) -> io::Result<()> { - backend::fs::syscalls::syncfs(fd.as_fd()) -} diff --git a/vendor/rustix-0.37.6/src/fs/file_type.rs b/vendor/rustix-0.37.6/src/fs/file_type.rs deleted file mode 100644 index cf8fc1d38..000000000 --- a/vendor/rustix-0.37.6/src/fs/file_type.rs +++ /dev/null @@ -1,4 +0,0 @@ -use crate::backend; - -/// `S_IF*` constants. -pub use backend::fs::types::FileType; diff --git a/vendor/rustix-0.37.6/src/fs/getpath.rs b/vendor/rustix-0.37.6/src/fs/getpath.rs deleted file mode 100644 index 8e14ff2f2..000000000 --- a/vendor/rustix-0.37.6/src/fs/getpath.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::ffi::CString; -use crate::{backend, io}; -use backend::fd::AsFd; - -/// `fcntl(fd, F_GETPATH)` -/// -/// # References -/// - [Apple] -/// -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html -#[inline] -pub fn getpath(fd: Fd) -> io::Result { - backend::fs::syscalls::getpath(fd.as_fd()) -} diff --git a/vendor/rustix-0.37.6/src/fs/makedev.rs b/vendor/rustix-0.37.6/src/fs/makedev.rs deleted file mode 100644 index 36aef6d66..000000000 --- a/vendor/rustix-0.37.6/src/fs/makedev.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::backend; -use crate::fs::Dev; - -/// `makedev(maj, min)` -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man3/makedev.3.html -#[inline] -pub fn makedev(maj: u32, min: u32) -> Dev { - backend::fs::makedev::makedev(maj, min) -} - -/// `minor(dev)` -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man3/minor.3.html -#[cfg(not(bsd))] -#[inline] -pub fn minor(dev: Dev) -> u32 { - backend::fs::makedev::minor(dev) -} - -/// `major(dev)` -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man3/major.3.html -#[cfg(not(bsd))] -#[inline] -pub fn major(dev: Dev) -> u32 { - backend::fs::makedev::major(dev) -} diff --git a/vendor/rustix-0.37.6/src/fs/memfd_create.rs b/vendor/rustix-0.37.6/src/fs/memfd_create.rs deleted file mode 100644 index dad964777..000000000 --- a/vendor/rustix-0.37.6/src/fs/memfd_create.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::fd::OwnedFd; -use crate::{backend, io, path}; - -pub use backend::fs::types::MemfdFlags; - -/// `memfd_create(path, flags)` -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/memfd_create.2.html -#[inline] -pub fn memfd_create(path: P, flags: MemfdFlags) -> io::Result { - path.into_with_c_str(|path| backend::fs::syscalls::memfd_create(path, flags)) -} diff --git a/vendor/rustix-0.37.6/src/fs/mod.rs b/vendor/rustix-0.37.6/src/fs/mod.rs deleted file mode 100644 index 9588cebe0..000000000 --- a/vendor/rustix-0.37.6/src/fs/mod.rs +++ /dev/null @@ -1,102 +0,0 @@ -//! Filesystem operations. - -mod abs; -#[cfg(not(target_os = "redox"))] -mod at; -mod constants; -#[cfg(any(target_os = "android", target_os = "linux"))] -mod copy_file_range; -#[cfg(not(target_os = "redox"))] -mod cwd; -#[cfg(not(target_os = "redox"))] -mod dir; -#[cfg(not(any( - apple, - netbsdlike, - solarish, - target_os = "dragonfly", - target_os = "haiku", - target_os = "redox", -)))] -mod fadvise; -pub(crate) mod fcntl; -#[cfg(apple)] -mod fcntl_apple; -#[cfg(apple)] -mod fcopyfile; -pub(crate) mod fd; -mod file_type; -#[cfg(apple)] -mod getpath; -#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))] -mod makedev; -#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] -mod memfd_create; -#[cfg(any(target_os = "android", target_os = "linux"))] -mod mount; -#[cfg(any(target_os = "android", target_os = "linux"))] -mod openat2; -#[cfg(any(target_os = "android", target_os = "linux"))] -mod raw_dir; -#[cfg(target_os = "linux")] -mod sendfile; -#[cfg(any(target_os = "android", target_os = "linux"))] -mod statx; -// TODO: Enable `sync` for solarish when upstream is updated. -#[cfg(not(any(solarish, target_os = "redox", target_os = "wasi")))] -mod sync; - -#[cfg(any(target_os = "android", target_os = "linux"))] -pub use crate::backend::fs::inotify; -pub use abs::*; -#[cfg(not(target_os = "redox"))] -pub use at::*; -pub use constants::*; -#[cfg(any(target_os = "android", target_os = "linux"))] -pub use copy_file_range::copy_file_range; -#[cfg(not(target_os = "redox"))] -pub use cwd::cwd; -#[cfg(not(target_os = "redox"))] -pub use dir::{Dir, DirEntry}; -#[cfg(not(any( - apple, - solarish, - netbsdlike, - target_os = "dragonfly", - target_os = "haiku", - target_os = "redox", -)))] -pub use fadvise::{fadvise, Advice}; -pub use fcntl::*; -#[cfg(apple)] -pub use fcntl_apple::{fcntl_fullfsync, fcntl_rdadvise}; -#[cfg(apple)] -pub use fcopyfile::*; -pub use fd::*; -pub use file_type::FileType; -#[cfg(apple)] -pub use getpath::getpath; -#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))] -pub use makedev::*; -#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] -pub use memfd_create::{memfd_create, MemfdFlags}; -#[cfg(any(target_os = "android", target_os = "linux"))] -pub use mount::*; -#[cfg(any(target_os = "android", target_os = "linux"))] -pub use openat2::openat2; -#[cfg(any(target_os = "android", target_os = "linux"))] -pub use raw_dir::{RawDir, RawDirEntry}; -#[cfg(target_os = "linux")] -pub use sendfile::sendfile; -#[cfg(any(target_os = "android", target_os = "linux"))] -pub use statx::{statx, Statx, StatxFlags, StatxTimestamp}; -#[cfg(not(any(solarish, target_os = "redox", target_os = "wasi")))] -pub use sync::sync; - -/// Re-export types common to POSIX-ish platforms. -#[cfg(feature = "std")] -#[cfg(unix)] -pub use std::os::unix::fs::{DirEntryExt, FileExt, FileTypeExt, MetadataExt, OpenOptionsExt}; -#[cfg(feature = "std")] -#[cfg(target_os = "wasi")] -pub use std::os::wasi::fs::{DirEntryExt, FileExt, FileTypeExt, MetadataExt, OpenOptionsExt}; diff --git a/vendor/rustix-0.37.6/src/fs/mount.rs b/vendor/rustix-0.37.6/src/fs/mount.rs deleted file mode 100644 index 1439b1f32..000000000 --- a/vendor/rustix-0.37.6/src/fs/mount.rs +++ /dev/null @@ -1,166 +0,0 @@ -//! Linux `mount`. - -use crate::backend::fs::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::fs::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")] -pub fn remount( - target: Target, - flags: MountFlags, - data: Data, -) -> io::Result<()> { - target.into_with_c_str(|target| { - data.into_with_c_str(|data| { - backend::fs::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")] -pub fn bind_mount( - source: Source, - target: Target, -) -> io::Result<()> { - source.into_with_c_str(|source| { - target.into_with_c_str(|target| { - backend::fs::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")] -pub fn recursive_bind_mount( - source: Source, - target: Target, -) -> io::Result<()> { - source.into_with_c_str(|source| { - target.into_with_c_str(|target| { - backend::fs::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 change_mount( - target: Target, - flags: MountPropagationFlags, -) -> io::Result<()> { - target.into_with_c_str(|target| { - backend::fs::syscalls::mount(None, target, None, MountFlagsArg(flags.bits()), None) - }) -} - -/// `mount(source, target, NULL, MS_MOVE, NULL)` -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html -#[inline] -#[doc(alias = "mount")] -pub fn move_mount( - source: Source, - target: Target, -) -> io::Result<()> { - source.into_with_c_str(|source| { - target.into_with_c_str(|target| { - backend::fs::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 -#[doc(alias = "umount", alias = "umount2")] -pub fn unmount(target: Target, flags: UnmountFlags) -> io::Result<()> { - target.into_with_c_str(|target| backend::fs::syscalls::unmount(target, flags)) -} diff --git a/vendor/rustix-0.37.6/src/fs/openat2.rs b/vendor/rustix-0.37.6/src/fs/openat2.rs deleted file mode 100644 index 4918e0034..000000000 --- a/vendor/rustix-0.37.6/src/fs/openat2.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::fd::OwnedFd; -use crate::{backend, io, path}; -use backend::fd::AsFd; -use backend::fs::types::{Mode, OFlags, ResolveFlags}; - -/// `openat2(dirfd, path, OpenHow { oflags, mode, resolve }, sizeof(OpenHow))` -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/openat2.2.html -#[inline] -pub fn openat2( - dirfd: Fd, - path: P, - oflags: OFlags, - mode: Mode, - resolve: ResolveFlags, -) -> io::Result { - path.into_with_c_str(|path| { - backend::fs::syscalls::openat2(dirfd.as_fd(), path, oflags, mode, resolve) - }) -} diff --git a/vendor/rustix-0.37.6/src/fs/raw_dir.rs b/vendor/rustix-0.37.6/src/fs/raw_dir.rs deleted file mode 100644 index 780ff0e89..000000000 --- a/vendor/rustix-0.37.6/src/fs/raw_dir.rs +++ /dev/null @@ -1,224 +0,0 @@ -//! `RawDir` and `RawDirEntry`. - -use core::fmt; -use core::mem::{align_of, MaybeUninit}; -use linux_raw_sys::general::linux_dirent64; - -use crate::backend::fs::syscalls::getdents_uninit; -use crate::fd::AsFd; -use crate::ffi::CStr; -use crate::fs::FileType; -use crate::io; - -/// A directory iterator implemented with getdents. -/// -/// Note: This implementation does not handle growing the buffer. If this -/// functionality is necessary, you'll need to drop the current iterator, -/// resize the buffer, and then re-create the iterator. The iterator is -/// guaranteed to continue where it left off provided the file descriptor isn't -/// changed. See the example in [`RawDir::new`]. -pub struct RawDir<'buf, Fd: AsFd> { - fd: Fd, - buf: &'buf mut [MaybeUninit], - initialized: usize, - offset: usize, -} - -impl<'buf, Fd: AsFd> RawDir<'buf, Fd> { - /// Create a new iterator from the given file descriptor and buffer. - /// - /// Note: the buffer size may be trimmed to accommodate alignment - /// requirements. - /// - /// # Examples - /// - /// ## Simple but non-portable - /// - /// These examples are non-portable, because file systems may not have a - /// maximum file name length. If you can make assumptions that bound - /// this length, then these examples may suffice. - /// - /// Using the heap: - /// - /// ```notrust - /// # // The `notrust` above can be removed when we can depend on Rust 1.60. - /// # use std::mem::MaybeUninit; - /// # use rustix::fs::{cwd, Mode, OFlags, openat, RawDir}; - /// - /// let fd = openat(cwd(), ".", OFlags::RDONLY | OFlags::DIRECTORY, Mode::empty()).unwrap(); - /// - /// let mut buf = Vec::with_capacity(8192); - /// let mut iter = RawDir::new(fd, buf.spare_capacity_mut()); - /// while let Some(entry) = iter.next() { - /// let entry = entry.unwrap(); - /// dbg!(&entry); - /// } - /// ``` - /// - /// Using the stack: - /// - /// ``` - /// # use std::mem::MaybeUninit; - /// # use rustix::fs::{cwd, Mode, OFlags, openat, RawDir}; - /// - /// let fd = openat( - /// cwd(), - /// ".", - /// OFlags::RDONLY | OFlags::DIRECTORY, - /// Mode::empty(), - /// ) - /// .unwrap(); - /// - /// let mut buf = [MaybeUninit::uninit(); 2048]; - /// let mut iter = RawDir::new(fd, &mut buf); - /// while let Some(entry) = iter.next() { - /// let entry = entry.unwrap(); - /// dbg!(&entry); - /// } - /// ``` - /// - /// ## Portable - /// - /// Heap allocated growing buffer for supporting directory entries with - /// arbitrarily large file names: - /// - /// ```notrust - /// # // The `notrust` above can be removed when we can depend on Rust 1.60. - /// # use std::mem::MaybeUninit; - /// # use rustix::fs::{cwd, Mode, OFlags, openat, RawDir}; - /// # use rustix::io::Errno; - /// - /// let fd = openat(cwd(), ".", OFlags::RDONLY | OFlags::DIRECTORY, Mode::empty()).unwrap(); - /// - /// let mut buf = Vec::with_capacity(8192); - /// 'read: loop { - /// 'resize: { - /// let mut iter = RawDir::new(&fd, buf.spare_capacity_mut()); - /// while let Some(entry) = iter.next() { - /// let entry = match entry { - /// Err(Errno::INVAL) => break 'resize, - /// r => r.unwrap(), - /// }; - /// dbg!(&entry); - /// } - /// break 'read; - /// } - /// - /// let new_capacity = buf.capacity() * 2; - /// buf.reserve(new_capacity); - /// } - /// ``` - pub fn new(fd: Fd, buf: &'buf mut [MaybeUninit]) -> Self { - Self { - fd, - buf: { - let offset = buf.as_ptr().align_offset(align_of::()); - if offset < buf.len() { - &mut buf[offset..] - } else { - &mut [] - } - }, - initialized: 0, - offset: 0, - } - } -} - -/// A raw directory entry, similar to `std::fs::DirEntry`. -/// -/// Note that unlike the std version, this may represent the `.` or `..` -/// entries. -pub struct RawDirEntry<'a> { - file_name: &'a CStr, - file_type: u8, - inode_number: u64, - next_entry_cookie: i64, -} - -impl<'a> fmt::Debug for RawDirEntry<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut f = f.debug_struct("RawDirEntry"); - f.field("file_name", &self.file_name()); - f.field("file_type", &self.file_type()); - f.field("ino", &self.ino()); - f.field("next_entry_cookie", &self.next_entry_cookie()); - f.finish() - } -} - -impl<'a> RawDirEntry<'a> { - /// Returns the file name of this directory entry. - #[inline] - pub fn file_name(&self) -> &CStr { - self.file_name - } - - /// Returns the type of this directory entry. - #[inline] - pub fn file_type(&self) -> FileType { - FileType::from_dirent_d_type(self.file_type) - } - - /// Returns the inode number of this directory entry. - #[inline] - #[doc(alias = "inode_number")] - pub fn ino(&self) -> u64 { - self.inode_number - } - - /// Returns the seek cookie to the next directory entry. - #[inline] - #[doc(alias = "off")] - pub fn next_entry_cookie(&self) -> u64 { - self.next_entry_cookie as u64 - } -} - -impl<'buf, Fd: AsFd> RawDir<'buf, Fd> { - /// Identical to [Iterator::next] except that [Iterator::Item] borrows from - /// self. - /// - /// Note: this interface will be broken to implement a stdlib iterator API - /// with GAT support once one becomes available. - #[allow(unsafe_code)] - #[allow(clippy::should_implement_trait)] - pub fn next(&mut self) -> Option> { - if self.is_buffer_empty() { - match getdents_uninit(self.fd.as_fd(), self.buf) { - Ok(bytes_read) if bytes_read == 0 => return None, - Ok(bytes_read) => { - self.initialized = bytes_read; - self.offset = 0; - } - Err(e) => return Some(Err(e)), - } - } - - let dirent_ptr = self.buf[self.offset..].as_ptr(); - // SAFETY: - // - This data is initialized by the check above. - // - Assumption: the kernel will not give us partial structs. - // - Assumption: the kernel uses proper alignment between structs. - // - The starting pointer is aligned (performed in RawDir::new) - let dirent = unsafe { &*dirent_ptr.cast::() }; - - self.offset += usize::from(dirent.d_reclen); - - Some(Ok(RawDirEntry { - file_type: dirent.d_type, - inode_number: dirent.d_ino.into(), - next_entry_cookie: dirent.d_off.into(), - // SAFETY: the kernel guarantees a NUL terminated string. - file_name: unsafe { CStr::from_ptr(dirent.d_name.as_ptr().cast()) }, - })) - } - - /// Returns true if the internal buffer is empty and will be refilled when - /// calling [`next`]. - /// - /// [`next`]: Self::next - pub fn is_buffer_empty(&self) -> bool { - self.offset >= self.initialized - } -} diff --git a/vendor/rustix-0.37.6/src/fs/sendfile.rs b/vendor/rustix-0.37.6/src/fs/sendfile.rs deleted file mode 100644 index 472ad37b2..000000000 --- a/vendor/rustix-0.37.6/src/fs/sendfile.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::{backend, io}; -use backend::fd::AsFd; - -/// `sendfile(out_fd, in_fd, offset, count)` -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/sendfile.2.html -#[cfg(any(target_os = "android", target_os = "linux"))] -#[inline] -pub fn sendfile( - out_fd: OutFd, - in_fd: InFd, - offset: Option<&mut u64>, - count: usize, -) -> io::Result { - backend::fs::syscalls::sendfile(out_fd.as_fd(), in_fd.as_fd(), offset, count) -} diff --git a/vendor/rustix-0.37.6/src/fs/statx.rs b/vendor/rustix-0.37.6/src/fs/statx.rs deleted file mode 100644 index 716c66212..000000000 --- a/vendor/rustix-0.37.6/src/fs/statx.rs +++ /dev/null @@ -1,105 +0,0 @@ -//! Linux `statx`. - -use crate::fd::AsFd; -use crate::fs::AtFlags; -use crate::{backend, io, path}; - -pub use backend::fs::types::{Statx, StatxFlags, StatxTimestamp}; - -#[cfg(feature = "linux_4_11")] -use backend::fs::syscalls::statx as _statx; -#[cfg(not(feature = "linux_4_11"))] -use compat::statx as _statx; - -/// `statx(dirfd, path, flags, mask, statxbuf)` -/// -/// This function returns [`io::Errno::NOSYS`] if `statx` is not available on -/// the platform, such as Linux before 4.11. This also includes older Docker -/// versions where the actual syscall fails with different error codes; Rustix -/// handles this and translates them into `NOSYS`. -/// -/// # References -/// - [Linux] -/// -/// [Linux]: https://man7.org/linux/man-pages/man2/statx.2.html -#[inline] -pub fn statx( - dirfd: Fd, - path: P, - flags: AtFlags, - mask: StatxFlags, -) -> io::Result { - path.into_with_c_str(|path| _statx(dirfd.as_fd(), path, flags, mask)) -} - -#[cfg(not(feature = "linux_4_11"))] -mod compat { - use crate::fd::BorrowedFd; - use crate::ffi::CStr; - use crate::fs::AtFlags; - use crate::{backend, io}; - use core::sync::atomic::{AtomicU8, Ordering}; - - use backend::fs::types::{Statx, StatxFlags}; - - // Linux kernel prior to 4.11 old versions of Docker don't support `statx`. We - // store the availability in a global to avoid unnecessary syscalls. - // - // 0: Unknown - // 1: Not available - // 2: Available - static STATX_STATE: AtomicU8 = AtomicU8::new(0); - - #[inline] - pub fn statx( - dirfd: BorrowedFd<'_>, - path: &CStr, - flags: AtFlags, - mask: StatxFlags, - ) -> io::Result { - match STATX_STATE.load(Ordering::Relaxed) { - 0 => statx_init(dirfd, path, flags, mask), - 1 => Err(io::Errno::NOSYS), - _ => backend::fs::syscalls::statx(dirfd, path, flags, mask), - } - } - - /// The first `statx` call. We don't know if `statx` is available yet. - fn statx_init( - dirfd: BorrowedFd<'_>, - path: &CStr, - flags: AtFlags, - mask: StatxFlags, - ) -> io::Result { - match backend::fs::syscalls::statx(dirfd, path, flags, mask) { - Err(io::Errno::NOSYS) => statx_error_nosys(), - Err(io::Errno::PERM) => statx_error_perm(), - result => { - STATX_STATE.store(2, Ordering::Relaxed); - result - } - } - } - - /// The first `statx` call failed with `NOSYS` (or something we're treating - /// like `NOSYS`). - #[cold] - fn statx_error_nosys() -> io::Result { - STATX_STATE.store(1, Ordering::Relaxed); - Err(io::Errno::NOSYS) - } - - /// The first `statx` call failed with `PERM`. - #[cold] - fn statx_error_perm() -> io::Result { - // Some old versions of Docker have `statx` fail with `PERM` when it isn't - // recognized. Check whether `statx` really is available, and if so, fail - // with `PERM`, and if not, treat it like `NOSYS`. - if backend::fs::syscalls::is_statx_available() { - STATX_STATE.store(2, Ordering::Relaxed); - Err(io::Errno::PERM) - } else { - statx_error_nosys() - } - } -} diff --git a/vendor/rustix-0.37.6/src/fs/sync.rs b/vendor/rustix-0.37.6/src/fs/sync.rs deleted file mode 100644 index 3d2d08920..000000000 --- a/vendor/rustix-0.37.6/src/fs/sync.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::backend; - -/// `sync`—Flush cached filesystem data for all filesystems. -/// -/// # References -/// - [POSIX] -/// - [Linux] -/// -/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/sync.html -/// [Linux]: https://man7.org/linux/man-pages/man2/sync.2.html -#[inline] -pub fn sync() { - backend::fs::syscalls::sync(); -} -- cgit v1.2.3