Move post-dir unlink check from fhandler_disk_file::rmdir to _unlink_nt --- winsup/cygwin/fhandler_disk_file.cc | 20 -------------------- winsup/cygwin/syscalls.cc | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 885b59161..07f9c513a 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -1852,26 +1852,6 @@ fhandler_disk_file::rmdir () NTSTATUS status = unlink_nt (pc); - /* Check for existence of remote dirs after trying to delete them. - Two reasons: - - Sometimes SMB indicates failure when it really succeeds. - - Removing a directory on a Samba drive using an old Samba version - sometimes doesn't return an error, if the directory can't be removed - because it's not empty. */ - if (isremote ()) - { - OBJECT_ATTRIBUTES attr; - FILE_BASIC_INFORMATION fbi; - NTSTATUS q_status; - - q_status = NtQueryAttributesFile (pc.get_object_attr (attr, sec_none_nih), - &fbi); - if (!NT_SUCCESS (status) && q_status == STATUS_OBJECT_NAME_NOT_FOUND) - status = STATUS_SUCCESS; - else if (pc.fs_is_samba () - && NT_SUCCESS (status) && NT_SUCCESS (q_status)) - status = STATUS_DIRECTORY_NOT_EMPTY; - } if (!NT_SUCCESS (status)) { __seterrno_from_nt_status (status); diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 043ccdb99..f86a93825 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1071,6 +1071,27 @@ out: /* Stop transaction if we started one. */ if (trans) stop_transaction (status, old_trans, trans); + + /* Check for existence of remote dirs after trying to delete them. + Two reasons: + - Sometimes SMB indicates failure when it really succeeds. + - Removing a directory on a Samba drive using an old Samba version + sometimes doesn't return an error, if the directory can't be removed + because it's not empty. */ + if (pc.isdir () && pc.isremote ()) + { + FILE_BASIC_INFORMATION fbi; + NTSTATUS q_status; + + pc.get_object_attr (attr, sec_none_nih); + q_status = NtQueryAttributesFile (&attr, &fbi); + if (!NT_SUCCESS (status) && q_status == STATUS_OBJECT_NAME_NOT_FOUND) + status = STATUS_SUCCESS; + else if (pc.fs_is_samba () + && NT_SUCCESS (status) && NT_SUCCESS (q_status)) + status = STATUS_DIRECTORY_NOT_EMPTY; + } + syscall_printf ("%S, return status = %y", pc.get_nt_native_path (), status); return status; } -- 2.29.2