summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/fs/at.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/fs/at.rs')
-rw-r--r--vendor/rustix/src/fs/at.rs27
1 files changed, 19 insertions, 8 deletions
diff --git a/vendor/rustix/src/fs/at.rs b/vendor/rustix/src/fs/at.rs
index 5bd90fab5..0434b56ef 100644
--- a/vendor/rustix/src/fs/at.rs
+++ b/vendor/rustix/src/fs/at.rs
@@ -3,26 +3,32 @@
//! The `dirfd` argument to these functions may be a file descriptor for a
//! directory, or the special value [`CWD`].
//!
-//! [`cwd`]: crate::fs::cwd::CWD
+//! [`cwd`]: crate::fs::CWD
use crate::fd::OwnedFd;
-use crate::ffi::{CStr, CString};
#[cfg(apple)]
use crate::fs::CloneFlags;
#[cfg(not(any(apple, target_os = "espidf", target_os = "wasi")))]
use crate::fs::FileType;
#[cfg(linux_kernel)]
use crate::fs::RenameFlags;
+#[cfg(not(any(target_os = "aix", target_os = "espidf")))]
+use crate::fs::Stat;
#[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
use crate::fs::{Gid, Uid};
use crate::fs::{Mode, OFlags};
-use crate::path::SMALL_PATH_BUFFER_SIZE;
use crate::{backend, io, path};
-use alloc::vec::Vec;
-use backend::fd::{AsFd, BorrowedFd};
+use backend::fd::AsFd;
+#[cfg(feature = "alloc")]
+use {
+ crate::ffi::{CStr, CString},
+ crate::path::SMALL_PATH_BUFFER_SIZE,
+ alloc::vec::Vec,
+ backend::fd::BorrowedFd,
+};
#[cfg(not(target_os = "espidf"))]
use {
- crate::fs::{Access, AtFlags, Stat, Timestamps},
+ crate::fs::{Access, AtFlags, Timestamps},
crate::timespec::Nsecs,
};
@@ -76,6 +82,7 @@ pub fn openat<P: path::Arg, Fd: AsFd>(
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlinkat.html
/// [Linux]: https://man7.org/linux/man-pages/man2/readlinkat.2.html
+#[cfg(feature = "alloc")]
#[inline]
pub fn readlinkat<P: path::Arg, Fd: AsFd, B: Into<Vec<u8>>>(
dirfd: Fd,
@@ -85,6 +92,7 @@ pub fn readlinkat<P: path::Arg, Fd: AsFd, B: Into<Vec<u8>>>(
path.into_with_c_str(|path| _readlinkat(dirfd.as_fd(), path, reuse.into()))
}
+#[cfg(feature = "alloc")]
#[allow(unsafe_code)]
fn _readlinkat(dirfd: BorrowedFd<'_>, path: &CStr, mut buffer: Vec<u8>) -> io::Result<CString> {
buffer.clear();
@@ -96,8 +104,10 @@ fn _readlinkat(dirfd: BorrowedFd<'_>, path: &CStr, mut buffer: Vec<u8>) -> io::R
debug_assert!(nread <= buffer.capacity());
if nread < buffer.capacity() {
- // SAFETY from the man page:
+ // SAFETY: From the [documentation]:
// "On success, these calls return the number of bytes placed in buf."
+ //
+ // [documentation]: https://man7.org/linux/man-pages/man2/readlinkat.2.html
unsafe {
buffer.set_len(nread);
}
@@ -280,7 +290,8 @@ pub fn symlinkat<P: path::Arg, Q: path::Arg, Fd: AsFd>(
/// [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
-#[cfg(not(target_os = "espidf"))]
+// TODO: Add `stat64xat` to upstream libc bindings and reenable this for AIX.
+#[cfg(not(any(target_os = "aix", target_os = "espidf")))]
#[inline]
#[doc(alias = "fstatat")]
pub fn statat<P: path::Arg, Fd: AsFd>(dirfd: Fd, path: P, flags: AtFlags) -> io::Result<Stat> {