Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Date: Thu, 29 Sep 2005 14:31:02 +0200
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: bug in rmdir(2)
Message-ID: <20050929123102.GA23334@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <092820052226.6432.433B18B2000A598D0000192022007358340A050E040D0C079D0A@comcast.net> <20050929075025.GA19713@calimero.vinschen.de> <433BDB6D.1010806@byu.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <433BDB6D.1010806@byu.net>
User-Agent: Mutt/1.4.2i

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/

