We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e9f2466 commit 40ecc41Copy full SHA for 40ecc41
library/std/src/sys/unix/fs/dir_fd.rs
@@ -147,8 +147,9 @@ mod remove_dir_all_xat {
147
fn open_subdir_or_unlink_non_dir(&self, child_name: &CStr) -> io::Result<Option<Self>> {
148
let fd = match openat_nofollow_dironly(Some(self.as_fd()), child_name) {
149
Ok(fd) => fd,
150
- Err(err) if err.raw_os_error() == Some(libc::ENOTDIR) => {
+ Err(err) if matches!(err.raw_os_error(), Some(libc::ENOTDIR | libc::ELOOP)) => {
151
// not a directory - unlink and return
152
+ // (for symlinks, older Linux kernels may return ELOOP instead of ENOTDIR)
153
cvt(unsafe { unlinkat(self.as_fd().as_raw_fd(), child_name.as_ptr(), 0) })?;
154
return Ok(None);
155
}
0 commit comments