Skip to content

Commit cb88166

Browse files
hkratzpietroalbini
authored andcommitted
backport missed illumos fix
1 parent 1e17daf commit cb88166

File tree

1 file changed

+26
-17
lines changed
  • library/std/src/sys/unix

1 file changed

+26
-17
lines changed

Diff for: library/std/src/sys/unix/fs.rs

+26-17
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ mod remove_dir_impl {
15821582
// Modern implementation using openat(), unlinkat() and fdopendir()
15831583
#[cfg(not(any(all(target_os = "macos", target_arch = "x86_64"), target_os = "redox")))]
15841584
mod remove_dir_impl {
1585-
use super::{cstr, lstat, Dir, InnerReadDir, ReadDir};
1585+
use super::{cstr, lstat, Dir, DirEntry, InnerReadDir, ReadDir};
15861586
use crate::ffi::CStr;
15871587
use crate::io;
15881588
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd};
@@ -1629,6 +1629,30 @@ mod remove_dir_impl {
16291629
))
16301630
}
16311631

1632+
#[cfg(any(
1633+
target_os = "solaris",
1634+
target_os = "illumos",
1635+
target_os = "haiku",
1636+
target_os = "vxworks"
1637+
))]
1638+
fn is_dir(_ent: &DirEntry) -> Option<bool> {
1639+
None
1640+
}
1641+
1642+
#[cfg(not(any(
1643+
target_os = "solaris",
1644+
target_os = "illumos",
1645+
target_os = "haiku",
1646+
target_os = "vxworks"
1647+
)))]
1648+
fn is_dir(ent: &DirEntry) -> Option<bool> {
1649+
match ent.entry.d_type {
1650+
libc::DT_UNKNOWN => None,
1651+
libc::DT_DIR => Some(true),
1652+
_ => Some(false),
1653+
}
1654+
}
1655+
16321656
fn remove_dir_all_recursive(parent_fd: Option<RawFd>, p: &Path) -> io::Result<()> {
16331657
let pcstr = cstr(p)?;
16341658

@@ -1639,22 +1663,7 @@ mod remove_dir_impl {
16391663
let (dir, fd) = fdreaddir(fd)?;
16401664
for child in dir {
16411665
let child = child?;
1642-
let child_is_dir = if cfg!(any(
1643-
target_os = "solaris",
1644-
target_os = "illumos",
1645-
target_os = "haiku",
1646-
target_os = "vxworks"
1647-
)) {
1648-
// no d_type in dirent
1649-
None
1650-
} else {
1651-
match child.entry.d_type {
1652-
libc::DT_UNKNOWN => None,
1653-
libc::DT_DIR => Some(true),
1654-
_ => Some(false),
1655-
}
1656-
};
1657-
match child_is_dir {
1666+
match is_dir(&child) {
16581667
Some(true) => {
16591668
remove_dir_all_recursive(Some(fd), Path::new(&child.file_name()))?;
16601669
}

0 commit comments

Comments
 (0)