remove_dir_all_recursive: treat ELOOP the same as ENOTDIR
This commit is contained in:
parent
8305398d7a
commit
cff3f1e8d5
|
@ -1647,8 +1647,9 @@ mod remove_dir_impl {
|
||||||
fn remove_dir_all_recursive(parent_fd: Option<RawFd>, path: &CStr) -> io::Result<()> {
|
fn remove_dir_all_recursive(parent_fd: Option<RawFd>, path: &CStr) -> io::Result<()> {
|
||||||
// try opening as directory
|
// try opening as directory
|
||||||
let fd = match openat_nofollow_dironly(parent_fd, &path) {
|
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
|
// not a directory - don't traverse further
|
||||||
|
// (for symlinks, older Linux kernels may return ELOOP instead of ENOTDIR)
|
||||||
return match parent_fd {
|
return match parent_fd {
|
||||||
// unlink...
|
// unlink...
|
||||||
Some(parent_fd) => {
|
Some(parent_fd) => {
|
||||||
|
|
Loading…
Reference in a new issue