about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorGeoffry Song <goffrie@dropbox.com>2022-04-20 00:46:50 +0000
committerGeoffry Song <goffrie@dropbox.com>2022-04-20 00:50:03 +0000
commitcff3f1e8d52a1bd6340362cbe7689dd6fa4f72e1 (patch)
tree71dac520cc995bc6379365375b5a7700935ade29 /library/std/src
parent8305398d7ae6128811ec2b3223939bcd067530c2 (diff)
downloadrust-cff3f1e8d52a1bd6340362cbe7689dd6fa4f72e1.tar.gz
rust-cff3f1e8d52a1bd6340362cbe7689dd6fa4f72e1.zip
remove_dir_all_recursive: treat ELOOP the same as ENOTDIR
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/unix/fs.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
index 7181451de57..a60b19976ba 100644
--- a/library/std/src/sys/unix/fs.rs
+++ b/library/std/src/sys/unix/fs.rs
@@ -1647,8 +1647,9 @@ mod remove_dir_impl {
     fn remove_dir_all_recursive(parent_fd: Option<RawFd>, path: &CStr) -> io::Result<()> {
         // try opening as directory
         let fd = match openat_nofollow_dironly(parent_fd, &path) {
-            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 - don't traverse further
+                // (for symlinks, older Linux kernels may return ELOOP instead of ENOTDIR)
                 return match parent_fd {
                     // unlink...
                     Some(parent_fd) => {