Skip to content

Commit 40ecc41

Browse files
committed
apply rust-lang#96234: remove_dir_all_recursive: treat ELOOP the same as ENOTDIR rust-lang#96234
1 parent e9f2466 commit 40ecc41

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/std/src/sys/unix/fs/dir_fd.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ mod remove_dir_all_xat {
147147
fn open_subdir_or_unlink_non_dir(&self, child_name: &CStr) -> io::Result<Option<Self>> {
148148
let fd = match openat_nofollow_dironly(Some(self.as_fd()), child_name) {
149149
Ok(fd) => fd,
150-
Err(err) if err.raw_os_error() == Some(libc::ENOTDIR) => {
150+
Err(err) if matches!(err.raw_os_error(), Some(libc::ENOTDIR | libc::ELOOP)) => {
151151
// not a directory - unlink and return
152+
// (for symlinks, older Linux kernels may return ELOOP instead of ENOTDIR)
152153
cvt(unsafe { unlinkat(self.as_fd().as_raw_fd(), child_name.as_ptr(), 0) })?;
153154
return Ok(None);
154155
}

0 commit comments

Comments
 (0)