public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Unable to delete directory in Cygwin
       [not found] <1F211FE03383644EAA6BB7A52FCD9B9B0927A0@sohm.kpit.com>
@ 2006-06-15 10:15 ` Gina Verlekar
  2006-06-15 13:19   ` Eric Blake
  2006-06-15 15:40   ` Thorsten Kampe
  0 siblings, 2 replies; 19+ messages in thread
From: Gina Verlekar @ 2006-06-15 10:15 UTC (permalink / raw)
  To: cygwin


Hi,

I have implemented some changes in the linker code for some intermediate

processing. 
For that I need to create a temporary directory, generate some
intermediate 
files in it, process those files by calling a function. After processing
of the	
intermediate files, I delete the intermediate files and the temporary
directory.	
While this logic works fine in the linux, the temporary directory does
not get	
deleted in cygwin.

/* ldmain.c */
main()
{
.
.
my_function();
.
.
delete tmp_directory;//I have to delete the tmp_directory only here 
}


/* myfile.c */
my_function()
{
create tmp directory tmp_directory;
.
create intermediate files in the above directory; .
my_process_function(intermediate files);//processes the intermediate
files .
return;
}



my_process_function(files)
{
.
process the intermediate files;
.
delete the intermediate files;// I cannot delete the tmp_directory here
return; 
}



After debugging using gdb, I found that in cygwin, the intermediate
files still 
had some handlers open for it inspite of reaching till the end of the
main() 
function in linker. Due to this, the temporary files get deleted only
after 
exiting from the main. Hence as the temporary drectory is not empty till
then,
it cannot get deleted.

This behaviour is not seen in linux. Care has been taken in the code for
correct
opening and closing of the intermediate files.

Is this a known behavior in cygwin? Any inputs will be appreciated. 

Regards,
Gina Verlekar
KPIT Cummins InfoSystems Ltd.
Pune, India
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Free download of GNU based tool-chains for Renesas' SH, H8, R8C, M16C
and M32C Series.
The following site also offers free technical support to its users. 
Visit http://www.kpitgnutools.com for details. 
Latest versions of KPIT GNU tools were released on June 1, 2006.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-15 10:15 ` Unable to delete directory in Cygwin Gina Verlekar
@ 2006-06-15 13:19   ` Eric Blake
  2006-06-19 15:07     ` mwoehlke
  2006-06-15 15:40   ` Thorsten Kampe
  1 sibling, 1 reply; 19+ messages in thread
From: Eric Blake @ 2006-06-15 13:19 UTC (permalink / raw)
  To: cygwin, GinaV

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Gina Verlekar on 6/15/2006 3:53 AM:
> Hi,
> 
> I have implemented some changes in the linker code for some intermediate
> 
> processing. 
> For that I need to create a temporary directory, generate some
> intermediate 
> files in it, process those files by calling a function. After processing
> of the	
> intermediate files, I delete the intermediate files and the temporary
> directory.	
> While this logic works fine in the linux, the temporary directory does
> not get	
> deleted in cygwin.

Windows is not Linux, and will not allow users to delete in-use
directories (where a directory is considered in-use if it contains files,
or if any process is using that directory as its current working
directory), nor the clean deletion of files that are still open.  POSIX
allows this behavior, and cygwin cannot change Window's implementation of
deletion semantics.  Just because Linux behaves nicer doesn't mean that it
is portable to remove in-use directories.  Fix your code to first close
all outstanding file handles before trying to remove the files, and then
the directory.

That said, cygwin does try to emulate linux, and if someone were to
contribute a patch that would allow cygwin to emulate directory deletion
if it knows that all open handles have also been scheduled for unlinking
at process end, then http://cygwin.com/acronyms/#PTC.

> 
> /* ldmain.c */
> main()
> {
> .
> .
> my_function();
> .
> .
> delete tmp_directory;//I have to delete the tmp_directory only here 
> }

pseudocode like this is worthless when asking for help.  Post a simple,
self-contained, compiling testcase if you want more help.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEkVYs84KuGfSFAYARAuREAJ9EnUBagCb2fXjvJ0y77GKkF+ZXCgCfdo4Y
l0H2f8Bd6sxUSEQ5mglS8Tw=
=YWk6
-----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/

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-15 10:15 ` Unable to delete directory in Cygwin Gina Verlekar
  2006-06-15 13:19   ` Eric Blake
@ 2006-06-15 15:40   ` Thorsten Kampe
  2006-06-16 11:36     ` Brett Serkez
  1 sibling, 1 reply; 19+ messages in thread
From: Thorsten Kampe @ 2006-06-15 15:40 UTC (permalink / raw)
  To: cygwin

* Gina Verlekar (2006-06-15 10:53 +0000)
> I have implemented some changes in the linker code for some intermediate
> processing. 
> For that I need to create a temporary directory, generate some
> intermediate 
> files in it, process those files by calling a function. After processing
> of the	
> intermediate files, I delete the intermediate files and the temporary
> directory.	
> While this logic works fine in the linux, the temporary directory does
> not get	
> deleted in cygwin.
> [...]
> After debugging using gdb, I found that in cygwin, the intermediate
> files still 
> had some handlers open for it inspite of reaching till the end of the
> main() 
> function in linker. Due to this, the temporary files get deleted only
> after 
> exiting from the main. Hence as the temporary drectory is not empty till
> then,
> it cannot get deleted.
> 
> This behaviour is not seen in linux. Care has been taken in the code for
> correct
> opening and closing of the intermediate files.
> 
> Is this a known behavior in cygwin? Any inputs will be appreciated. 

mkdir test && cd test && rmdir ../test
does work in Linux but not under Windows and therefor not under
Cygwin.

Cygwin can't break Windows rules. Under Linux you can name a file c:,
under Windows and under Cygwin not.


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-15 15:40   ` Thorsten Kampe
@ 2006-06-16 11:36     ` Brett Serkez
  2006-06-16 12:28       ` Christopher Faylor
  0 siblings, 1 reply; 19+ messages in thread
From: Brett Serkez @ 2006-06-16 11:36 UTC (permalink / raw)
  To: cygwin

<snip>
> mkdir test && cd test && rmdir ../test
> does work in Linux but not under Windows and therefor not under
> Cygwin.

This works under Linux/UNIX as the rmdir removes the directory entry,
disassociating it from the inode, the files still exist as the OS is
using the inode as the handle.  When this disassociation from the
inode occurs, the link count in the inode is decremented.  When the
files and directory finally close, the OS sees that the link count is
zero and physically deletes the directory and files.

This notion of an inode and directory entry pointing to the inode is
what allows hardlinks in Linux/UNIX.  The notion of deleting the
directory entry while a file is still open is a long used trick to
make sure that temporary files are never accidentally reopened
unintentionally and insures deletion (zero link count) should the
process or OS crash.

> Cygwin can't break Windows rules. Under Linux you can name a file c:,
> under Windows and under Cygwin not.

NTFS and FAT file systems simply do not have the concept of inodes,
Cygwin is dependent upon the facilities supplied by these file
systems.

Brett

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-16 11:36     ` Brett Serkez
@ 2006-06-16 12:28       ` Christopher Faylor
  2006-06-16 12:37         ` Brett Serkez
  0 siblings, 1 reply; 19+ messages in thread
From: Christopher Faylor @ 2006-06-16 12:28 UTC (permalink / raw)
  To: cygwin

On Fri, Jun 16, 2006 at 07:35:27AM -0400, Brett Serkez wrote:
>NTFS and FAT file systems simply do not have the concept of inodes,
>Cygwin is dependent upon the facilities supplied by these file systems.

Actually NTFS does have something like an inode.  That's what Cygwin
uses.

cgf

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-16 12:28       ` Christopher Faylor
@ 2006-06-16 12:37         ` Brett Serkez
  2006-06-16 12:48           ` Christopher Faylor
  0 siblings, 1 reply; 19+ messages in thread
From: Brett Serkez @ 2006-06-16 12:37 UTC (permalink / raw)
  To: cygwin

> >NTFS and FAT file systems simply do not have the concept of inodes,
> >Cygwin is dependent upon the facilities supplied by these file systems.
>
> Actually NTFS does have something like an inode.  That's what Cygwin
> uses.

Then why does this fail?  Please enlighten us?

Brett

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-16 12:37         ` Brett Serkez
@ 2006-06-16 12:48           ` Christopher Faylor
  2006-06-16 13:01             ` Brett Serkez
  0 siblings, 1 reply; 19+ messages in thread
From: Christopher Faylor @ 2006-06-16 12:48 UTC (permalink / raw)
  To: cygwin

On Fri, Jun 16, 2006 at 08:28:22AM -0400, Brett Serkez wrote:
>On Fri, Jun 16, 2006 at 08:24:12AM -0400, Christopher Faylor wrote:
>>>NTFS and FAT file systems simply do not have the concept of inodes,
>>>Cygwin is dependent upon the facilities supplied by these file systems.
>>
>>Actually NTFS does have something like an inode.  That's what Cygwin
>>uses.
>
>Then why does this fail?  Please enlighten us?

http://cygwin.com/ml/cygwin/2006-06/msg00347.html

It has nothing to do with inodes.  There have been versions of UNIX
which didn't allow you to remove a directory when someone has cd'ed to
it, too.

cgf

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-16 12:48           ` Christopher Faylor
@ 2006-06-16 13:01             ` Brett Serkez
  2006-06-16 13:13               ` Corinna Vinschen
  2006-06-16 14:22               ` Christopher Faylor
  0 siblings, 2 replies; 19+ messages in thread
From: Brett Serkez @ 2006-06-16 13:01 UTC (permalink / raw)
  To: cygwin

> >>>NTFS and FAT file systems simply do not have the concept of inodes,
> >>>Cygwin is dependent upon the facilities supplied by these file systems.
> >>
> >>Actually NTFS does have something like an inode.  That's what Cygwin
> >>uses.
> >
> >Then why does this fail?  Please enlighten us?
>
> http://cygwin.com/ml/cygwin/2006-06/msg00347.html

This is the same email thread, nothing here that helps explain what
I'm asking.  Rereading it all I see is the reference to open
handles/handlers (Windows/UNIX terminology).  This is precisely what
an inode does in a Linux/UNIX file system, the kernel is given the
inode to hold as the handle to the open file.  If the directory entry
is detached from this inode, no problem, but the file is still open
and exists.  Ultimately the only difference is that UNIX/Linux says no
problem, Windows generates an error due to this difference.

> It has nothing to do with inodes.  There have been versions of UNIX
> which didn't allow you to remove a directory when someone has cd'ed to
> it, too.

Well, the UNIX/Linux rules don't change in this regard, this area has
been stable for as long as I've been using UNIX/Linux (20+ years).
This is one of the great strengths of UNIX, the basic rules are
simple, well understood and stable.  When you cd to a directory, you
are maintaining the directory as a open file.   It is more likely the
specific file system in use does or doesn't support inodes.

ext2/ext3 has been the predominate file system atleast in Linux,
althought there are many choices and ext2/ext3 is an inode based file
system.  I cannot say that all file system available are inode based,
but all the ones I've worked with in the last decade have been.

So this brings me back to my original question, what is it in NTFS
that provides Inode type functionality that Cygwin is leveraging?  The
inode functionality would disassociate a files meta-data from the
directory entry to allow the functionality we've been talking about as
well as hard links.

Thanks!

Brett

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-16 13:01             ` Brett Serkez
@ 2006-06-16 13:13               ` Corinna Vinschen
  2006-06-16 13:15                 ` Brett Serkez
  2006-06-16 14:22               ` Christopher Faylor
  1 sibling, 1 reply; 19+ messages in thread
From: Corinna Vinschen @ 2006-06-16 13:13 UTC (permalink / raw)
  To: cygwin

On Jun 16 08:59, Brett Serkez wrote:
> So this brings me back to my original question, what is it in NTFS
> that provides Inode type functionality that Cygwin is leveraging?

This might sound far-fetched, but can you imagine that this is just
the way Microsoft implemented the file system?  It doesn't allow to
remove a directory if *any* process has an open handle to the directory
or one of its children.


Corinna

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

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-16 13:13               ` Corinna Vinschen
@ 2006-06-16 13:15                 ` Brett Serkez
  0 siblings, 0 replies; 19+ messages in thread
From: Brett Serkez @ 2006-06-16 13:15 UTC (permalink / raw)
  To: cygwin

> > So this brings me back to my original question, what is it in NTFS
> > that provides Inode type functionality that Cygwin is leveraging?
>
> This might sound far-fetched, but can you imagine that this is just
> the way Microsoft implemented the file system?  It doesn't allow to
> remove a directory if *any* process has an open handle to the directory
> or one of its children.

Absolutely, this is precisely my point!

UNIX/Linux specifically allows for this not to be the case via the
inode in the file system. I didn't think that Windows/NTFS allowed for
this possibility.  Christopher seemed to be indicating this was not
the case and I was trying to understand.

So this is clear, the original script will never work on Cygwin
because it is reliant upon NTFS which doesn't support this
functionality.

I would also point out that this functionality might not work under
Linux if the underlying file system isn't inode based.  For instance
one can mount a FAT/FAT32 file system and the script would fail in
that case also.

The original script worked based on file system functionality, not a
particular OS.

Thanks!

Brett

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-16 13:01             ` Brett Serkez
  2006-06-16 13:13               ` Corinna Vinschen
@ 2006-06-16 14:22               ` Christopher Faylor
  2006-06-16 14:35                 ` Brett Serkez
  1 sibling, 1 reply; 19+ messages in thread
From: Christopher Faylor @ 2006-06-16 14:22 UTC (permalink / raw)
  To: cygwin

On Fri, Jun 16, 2006 at 08:59:12AM -0400, Brett Serkez wrote:
>>>>>NTFS and FAT file systems simply do not have the concept of inodes,
>>>>>Cygwin is dependent upon the facilities supplied by these file systems.
>>>>
>>>>Actually NTFS does have something like an inode.  That's what Cygwin
>>>>uses.
>>>
>>>Then why does this fail?  Please enlighten us?
>>
>>http://cygwin.com/ml/cygwin/2006-06/msg00347.html
>
>This is the same email thread, nothing here that helps explain what
>I'm asking.

I doubt that anyone has access to Windows source code so the only thing
you can do is mention how things work on Windows and move on.  On
Windows, and on some UNIX systems, you can't delete a directory if
someone is cd'ed to it.

>Rereading it all I see is the reference to open handles/handlers
>(Windows/UNIX terminology).  This is precisely what an inode does in a
>Linux/UNIX file system, the kernel is given the inode to hold as the
>handle to the open file.  If the directory entry is detached from this
>inode, no problem, but the file is still open and exists.  Ultimately
>the only difference is that UNIX/Linux says no problem, Windows
>generates an error due to this difference.

On linux, a directory still has an inode after it is deleted.

>>It has nothing to do with inodes.  There have been versions of UNIX
>>which didn't allow you to remove a directory when someone has cd'ed to
>>it, too.
>
>Well, the UNIX/Linux rules don't change in this regard, this area has
>been stable for as long as I've been using UNIX/Linux (20+ years).
>This is one of the great strengths of UNIX, the basic rules are
>simple, well understood and stable.  When you cd to a directory, you
>are maintaining the directory as a open file.   It is more likely the
>specific file system in use does or doesn't support inodes.

I' really am not interested in arguing with you.  There have been UNIX
systems which fully supported inodes which did not allow you to remove
an active directory.  I have been using a wide variety UNIX systems for
24+ years so I guess my experience trumps yours.

(and, that plus $1.00+ will get me a cup of coffee)

Windows does support the concept of an inode-like-thing on NTFS
filesystems and that is what I was trying to clarify.  I don't see any
reason to write multi-paragraph treatises on the subject when it doesn't
really matter one way or the other.

The windows behavior is a simple statement of "That is the way it works".
If you want to research how Windows works under the hood then maybe google
has more information.  I'm not sure how it will benefit anyone, though.

cgf

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-16 14:22               ` Christopher Faylor
@ 2006-06-16 14:35                 ` Brett Serkez
  2006-06-16 16:21                   ` Christopher Faylor
  2006-06-16 16:24                   ` Dave Korn
  0 siblings, 2 replies; 19+ messages in thread
From: Brett Serkez @ 2006-06-16 14:35 UTC (permalink / raw)
  To: cygwin

<snip>
> I' really am not interested in arguing with you.

Then why are you!

I simply clarified to the original poster what was happening under the
hood on the UNIX/Linux side so they could understand, essentially
defending why it isn't supported under Cygwin.

I've noticed this before, you tend to take issue and start arguements,
you always have to be right and have the last word.

I only want to know what you were refering to in Windows that was like
inodes so I could learn.

I'd like to keep participating on the list to share knowledge and
learn but I've almost had enough of this sillyness.

Brett

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-16 14:35                 ` Brett Serkez
@ 2006-06-16 16:21                   ` Christopher Faylor
  2006-06-16 16:24                   ` Dave Korn
  1 sibling, 0 replies; 19+ messages in thread
From: Christopher Faylor @ 2006-06-16 16:21 UTC (permalink / raw)
  To: cygwin

On Fri, Jun 16, 2006 at 10:22:27AM -0400, Brett Serkez wrote:
>I only want to know what you were refering to in Windows that was like
>inodes so I could learn.

Cygwin's inode handling is in the source file fhandler_disk_file.cc.  If
you look for the word "inode" you should be able to see how it is done.

cgf

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: Unable to delete directory in Cygwin
  2006-06-16 14:35                 ` Brett Serkez
  2006-06-16 16:21                   ` Christopher Faylor
@ 2006-06-16 16:24                   ` Dave Korn
  2006-06-16 18:14                     ` Christopher Faylor
  1 sibling, 1 reply; 19+ messages in thread
From: Dave Korn @ 2006-06-16 16:24 UTC (permalink / raw)
  To: cygwin

On 16 June 2006 15:22, Brett Serkez wrote:


> I simply clarified to the original poster what was happening under the
> hood on the UNIX/Linux side so they could understand, essentially
> defending why it isn't supported under Cygwin.

  I think that you may have added confusion rather than clarity, but I'm sure
your motives were benign :)
 
> I only want to know what you were refering to in Windows that was like
> inodes so I could learn.

  File index numbers (only an NTFS feature); in *nix, an inode can be
considered analagous to a sector number on the drive; in 'doze, the inode is
an entry index# in the central directory.  Google 'FILE_OPEN_BY_FILE_ID' or
'ntfs mft' for more; cygwin uses the mft index# as an inode-alike.

> I'd like to keep participating on the list to share knowledge and
> learn but I've almost had enough of this sillyness.

  Hell, come to the talk list.  We have a whole different kind of silliness
there.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-16 16:24                   ` Dave Korn
@ 2006-06-16 18:14                     ` Christopher Faylor
  0 siblings, 0 replies; 19+ messages in thread
From: Christopher Faylor @ 2006-06-16 18:14 UTC (permalink / raw)
  To: cygwin

On Fri, Jun 16, 2006 at 05:21:36PM +0100, Dave Korn wrote:
>On 16 June 2006 15:22, Brett Serkez wrote:
>>I simply clarified to the original poster what was happening under the
>>hood on the UNIX/Linux side so they could understand, essentially
>>defending why it isn't supported under Cygwin.
>
>I think that you may have added confusion rather than clarity, but I'm
>sure your motives were benign :)

Right.  No motive speculation was intended in anything that I wrote.  I
just don't like the last word in a discussion to be an incorrect
statement.

I'm 90% sure that the discussion about linux was incorrect but I was
trying to point out that I didn't want to argue about what linux does
when, in the end, it doesn't matter.

cgf

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-15 13:19   ` Eric Blake
@ 2006-06-19 15:07     ` mwoehlke
  2006-06-19 19:59       ` Larry Hall (Cygwin)
  0 siblings, 1 reply; 19+ messages in thread
From: mwoehlke @ 2006-06-19 15:07 UTC (permalink / raw)
  To: cygwin

Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> According to Gina Verlekar on 6/15/2006 3:53 AM:
>> Hi,
>>
>> I have implemented some changes in the linker code for some intermediate
>> processing. For that I need to create a temporary directory, generate
>> some intermediate  in it, process those files by calling a function.
>> After processing of the intermediate files, I delete the intermediate
>> files and the temporary directory.	
>> While this logic works fine in the linux, the temporary directory does
>> not get deleted in cygwin.
> 
> Windows is not Linux, and will not allow users to delete in-use
> directories (where a directory is considered in-use if it contains files,
> or if any process is using that directory as its current working
> directory), nor the clean deletion of files that are still open.  POSIX
> allows this behavior, and cygwin cannot change Window's implementation of
> deletion semantics.  Just because Linux behaves nicer doesn't mean that it
> is portable to remove in-use directories.  Fix your code to first close
> all outstanding file handles before trying to remove the files, and then
> the directory.
> 
> That said, cygwin does try to emulate linux, and if someone were to
> contribute a patch that would allow cygwin to emulate directory deletion
> if it knows that all open handles have also been scheduled for unlinking
> at process end, then http://cygwin.com/acronyms/#PTC.

Not a patch, but for the record, it looks like Interix solves this 
problem (http://www.interopsystems.com/tools/tm.aspx?m=9403). Maybe 
Cygwin could do something similar?

(And in case that link dies; apparently Interix has a special 'temp' 
directory where "unlinked" files are sent until their handles are all 
closed.)

-- 
Matthew
...Ruthlessly beating Windows with a hammer until it looks like POSIX.


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-19 15:07     ` mwoehlke
@ 2006-06-19 19:59       ` Larry Hall (Cygwin)
  2006-06-19 20:25         ` mwoehlke
  0 siblings, 1 reply; 19+ messages in thread
From: Larry Hall (Cygwin) @ 2006-06-19 19:59 UTC (permalink / raw)
  To: cygwin

mwoehlke wrote:
> Eric Blake wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> According to Gina Verlekar on 6/15/2006 3:53 AM:
>>> Hi,
>>>
>>> I have implemented some changes in the linker code for some intermediate
>>> processing. For that I need to create a temporary directory, generate
>>> some intermediate  in it, process those files by calling a function.
>>> After processing of the intermediate files, I delete the intermediate
>>> files and the temporary directory.   
>>> While this logic works fine in the linux, the temporary directory does
>>> not get deleted in cygwin.
>>
>> Windows is not Linux, and will not allow users to delete in-use
>> directories (where a directory is considered in-use if it contains files,
>> or if any process is using that directory as its current working
>> directory), nor the clean deletion of files that are still open.  POSIX
>> allows this behavior, and cygwin cannot change Window's implementation of
>> deletion semantics.  Just because Linux behaves nicer doesn't mean 
>> that it
>> is portable to remove in-use directories.  Fix your code to first close
>> all outstanding file handles before trying to remove the files, and then
>> the directory.
>>
>> That said, cygwin does try to emulate linux, and if someone were to
>> contribute a patch that would allow cygwin to emulate directory deletion
>> if it knows that all open handles have also been scheduled for unlinking
>> at process end, then http://cygwin.com/acronyms/#PTC.
> 
> Not a patch, but for the record, it looks like Interix solves this 
> problem (http://www.interopsystems.com/tools/tm.aspx?m=9403). Maybe 
> Cygwin could do something similar?
> 
> (And in case that link dies; apparently Interix has a special 'temp' 
> directory where "unlinked" files are sent until their handles are all 
> closed.)
> 


If you take a look at the cygwin sources, you'll see that Cygwin does
something similar already.  This does not solve the problem for those
that want to unlink and immediately recreate the unlinked entry though...


-- 
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-19 19:59       ` Larry Hall (Cygwin)
@ 2006-06-19 20:25         ` mwoehlke
  2006-06-20 15:28           ` Lev Bishop
  0 siblings, 1 reply; 19+ messages in thread
From: mwoehlke @ 2006-06-19 20:25 UTC (permalink / raw)
  To: cygwin

Larry Hall (Cygwin) wrote:
> mwoehlke wrote:
>> Eric Blake wrote:
>>> That said, cygwin does try to emulate linux, and if someone were to
>>> contribute a patch that would allow cygwin to emulate directory deletion
>>> if it knows that all open handles have also been scheduled for unlinking
>>> at process end, then http://cygwin.com/acronyms/#PTC.
>>
>> Not a patch, but for the record, it looks like Interix solves this 
>> problem (http://www.interopsystems.com/tools/tm.aspx?m=9403). Maybe 
>> Cygwin could do something similar?
>>
>> (And in case that link dies; apparently Interix has a special 'temp' 
>> directory where "unlinked" files are sent until their handles are all 
>> closed.)
> 
> If you take a look at the cygwin sources, you'll see that Cygwin does
> something similar already.  This does not solve the problem for those
> that want to unlink and immediately recreate the unlinked entry though...

I'm confused. As I read the post, if I create a file 'bar' in '/foo', 
open the file, and then 'rm -rf /foo', I can't do that. If Cygwin 
"magically redirects" 'bar' to some special place, wouldn't that
a: allow me to unlink '/foo'
b: allow me to then create a new (and different) '/foo/bar'?

I also do not see anywhere that the OP is even trying to do [b].

-- 
Matthew
...Ruthlessly beating Windows with a hammer until it looks like POSIX.


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Unable to delete directory in Cygwin
  2006-06-19 20:25         ` mwoehlke
@ 2006-06-20 15:28           ` Lev Bishop
  0 siblings, 0 replies; 19+ messages in thread
From: Lev Bishop @ 2006-06-20 15:28 UTC (permalink / raw)
  To: cygwin

On 6/19/06, mwoehlke  wrote:
> Larry Hall (Cygwin) wrote:
> > mwoehlke wrote:
> >> Eric Blake wrote:
> >>> That said, cygwin does try to emulate linux, and if someone were to
> >>> contribute a patch that would allow cygwin to emulate directory deletion
> >>> if it knows that all open handles have also been scheduled for unlinking
> >>> at process end, then http://cygwin.com/acronyms/#PTC.
> >>
> >> Not a patch, but for the record, it looks like Interix solves this
> >> problem (http://www.interopsystems.com/tools/tm.aspx?m=9403). Maybe
> >> Cygwin could do something similar?
> >>
> >> (And in case that link dies; apparently Interix has a special 'temp'
> >> directory where "unlinked" files are sent until their handles are all
> >> closed.)
> >
> > If you take a look at the cygwin sources, you'll see that Cygwin does
> > something similar already.  This does not solve the problem for those
> > that want to unlink and immediately recreate the unlinked entry though...
>
> I'm confused. As I read the post, if I create a file 'bar' in '/foo',
> open the file, and then 'rm -rf /foo', I can't do that. If Cygwin
> "magically redirects" 'bar' to some special place, wouldn't that
> a: allow me to unlink '/foo'
> b: allow me to then create a new (and different) '/foo/bar'?

Yes, in both cases. However, cygwin doesn't do this magic redirection.
What it does do, as far as I understand it, is that it adds files that
have deletion syscalls called on them to a pending-deletion list,
returns success to the deleter, and then deletes the file at the first
chance it gets. I had a go at making a "magic redirection" patch a
while ago, but never got it into submittable form.

> I also do not see anywhere that the OP is even trying to do [b].

With the current cygwin, you don't get that far, since the file bar
still exists until it's no longer in use, and the pending-delete stuff
doesn't happen for directories.

Take a look at winsup/cygwin/delqueue.cc , especially the initial
FIXME comment....

L

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2006-06-20 15:22 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1F211FE03383644EAA6BB7A52FCD9B9B0927A0@sohm.kpit.com>
2006-06-15 10:15 ` Unable to delete directory in Cygwin Gina Verlekar
2006-06-15 13:19   ` Eric Blake
2006-06-19 15:07     ` mwoehlke
2006-06-19 19:59       ` Larry Hall (Cygwin)
2006-06-19 20:25         ` mwoehlke
2006-06-20 15:28           ` Lev Bishop
2006-06-15 15:40   ` Thorsten Kampe
2006-06-16 11:36     ` Brett Serkez
2006-06-16 12:28       ` Christopher Faylor
2006-06-16 12:37         ` Brett Serkez
2006-06-16 12:48           ` Christopher Faylor
2006-06-16 13:01             ` Brett Serkez
2006-06-16 13:13               ` Corinna Vinschen
2006-06-16 13:15                 ` Brett Serkez
2006-06-16 14:22               ` Christopher Faylor
2006-06-16 14:35                 ` Brett Serkez
2006-06-16 16:21                   ` Christopher Faylor
2006-06-16 16:24                   ` Dave Korn
2006-06-16 18:14                     ` Christopher Faylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).