This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: 1.3.2 rmdir fails if CWD is in the directory to be deleted?


Ok, if this is a fundamental limitation of Windows, I can accept that. But 
there must be a workaround -- after all, DJGPP works. I tried modifying my 
code such that:

rmdir_workaround(dir)
  char *dir;
{
  chdir("/");
  return(rmdir(dir));
}

...and that seems to work just fine.

Yes, it's a cheap hack, but maybe DJGPP does something similar. This code 
will, of course, fail if the program relies on chdir("..") always working, 
so this isn't a complete fix, but it's better than not having the program 
work at all. The "real" fix would probably be to have an internal path, 
separate from the Windows path, so chdir("..") would work and Windows 
wouldn't have to know that the CWD was invalid before the chdir(".."). Just 
a thought.

Anyhow, thanks for the help and info!

- John

>From: Randall R Schulz <rrschulz@cris.com>
>To: "John William" <jw2357@hotmail.com>, cygwin@cygwin.com
>Subject: Re: 1.3.2 rmdir fails if CWD is in the directory to be deleted?
>Date: Fri, 07 Sep 2001 22:06:18 -0700
>
>John,
>
>I'm not sure I'd call it an "issue" since I don't think it's likely ever to
>be "resolved."
>
>This reflects a restriction imposed by Windows that no file system entity
>that is in use (open file, program being executed, directory that is a
>current working directory, etc.) can be deleted.
>
>Unix can accomplish this sort of thing (deletion of in-use file system
>entities) because of the strong distinction and separation between the name
>of a thing (a directory entry) and the thing itself (an inode, whether
>internal or on disk). "Real" Unix systems use internal reference counting
>(multiple levels of it, in fact) to defer actions like the removal of a
>file or directory (inode) independent of the removal of the entity's last
>referencing directory entry (which is the direct consequence of an unlink
>or rmdir call).
>
>Simulating this in Cygwin would presumably require herculean hoop-jumping
>and major slight-of-hand and I tend to doubt the principals would consider
>it worth the effort.
>
>In short, "Cygwin is not Unix" and this is one place where the distinction
>is manifest as a difference in operation.
>
>Randall Schulz
>Mountain View, CA USA
>
>
>At 21:45 2001-09-07, John William wrote:
>>I just installed Cygwin and am having the following problem with rmdir()
>>-- it fails if the CWD is set to the directory to be deleted.
>>
>>main()
>>{
>>  mkdir("test");
>>  rmdir("test"); <-- succeeds
>>
>>  mkdir("test");
>>  chdir("test");
>>  rmdir("test"); <-- fails
>>}
>>
>>This is different than standard UN*X. It appears to me that POSIX only
>>requires that the directory be empty, it doesn't say that the CWD can't be
>>set to the directory to be deleted.
>>
>>Is this a known issue? It is causing problems with some programs I'm
>>trying to compile (they work fine under RH Linux, DJGPP and FreeBSD).
>>Please e-mail any reponses, as I am not subscribed to the mailing list. 
>>Thanks!
>>
>>- John
>


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]