Skip to content

Commit

Permalink
apply rust-lang#96234: remove_dir_all_recursive: treat ELOOP the same…
Browse files Browse the repository at this point in the history
… as ENOTDIR rust-lang#96234
  • Loading branch information
hkratz committed Jun 19, 2022
1 parent e9f2466 commit 40ecc41
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/std/src/sys/unix/fs/dir_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ mod remove_dir_all_xat {
fn open_subdir_or_unlink_non_dir(&self, child_name: &CStr) -> io::Result<Option<Self>> {
let fd = match openat_nofollow_dironly(Some(self.as_fd()), child_name) {
Ok(fd) => fd,
Err(err) if err.raw_os_error() == Some(libc::ENOTDIR) => {
Err(err) if matches!(err.raw_os_error(), Some(libc::ENOTDIR | libc::ELOOP)) => {
// not a directory - unlink and return
// (for symlinks, older Linux kernels may return ELOOP instead of ENOTDIR)
cvt(unsafe { unlinkat(self.as_fd().as_raw_fd(), child_name.as_ptr(), 0) })?;
return Ok(None);
}
Expand Down

0 comments on commit 40ecc41

Please sign in to comment.