Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <433BDB6D.1010806@byu.net> Date: Thu, 29 Sep 2005 06:17:49 -0600 From: Eric Blake User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: bug in rmdir(2) References: <092820052226 DOT 6432 DOT 433B18B2000A598D0000192022007358340A050E040D0C079D0A AT comcast DOT net> <20050929075025 DOT GA19713 AT calimero DOT vinschen DOT de> In-Reply-To: <20050929075025.GA19713@calimero.vinschen.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes -----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. Further discussion on the coreutils list pointed out that POSIX has some holes in this area (a strict reading of "rm -R symlink/", for example, would remove the contents of the referrant directory, then fail with EINVAL, but obviously no system does that - they just remove symlink and leave the referrant directory intact). In light of the misunderstandings in interpreting POSIX, and the various behaviors on different POSIXy platforms, I'm now in the process of asking the Austin group for clarification (with a goal of mandating, or at least allowing, existing behavior, where it is different from a strict reading of the specification). So for now I agree that you only need to check for explicit trailing . or .., and don't worry about trailing / until the next version of POSIX better defines what can/should be done. - -- Life is short - so eat dessert first! Eric Blake ebb9 AT byu DOT net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDO9tt84KuGfSFAYARAmuTAKDQSxOctFpFJW5mukyYCdzIlNy1owCgvsLJ f0wQVl/Go1ToSGYy+TOm4/0= =WY/e -----END PGP SIGNATURE----- -- 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/