[PATCH v2 7/8] dir.cc: Try unlink_nt first
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue Jan 26 11:46:19 GMT 2021
On Jan 20 17:10, Ben Wijen wrote:
> Speedup deletion of directories.
> ---
> winsup/cygwin/dir.cc | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
> index 7762557d6..470f83aee 100644
> --- a/winsup/cygwin/dir.cc
> +++ b/winsup/cygwin/dir.cc
> @@ -22,6 +22,8 @@ details. */
> #include "cygtls.h"
> #include "tls_pbuf.h"
>
> +extern NTSTATUS unlink_nt (const char *ourname, ULONG eflags);
> +
> extern "C" int
> dirfd (DIR *dir)
> {
> @@ -398,6 +400,14 @@ rmdir (const char *dir)
> if (msdos && p == dir + 1 && isdrive (dir))
> p[1] = '\\';
> }
> + if (has_dot_last_component (dir, false)) {
> + set_errno (EINVAL);
> + __leave;
> + }
> + if (NT_SUCCESS (unlink_nt (dir, FILE_DIRECTORY_FILE))) {
> + res = 0;
> + __leave;
> + }
So what about /dev, /proc, etc?
> if (!(fh = build_fh_name (dir, PC_SYM_NOFOLLOW)))
> __leave; /* errno already set */;
>
> @@ -408,8 +418,6 @@ rmdir (const char *dir)
> }
> else if (!fh->exists ())
> set_errno (ENOENT);
> - else if (has_dot_last_component (dir, false))
> - set_errno (EINVAL);
> else if (!fh->rmdir ())
> res = 0;
> delete fh;
Corinna
More information about the Cygwin-patches
mailing list