rmdir: improvement for emptiness check

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Aug 18 14:33:00 GMT 2017


Hi Simon,

On Aug  6 15:57, Simon wrote:
> Dear list,
> 
> when deleting a directory, cygwin checks if the directory is empty.
> When doing so, it skipped every second file found in that directory
> (note the repetition of the line "pfni = ...NextEntryOffset"). This is
> a problem when, e.g., there are two files in that directory and the
> first one is in a PENDING_DELETE state. The second one will not be
> tested, so the directory is considered empty.
> 
> This is not an urgent patch, but fixing this should lower the
> probability of an accidentally, temporarily "deleted" directory (i.e.
> 1. think it is empty; 2. move to recycle bin; 3. check again; 4.
> notice the error and move back to its old location).

Good catch!  Can you create a `git format-patch' style patch
with a nice log message, please?

> NB.: The whole move-to-bin strategy is broken and maybe even
> unfounded. I don't know why cygwin is trying to move an empty
> directory to a recycle.bin folder. The inherent race condition seems
> avoidable to me. Is there a discussion regarding that behaviour?

  $ mkdir dir
  $ cd dir
  $ rmdir ../dir


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20170818/efbeb237/attachment.sig>


More information about the Cygwin-patches mailing list