bug in rmdir(2)

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Sep 29 12:58:00 GMT 2005


On Sep 29 06:17, Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> According to Corinna Vinschen on 9/29/2005 1:50 AM:
> >>The fix to rmdir(2) is easy - check for a trailing / or /. or /..
> >>before handing the name off to the complex path processing
> >>code, and fail with EINVAL if so.  rmdir(2) isn't called often
> >>enough for this to slow down everything else, and there are
> >>no Windows API calls in this failure mode, and in return you
> >>get POSIX compliance.
> > 
> > 
> > Just a trailing slash is fine, btw.  Try this on any POSIXy system.
> 
> It is still inconsistent on POSIXy systems - compare Solaris 8 vs. Solaris 10:
> 
> 8> mkdir a
> 8> ln -s a b
> 8> rmdir b/
> rmdir: directory "b/": Path component not a directory
> 
> 10> mkdir a
> 10> ln -s a b
> 10> rmdir b/
> 10> ls ?
> b
> 
> However, I'm not sure in Solaris 8 whether the trailing slash was removed
> by rmdir(1) before calling rmdir(2), or whether rmdir(2) errored out with
> ENOTDIR.  But Solaris 10 certainly removed the referrant directory,
> leaving the symlink dangling.

Try the actual call rmdir(2) and especially read the rmdir entry in SUSv3:
http://www.opengroup.org/onlinepubs/009695399/functions/rmdir.html

There's no text restricting the behaviour in case of "dir/", there's just
this:

  If the path argument refers to a path whose final component is either
  dot or dot-dot, rmdir() shall fail.

On Linux, rmdir(2) consequentially allows removing "dir/".

The "path/.." case is also already covered by returning ENOTEMPTY or
EBUSY, whatever Windows returns.  So there's only the "path/." case
left to check.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list