Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions library/std/src/sys/fs/unix/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Dir {
pub fn self_metadata(&self) -> io::Result<FileAttr> {
// Reuse the implementation for files, which should work for all FDs.
let fd = self.0.as_raw_fd();
let f = core::mem::ManuallyDrop::new(File(
let f = mem::ManuallyDrop::new(File(
// SAFETY: we borrowed `self` so the FD will not be closed while this function runs.
unsafe { FileDesc::from_raw_fd(fd) },
));
Expand Down Expand Up @@ -156,7 +156,22 @@ impl Dir {

pub(super) fn metadata_c(&self, path: &CStr, symlink_nofollow: bool) -> io::Result<FileAttr> {
let fd = self.0.as_raw_fd();
let flag = if symlink_nofollow { libc::AT_SYMLINK_NOFOLLOW } else { 0 };
let flag = if symlink_nofollow {
cfg_select! {
// libc does not have AT_SYMLINK_NOFOLLOW for nuttx.
// FIXME: Once <https://github.com/rust-lang/libc/issues/5599> is fixed,
// nuttx can use the same path as everything else.
target_os = "nuttx" => {
return Err(io::const_error!(
io::ErrorKind::Unsupported,
"getting symlink metadata not supported"
));
}
_ => libc::AT_SYMLINK_NOFOLLOW,
}
} else {
0
};

cfg_has_statx! {
if let Some(ret) = unsafe { super::try_statx(
Expand Down
Loading