diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-20 18:26:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-20 18:26:06 +0200 |
| commit | 2443cf2c6a1b850c19e0de2b6fdc7f1ee250a7d0 (patch) | |
| tree | ff4fe74acd18b4d4edb4f21ca5075bcd0d00aeb7 /library/std/src/sys | |
| parent | 41235ef98a01eae0e9ad56e576fcc04d93c43ac0 (diff) | |
| parent | cff3f1e8d52a1bd6340362cbe7689dd6fa4f72e1 (diff) | |
| download | rust-2443cf2c6a1b850c19e0de2b6fdc7f1ee250a7d0.tar.gz rust-2443cf2c6a1b850c19e0de2b6fdc7f1ee250a7d0.zip | |
Rollup merge of #96234 - goffrie:eloop, r=thomcc
remove_dir_all_recursive: treat ELOOP the same as ENOTDIR On older Linux kernels (I tested on 4.4, corresponding to Ubuntu 16.04), opening a symlink using `O_DIRECTORY | O_NOFOLLOW` returns `ELOOP` instead of `ENOTDIR`. We should handle it the same, since a symlink is still not a directory and needs to be `unlink`ed.
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/unix/fs.rs | 3 |
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) => { |
