delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/09/09/19:07:55

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
To: Randall R Schulz <rrschulz AT cris DOT com>
Cc: Rick Rankin <rick_rankin AT yahoo DOT com>, John William <jw2357 AT hotmail DOT com>,
cygwin AT cygwin DOT com
Subject: Re: 1.3.2 rmdir fails if CWD is in the directory to be deleted?
References: <F146hlbgwCpsCXsCLMy0000ad06 AT hotmail DOT com>
<5 DOT 1 DOT 0 DOT 14 DOT 2 DOT 20010908074822 DOT 0292ce60 AT pop3 DOT cris DOT com>
From: James Youngman <jay AT gnu DOT org>
Date: 09 Sep 2001 13:29:55 +0100
In-Reply-To: <5.1.0.14.2.20010908074822.0292ce60@pop3.cris.com>
Message-ID: <x6heuc1r98.fsf@no-such-thing-as-a.free-lunch.demon.co.uk>
Lines: 43
User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7
MIME-Version: 1.0

Randall R Schulz <rrschulz AT cris DOT com> writes:

> You should try it. On many Unix systems it will work just
> fine. After the rmdir call, no call that uses a relative file name
> will work, however, since the directory must have been empty to be
> removed and in doing so the .. link would have been removed.
> 
> This applies to "classic" implementations on the Unix file
> system. Chris has pointed out that IRIX does not behave this
> way. Since those details are not part of the API specifications, the
> implementers get to do what they please.

The (POSIX)|(X/Open) spec currenly says (about rmdir()) :-

(38292 ff.)

> The rmdir( ) function shall remove a directory whose name is given
> by path. The directory shall be removed only if it is an empty
> directory.  If the directory is the root directory or the current
> working directory of any process, it is unspecified whether the
> function succeeds, or whether it shall fail and set errno to
> [EBUSY].  If path names a symbolic link, then rmdir( ) shall fail
> and set errno to [ENOTDIR].
> 
> If the directory's link count becomes 0 and no process has the
> directory open, the space occupied by the directory shall be freed
> and the directory shall no longer be accessible. If one or more
> processes have the directory open when the last link is removed, the
> dot and dot-dot entries, if present, shall be removed before rmdir(
> ) returns and no new entries may be created in the directory, but
> the directory shall not be removed until all references to the
> directory are closed.  If the directory is not an empty directory,
> rmdir( ) shall fail and set errno to [EEXIST] or [ENOTEMPTY].

My reading of this is that if you have a directory open by virtue of
it being your working directory, then it is valid for rmdir() to fail.
If however it is open via opendir(), then the rmdir() must succeed.  


-- 
James Youngman
Manchester, UK.  +44 161 226 7339
PGP (GPG) key ID for <jay AT gnu DOT org> is 64A95EE5 (F1B83152).

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019