Skip to content

Commit cff3f1e

Browse files
committed
remove_dir_all_recursive: treat ELOOP the same as ENOTDIR
1 parent 8305398 commit cff3f1e

File tree

1 file changed

+2
-1
lines changed
  • library/std/src/sys/unix

1 file changed

+2
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1647,8 +1647,9 @@ mod remove_dir_impl {
16471647
fn remove_dir_all_recursive(parent_fd: Option<RawFd>, path: &CStr) -> io::Result<()> {
16481648
// try opening as directory
16491649
let fd = match openat_nofollow_dironly(parent_fd, &path) {
1650-
Err(err) if err.raw_os_error() == Some(libc::ENOTDIR) => {
1650+
Err(err) if matches!(err.raw_os_error(), Some(libc::ENOTDIR | libc::ELOOP)) => {
16511651
// not a directory - don't traverse further
1652+
// (for symlinks, older Linux kernels may return ELOOP instead of ENOTDIR)
16521653
return match parent_fd {
16531654
// unlink...
16541655
Some(parent_fd) => {

0 commit comments

Comments
 (0)