summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/fs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/fs')
-rw-r--r--vendor/rustix/src/fs/abs.rs22
-rw-r--r--vendor/rustix/src/fs/at.rs51
-rw-r--r--vendor/rustix/src/fs/constants.rs4
-rw-r--r--vendor/rustix/src/fs/copy_file_range.rs4
-rw-r--r--vendor/rustix/src/fs/cwd.rs2
-rw-r--r--vendor/rustix/src/fs/dir.rs2
-rw-r--r--vendor/rustix/src/fs/fcntl.rs36
-rw-r--r--vendor/rustix/src/fs/fcntl_apple.rs (renamed from vendor/rustix/src/fs/fcntl_darwin.rs)0
-rw-r--r--vendor/rustix/src/fs/fd.rs57
-rw-r--r--vendor/rustix/src/fs/makedev.rs2
-rw-r--r--vendor/rustix/src/fs/mod.rs187
-rw-r--r--vendor/rustix/src/fs/mount.rs166
-rw-r--r--vendor/rustix/src/fs/raw_dir.rs224
-rw-r--r--vendor/rustix/src/fs/statx.rs122
-rw-r--r--vendor/rustix/src/fs/sync.rs14
15 files changed, 619 insertions, 274 deletions
diff --git a/vendor/rustix/src/fs/abs.rs b/vendor/rustix/src/fs/abs.rs
index a0d6cdecb..cffcf709b 100644
--- a/vendor/rustix/src/fs/abs.rs
+++ b/vendor/rustix/src/fs/abs.rs
@@ -1,21 +1,14 @@
//! POSIX-style filesystem functions which operate on bare paths.
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
use crate::fs::StatFs;
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
use {
crate::fs::StatVfs,
crate::{backend, io, path},
@@ -31,11 +24,10 @@ use {
///
/// [Linux]: https://man7.org/linux/man-pages/man2/statfs.2.html
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
#[inline]
@@ -56,13 +48,7 @@ pub fn statfs<P: path::Arg>(path: P) -> io::Result<StatFs> {
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/statvfs.html
/// [Linux]: https://man7.org/linux/man-pages/man2/statvfs.2.html
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
#[inline]
pub fn statvfs<P: path::Arg>(path: P) -> io::Result<StatVfs> {
path.into_with_c_str(backend::fs::syscalls::statvfs)
diff --git a/vendor/rustix/src/fs/at.rs b/vendor/rustix/src/fs/at.rs
index 925a0aa01..42bc5f807 100644
--- a/vendor/rustix/src/fs/at.rs
+++ b/vendor/rustix/src/fs/at.rs
@@ -7,11 +7,11 @@
use crate::fd::OwnedFd;
use crate::ffi::{CStr, CString};
-#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
+#[cfg(not(solarish))]
use crate::fs::Access;
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
use crate::fs::CloneFlags;
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "wasi")))]
+#[cfg(not(any(apple, target_os = "wasi")))]
use crate::fs::FileType;
#[cfg(any(target_os = "android", target_os = "linux"))]
use crate::fs::RenameFlags;
@@ -30,13 +30,13 @@ pub use backend::fs::types::{Dev, RawMode};
///
/// [`utimensat`]: crate::fs::utimensat
#[cfg(not(target_os = "redox"))]
-pub const UTIME_NOW: Nsecs = backend::fs::types::UTIME_NOW as Nsecs;
+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::fs::types::UTIME_OMIT as Nsecs;
+pub const UTIME_OMIT: Nsecs = backend::c::UTIME_OMIT as Nsecs;
/// `openat(dirfd, path, oflags, mode)`—Opens a file.
///
@@ -222,7 +222,7 @@ pub fn renameat_with<P: path::Arg, Q: path::Arg, PFd: AsFd, QFd: AsFd>(
})
}
-/// `symlinkat(old_dirfd, old_path, new_dirfd, new_path)`—Creates a symlink.
+/// `symlinkat(old_path, new_dirfd, new_path)`—Creates a symlink.
///
/// # References
/// - [POSIX]
@@ -271,7 +271,7 @@ pub fn statat<P: path::Arg, Fd: AsFd>(dirfd: Fd, path: P, flags: AtFlags) -> io:
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/faccessat.html
/// [Linux]: https://man7.org/linux/man-pages/man2/faccessat.2.html
-#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
+#[cfg(not(solarish))]
#[inline]
#[doc(alias = "faccessat")]
pub fn accessat<P: path::Arg, Fd: AsFd>(
@@ -303,11 +303,7 @@ pub fn utimensat<P: path::Arg, Fd: AsFd>(
/// `fchmodat(dirfd, path, mode, 0)`—Sets file or directory permissions.
///
-/// The flags argument is fixed to 0, so `AT_SYMLINK_NOFOLLOW` is not
-/// supported. <details>Platform support for this flag varies widely.</details>
-///
-/// This implementation does not support `O_PATH` file descriptors, even on
-/// platforms where the host libc emulates it.
+/// See `fchmodat_with` for a version that does take flags.
///
/// # References
/// - [POSIX]
@@ -319,7 +315,31 @@ pub fn utimensat<P: path::Arg, Fd: AsFd>(
#[inline]
#[doc(alias = "fchmodat")]
pub fn chmodat<P: path::Arg, Fd: AsFd>(dirfd: Fd, path: P, mode: Mode) -> io::Result<()> {
- path.into_with_c_str(|path| backend::fs::syscalls::chmodat(dirfd.as_fd(), path, mode))
+ 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<P: path::Arg, Fd: AsFd>(
+ 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.
@@ -328,7 +348,7 @@ pub fn chmodat<P: path::Arg, Fd: AsFd>(dirfd: Fd, path: P, mode: Mode) -> io::Re
/// - [Apple]
///
/// [Apple]: https://opensource.apple.com/source/xnu/xnu-3789.21.4/bsd/man/man2/clonefile.2.auto.html
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
#[inline]
pub fn fclonefileat<Fd: AsFd, DstFd: AsFd, P: path::Arg>(
src: Fd,
@@ -349,7 +369,7 @@ pub fn fclonefileat<Fd: AsFd, DstFd: AsFd, P: path::Arg>(
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknodat.html
/// [Linux]: https://man7.org/linux/man-pages/man2/mknodat.2.html
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "wasi")))]
+#[cfg(not(any(apple, target_os = "wasi")))]
#[inline]
pub fn mknodat<P: path::Arg, Fd: AsFd>(
dirfd: Fd,
@@ -374,6 +394,7 @@ pub fn mknodat<P: path::Arg, Fd: AsFd>(
/// [Linux]: https://man7.org/linux/man-pages/man2/fchownat.2.html
#[cfg(not(target_os = "wasi"))]
#[inline]
+#[doc(alias = "fchownat")]
pub fn chownat<P: path::Arg, Fd: AsFd>(
dirfd: Fd,
path: P,
diff --git a/vendor/rustix/src/fs/constants.rs b/vendor/rustix/src/fs/constants.rs
index 11b53fd2a..c8e261e66 100644
--- a/vendor/rustix/src/fs/constants.rs
+++ b/vendor/rustix/src/fs/constants.rs
@@ -8,11 +8,11 @@ pub use backend::fs::types::{Access, Mode, OFlags};
#[cfg(not(target_os = "redox"))]
pub use backend::fs::types::AtFlags;
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub use backend::fs::types::{CloneFlags, CopyfileFlags};
#[cfg(any(target_os = "android", target_os = "linux"))]
-pub use backend::fs::types::{RenameFlags, ResolveFlags};
+pub use backend::fs::types::*;
#[cfg(not(target_os = "redox"))]
pub use backend::fs::types::Dev;
diff --git a/vendor/rustix/src/fs/copy_file_range.rs b/vendor/rustix/src/fs/copy_file_range.rs
index 4b118b30e..b927d572b 100644
--- a/vendor/rustix/src/fs/copy_file_range.rs
+++ b/vendor/rustix/src/fs/copy_file_range.rs
@@ -14,7 +14,7 @@ pub fn copy_file_range<InFd: AsFd, OutFd: AsFd>(
off_in: Option<&mut u64>,
fd_out: OutFd,
off_out: Option<&mut u64>,
- len: u64,
-) -> io::Result<u64> {
+ len: usize,
+) -> io::Result<usize> {
backend::fs::syscalls::copy_file_range(fd_in.as_fd(), off_in, fd_out.as_fd(), off_out, len)
}
diff --git a/vendor/rustix/src/fs/cwd.rs b/vendor/rustix/src/fs/cwd.rs
index d0455cd6c..0abd75df6 100644
--- a/vendor/rustix/src/fs/cwd.rs
+++ b/vendor/rustix/src/fs/cwd.rs
@@ -26,7 +26,7 @@ use backend::fd::{BorrowedFd, RawFd};
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
+ // 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/src/fs/dir.rs b/vendor/rustix/src/fs/dir.rs
index 94bc0a3ee..b3e1e3b99 100644
--- a/vendor/rustix/src/fs/dir.rs
+++ b/vendor/rustix/src/fs/dir.rs
@@ -1,4 +1,4 @@
-//! `Dir` and `Entry`.
+//! `Dir` and `DirEntry`.
use crate::backend;
diff --git a/vendor/rustix/src/fs/fcntl.rs b/vendor/rustix/src/fs/fcntl.rs
index 80ac858c0..0f557ef7f 100644
--- a/vendor/rustix/src/fs/fcntl.rs
+++ b/vendor/rustix/src/fs/fcntl.rs
@@ -3,6 +3,13 @@
//! 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;
@@ -85,3 +92,32 @@ pub use backend::fs::types::SealFlags;
pub fn fcntl_add_seals<Fd: AsFd>(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: AsFd>(fd: Fd, operation: FlockOperation) -> io::Result<()> {
+ backend::fs::syscalls::fcntl_lock(fd.as_fd(), operation)
+}
diff --git a/vendor/rustix/src/fs/fcntl_darwin.rs b/vendor/rustix/src/fs/fcntl_apple.rs
index 6d624ee47..6d624ee47 100644
--- a/vendor/rustix/src/fs/fcntl_darwin.rs
+++ b/vendor/rustix/src/fs/fcntl_apple.rs
diff --git a/vendor/rustix/src/fs/fd.rs b/vendor/rustix/src/fs/fd.rs
index 6bea89547..6ce8410b2 100644
--- a/vendor/rustix/src/fs/fd.rs
+++ b/vendor/rustix/src/fs/fd.rs
@@ -8,39 +8,30 @@ use crate::process::{Gid, Uid};
use crate::{backend, io};
use backend::fd::{AsFd, BorrowedFd};
-#[cfg(not(any(target_os = "solaris", target_os = "wasi")))]
+#[cfg(not(target_os = "wasi"))]
pub use backend::fs::types::FlockOperation;
#[cfg(not(any(
+ netbsdlike,
+ solarish,
target_os = "aix",
target_os = "dragonfly",
- target_os = "illumos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub use backend::fs::types::FallocateFlags;
pub use backend::fs::types::Stat;
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
pub use backend::fs::types::StatFs;
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[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"))]
@@ -68,7 +59,7 @@ pub struct Timestamps {
///
/// [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::fs::types::PROC_SUPER_MAGIC;
+pub const PROC_SUPER_MAGIC: FsWord = backend::c::PROC_SUPER_MAGIC as FsWord;
/// The filesystem magic number for NFS.
///
@@ -76,7 +67,7 @@ pub const PROC_SUPER_MAGIC: FsWord = backend::fs::types::PROC_SUPER_MAGIC;
///
/// [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::fs::types::NFS_SUPER_MAGIC;
+pub const NFS_SUPER_MAGIC: FsWord = backend::c::NFS_SUPER_MAGIC as FsWord;
/// `lseek(fd, offset, whence)`—Repositions a file descriptor within a file.
///
@@ -87,6 +78,7 @@ pub const NFS_SUPER_MAGIC: FsWord = backend::fs::types::NFS_SUPER_MAGIC;
/// [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: AsFd>(fd: Fd, pos: SeekFrom) -> io::Result<u64> {
backend::fs::syscalls::seek(fd.as_fd(), pos)
}
@@ -104,6 +96,7 @@ pub fn seek<Fd: AsFd>(fd: Fd, pos: SeekFrom) -> io::Result<u64> {
/// [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: AsFd>(fd: Fd) -> io::Result<u64> {
backend::fs::syscalls::tell(fd.as_fd())
}
@@ -167,11 +160,10 @@ pub fn fstat<Fd: AsFd>(fd: Fd) -> io::Result<Stat> {
///
/// [Linux]: https://man7.org/linux/man-pages/man2/fstatfs.2.html
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
#[inline]
@@ -193,13 +185,7 @@ pub fn fstatfs<Fd: AsFd>(fd: Fd) -> io::Result<StatFs> {
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatvfs.html
/// [Linux]: https://man7.org/linux/man-pages/man2/fstatvfs.2.html
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
#[inline]
pub fn fstatvfs<Fd: AsFd>(fd: Fd) -> io::Result<StatVfs> {
backend::fs::syscalls::fstatvfs(fd.as_fd())
@@ -234,13 +220,11 @@ pub fn futimens<Fd: AsFd>(fd: Fd, times: &Timestamps) -> io::Result<()> {
/// [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 = "illumos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))] // not implemented in libc for netbsd yet
#[inline]
#[doc(alias = "posix_fallocate")]
@@ -311,10 +295,9 @@ pub fn fsync<Fd: AsFd>(fd: Fd) -> io::Result<()> {
/// [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 = "ios",
- target_os = "macos",
target_os = "redox",
)))]
#[inline]
@@ -346,3 +329,15 @@ pub fn ftruncate<Fd: AsFd>(fd: Fd, length: u64) -> io::Result<()> {
pub fn flock<Fd: AsFd>(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: AsFd>(fd: Fd) -> io::Result<()> {
+ backend::fs::syscalls::syncfs(fd.as_fd())
+}
diff --git a/vendor/rustix/src/fs/makedev.rs b/vendor/rustix/src/fs/makedev.rs
index 5793058ff..36aef6d66 100644
--- a/vendor/rustix/src/fs/makedev.rs
+++ b/vendor/rustix/src/fs/makedev.rs
@@ -18,6 +18,7 @@ pub fn makedev(maj: u32, min: u32) -> Dev {
/// - [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)
@@ -29,6 +30,7 @@ pub fn minor(dev: Dev) -> u32 {
/// - [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/src/fs/mod.rs b/vendor/rustix/src/fs/mod.rs
index fa7f93aec..9588cebe0 100644
--- a/vendor/rustix/src/fs/mod.rs
+++ b/vendor/rustix/src/fs/mod.rs
@@ -11,98 +11,47 @@ mod cwd;
#[cfg(not(target_os = "redox"))]
mod dir;
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
mod fadvise;
pub(crate) mod fcntl;
-#[cfg(any(target_os = "ios", target_os = "macos"))]
-mod fcntl_darwin;
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
+mod fcntl_apple;
+#[cfg(apple)]
mod fcopyfile;
pub(crate) mod fd;
mod file_type;
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
mod getpath;
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[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(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "netbsd",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
-pub use abs::statfs;
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
-pub use abs::statvfs;
-#[cfg(not(any(target_os = "illumos", target_os = "redox", target_os = "solaris")))]
-pub use at::accessat;
-#[cfg(any(target_os = "ios", target_os = "macos"))]
-pub use at::fclonefileat;
-#[cfg(not(any(
- target_os = "ios",
- target_os = "macos",
- target_os = "redox",
- target_os = "wasi",
-)))]
-pub use at::mknodat;
#[cfg(any(target_os = "android", target_os = "linux"))]
-pub use at::renameat_with;
-#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
-pub use at::{chmodat, chownat};
+pub use crate::backend::fs::inotify;
+pub use abs::*;
#[cfg(not(target_os = "redox"))]
-pub use at::{
- linkat, mkdirat, openat, readlinkat, renameat, statat, symlinkat, unlinkat, utimensat, RawMode,
- UTIME_NOW, UTIME_OMIT,
-};
-#[cfg(any(target_os = "ios", target_os = "macos"))]
-pub use constants::CloneFlags;
-/// `copyfile_flags_t`
-#[cfg(any(target_os = "ios", target_os = "macos"))]
-pub use constants::CopyfileFlags;
-#[cfg(any(target_os = "android", target_os = "linux"))]
-pub use constants::RenameFlags;
-#[cfg(any(target_os = "android", target_os = "linux"))]
-pub use constants::ResolveFlags;
-pub use constants::{Access, FdFlags, Mode, Nsecs, OFlags, Secs, Timespec};
-#[cfg(not(target_os = "redox"))]
-pub use constants::{AtFlags, Dev};
+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"))]
@@ -110,101 +59,39 @@ 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 = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub use fadvise::{fadvise, Advice};
-#[cfg(not(target_os = "wasi"))]
-pub use fcntl::fcntl_dupfd_cloexec;
-#[cfg(any(
- target_os = "android",
- target_os = "freebsd",
- target_os = "fuchsia",
- target_os = "linux",
-))]
-pub use fcntl::{fcntl_add_seals, fcntl_get_seals, SealFlags};
-pub use fcntl::{fcntl_getfd, fcntl_getfl, fcntl_setfd, fcntl_setfl};
-#[cfg(any(target_os = "ios", target_os = "macos"))]
-pub use fcntl_darwin::{fcntl_fullfsync, fcntl_rdadvise};
-#[cfg(any(target_os = "ios", target_os = "macos"))]
-pub use fcopyfile::{
- copyfile_state_alloc, copyfile_state_free, copyfile_state_get, copyfile_state_get_copied,
- copyfile_state_t, fcopyfile,
-};
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "redox",
-)))]
-pub use fd::fdatasync;
-#[cfg(not(any(
- target_os = "aix",
- target_os = "dragonfly",
- target_os = "illumos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
-pub use fd::{fallocate, FallocateFlags};
-#[cfg(not(target_os = "wasi"))]
-pub use fd::{fchmod, fchown};
-#[cfg(not(any(target_os = "solaris", target_os = "wasi")))]
-pub use fd::{flock, FlockOperation};
-pub use fd::{fstat, fsync, ftruncate, futimens, is_file_read_write, seek, tell, Stat, Timestamps};
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "netbsd",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
-pub use fd::{fstatfs, StatFs};
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
-pub use fd::{fstatvfs, StatVfs, StatVfsMountFlags};
-#[cfg(any(target_os = "android", target_os = "linux"))]
-pub use fd::{FsWord, NFS_SUPER_MAGIC, PROC_SUPER_MAGIC};
+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(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub use getpath::getpath;
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
-pub use makedev::{major, makedev, minor};
+#[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")]
diff --git a/vendor/rustix/src/fs/mount.rs b/vendor/rustix/src/fs/mount.rs
new file mode 100644
index 000000000..1439b1f32
--- /dev/null
+++ b/vendor/rustix/src/fs/mount.rs
@@ -0,0 +1,166 @@
+//! 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: 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::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: 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::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: path::Arg, Target: path::Arg>(
+ 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: path::Arg, Target: path::Arg>(
+ 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: path::Arg>(
+ 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: path::Arg, Target: path::Arg>(
+ 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: path::Arg>(target: Target, flags: UnmountFlags) -> io::Result<()> {
+ target.into_with_c_str(|target| backend::fs::syscalls::unmount(target, flags))
+}
diff --git a/vendor/rustix/src/fs/raw_dir.rs b/vendor/rustix/src/fs/raw_dir.rs
new file mode 100644
index 000000000..780ff0e89
--- /dev/null
+++ b/vendor/rustix/src/fs/raw_dir.rs
@@ -0,0 +1,224 @@
+//! `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<u8>],
+ 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<u8>]) -> Self {
+ Self {
+ fd,
+ buf: {
+ let offset = buf.as_ptr().align_offset(align_of::<linux_dirent64>());
+ 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<io::Result<RawDirEntry>> {
+ 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::<linux_dirent64>() };
+
+ 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/src/fs/statx.rs b/vendor/rustix/src/fs/statx.rs
index 383f109ce..716c66212 100644
--- a/vendor/rustix/src/fs/statx.rs
+++ b/vendor/rustix/src/fs/statx.rs
@@ -1,13 +1,16 @@
//! Linux `statx`.
-use crate::fd::{AsFd, BorrowedFd};
-use crate::ffi::CStr;
+use crate::fd::AsFd;
use crate::fs::AtFlags;
use crate::{backend, io, path};
-use core::sync::atomic::{AtomicU8, Ordering};
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
@@ -29,63 +32,74 @@ pub fn statx<P: path::Arg, Fd: AsFd>(
path.into_with_c_str(|path| _statx(dirfd.as_fd(), path, flags, mask))
}
-// 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);
+#[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};
-#[inline]
-fn _statx(
- dirfd: BorrowedFd<'_>,
- path: &CStr,
- flags: AtFlags,
- mask: StatxFlags,
-) -> io::Result<Statx> {
- 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),
+ 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<Statx> {
+ 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<Statx> {
- 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. We don't know if `statx` is available yet.
+ fn statx_init(
+ dirfd: BorrowedFd<'_>,
+ path: &CStr,
+ flags: AtFlags,
+ mask: StatxFlags,
+ ) -> io::Result<Statx> {
+ 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> {
- STATX_STATE.store(1, Ordering::Relaxed);
- Err(io::Errno::NOSYS)
-}
+ /// The first `statx` call failed with `NOSYS` (or something we're treating
+ /// like `NOSYS`).
+ #[cold]
+ fn statx_error_nosys() -> io::Result<Statx> {
+ STATX_STATE.store(1, Ordering::Relaxed);
+ Err(io::Errno::NOSYS)
+ }
-/// The first `statx` call failed with `PERM`.
-#[cold]
-fn statx_error_perm() -> io::Result<Statx> {
- // 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()
+ /// The first `statx` call failed with `PERM`.
+ #[cold]
+ fn statx_error_perm() -> io::Result<Statx> {
+ // 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/src/fs/sync.rs b/vendor/rustix/src/fs/sync.rs
new file mode 100644
index 000000000..3d2d08920
--- /dev/null
+++ b/vendor/rustix/src/fs/sync.rs
@@ -0,0 +1,14 @@
+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();
+}