public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: rename() in B18..
@ 1997-06-14  8:17 Keet
  0 siblings, 0 replies; 5+ messages in thread
From: Keet @ 1997-06-14  8:17 UTC (permalink / raw)
  To: Michael Hirmke, gnu-win32

>
>You try to unlink open files !
>

Under UNIX, it's perfectly legal to unlink a file BEFORE it is closed,
because UNIX only deletes the filename, and not the inode. This is one of
the incompatibility problems between UNIX and Windows. Under a FAT based
system you can't unlink a file because the filename IS the file. What I
suspect, is that for the sake of compatibility Cygwin is silently failing
when attempting to unlink an open file, and is thus never deleted. It seems
that there is a large problem in that area. Under UNIX there are a large
number of programs that really do rely on the ability to unlink() a file
before it is closed. Any more ideas on the matter? (other than loosing some
UNIX compatibility and having to rewrite the source that does not close a
file before it is unlinked? which is, perfectly legal in UNIX).

- Greg Neujahr
  Foxbird / Keet
  keetnet@wilmington.net


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Re: rename() in B18..
  1997-06-12 20:56 Keet
  1997-06-13 16:01 ` Michael Hirmke
@ 1997-06-13 18:08 ` $Bill Luebkert
  1 sibling, 0 replies; 5+ messages in thread
From: $Bill Luebkert @ 1997-06-13 18:08 UTC (permalink / raw)
  To: Keet; +Cc: gnu-win32

Keet wrote:
> 
> The following C code example, is proof that RENAME() or UNLINK() does not
> work reliably. After being told so many times it's the source's fault, I'm
> relieved to have found someone who knows what they're talking about and who
> could help me with this. What's happening is that when a file is unlinked,
> it isn't really unlinked. From what I'm told, there is no way to UNLINK an
> open file under a FAT based system. This is because in a FAT based system,
> the filename IS the file.. under UNIX, this is not the case. How you got
> around that, is beyond me. From what I can tell, the file is NOT unlinked,
> because when the following test program ends, test1 still exists. If this is
> not the case, then it's still failing to rename, because I get an error, and
> both test1 and test2 still exist. This isn't normal operation. Under 17.1
> this worked lovely, no problem at all. It even worked in Linux.. but under
> 18.. it messes up completely. If anyone can offer any help to me.. please
> reply ASAP.
> 
> ==============================START TEST.C====================================
> 
> /* rename() and unlink() failure */
> #include <stdio.h>
> 
> main()
> {
>     FILE *test1,*test2;
> 
>     if( (test1=fopen("test1","w")) == NULL) {
>         printf("Unable to fopen() test1!\n");
>         exit(1);
>     }
> 
>     if( (test2=fopen("test2","w")) == NULL) {
>         printf("Unable to fopen() test2!\n");
>         exit(1);
>     }
> 
>     if( fputs("This is test 1...\n",test1) < 0) {
>         printf("Unable to write to test1!\n");
>         exit(1);
>     }
> 
>     if( fputs("This is test 2...\n",test2) < 0) {
>         printf("Unable to write to test2!\n");
>         exit(1);
>     }

Try moving these to here:
      fclose(test1);
      fclose(test2);

>     if( unlink("test1") < 0) {
>         printf("Unable to unlink test1!\n");
>         exit(1);
>     }
> 
>     if( rename("test2","test1") < 0 ) {
>         printf("Unable to rename test2 to test1!\n");
>         exit(1);
>     }
> 
>     fclose(test1);
>     fclose(test2);

And delete from here.

> }
> 
> ==================================END TEST.C=================================

-- 
  ,-/-  __      _  _         $Bill Luebkert
 (_/   /  )    // //       DBE Collectibles
  / ) /--<  o // //      http://www.wgn.net/~dbe/
-/-' /___/_<_</_</_    Email: dbe@wgn.net
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Re: rename() in B18..
  1997-06-12 20:56 Keet
@ 1997-06-13 16:01 ` Michael Hirmke
  1997-06-13 18:08 ` $Bill Luebkert
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Hirmke @ 1997-06-13 16:01 UTC (permalink / raw)
  To: gnu-win32

On Thu, 12 Jun 1997, Keet wrote:

[...]
>     if( unlink("test1") < 0) {
> 	printf("Unable to unlink test1!\n");
> 	exit(1);
>     }
>     
>     if( rename("test2","test1") < 0 ) {
> 	printf("Unable to rename test2 to test1!\n");
> 	exit(1);
>     }

You try to unlink open files !

>     
>     fclose(test1);
>     fclose(test2);
> }
> 
[...]

Ciao.
Michael.
-- 
Michael Hirmke           | voice +49 (911) 557999
Georg-Strobel-Strasse 81 | fax   +49 (911) 557664
D-90489 Nuernberg        | email mh@mike.franken.de
Germany                  | www   http://minimike.franken.de/

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* rename() in B18..
@ 1997-06-12 20:56 Keet
  1997-06-13 16:01 ` Michael Hirmke
  1997-06-13 18:08 ` $Bill Luebkert
  0 siblings, 2 replies; 5+ messages in thread
From: Keet @ 1997-06-12 20:56 UTC (permalink / raw)
  To: gnu-win32

The following C code example, is proof that RENAME() or UNLINK() does not
work reliably. After being told so many times it's the source's fault, I'm
relieved to have found someone who knows what they're talking about and who
could help me with this. What's happening is that when a file is unlinked,
it isn't really unlinked. From what I'm told, there is no way to UNLINK an
open file under a FAT based system. This is because in a FAT based system,
the filename IS the file.. under UNIX, this is not the case. How you got
around that, is beyond me. From what I can tell, the file is NOT unlinked,
because when the following test program ends, test1 still exists. If this is
not the case, then it's still failing to rename, because I get an error, and
both test1 and test2 still exist. This isn't normal operation. Under 17.1
this worked lovely, no problem at all. It even worked in Linux.. but under
18.. it messes up completely. If anyone can offer any help to me.. please
reply ASAP.

==============================START TEST.C====================================

/* rename() and unlink() failure */
#include <stdio.h>

main()
{
    FILE *test1,*test2;
    
    if( (test1=fopen("test1","w")) == NULL) {
	printf("Unable to fopen() test1!\n");
	exit(1);
    }
    
    if( (test2=fopen("test2","w")) == NULL) {
	printf("Unable to fopen() test2!\n");
	exit(1);
    }
    
    if( fputs("This is test 1...\n",test1) < 0) {
	printf("Unable to write to test1!\n");
	exit(1);
    }
    
    if( fputs("This is test 2...\n",test2) < 0) {
	printf("Unable to write to test2!\n");
	exit(1);
    }
    
    if( unlink("test1") < 0) {
	printf("Unable to unlink test1!\n");
	exit(1);
    }
    
    if( rename("test2","test1") < 0 ) {
	printf("Unable to rename test2 to test1!\n");
	exit(1);
    }
    
    fclose(test1);
    fclose(test2);
}

==================================END TEST.C=================================

- Greg Neujahr
  Keet - Foxbird
  keetnet@wilmington.net


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* rename() in b18
@ 1997-06-05 18:47 crvich
  0 siblings, 0 replies; 5+ messages in thread
From: crvich @ 1997-06-05 18:47 UTC (permalink / raw)
  To: Cygnus Discussion

	I've been experimenting with an odd problem with rename(), and am
apparently running into the same (or similar) problem that another person
reported here earlier (by Greg Neujahr).

	I've traced it to the point that it seems that rename() will fail
consistently if there is one or more open file handles on the target
parameter (as in "rename( source, target )").  The errno is 13 (EACCES),
which I think is what Greg was getting.  This doesn't seem to happen with
b17.1, as I haven't changed any code since installing b18.

	I've tried using unlink() to erase the target file before calling
rename(), and although unlink() successfully removes the file, rename()
still fails with the same error.

	I'm running WinNT 4.0, by the way.

	I would like to say, though, that b18 *did* fix an annoying bug
with fork(), and for that I'm most grateful.  8-)

-- 
Ernest M. Crvich
Raleigh/Durham, NC
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

end of thread, other threads:[~1997-06-14  8:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-14  8:17 rename() in B18 Keet
  -- strict thread matches above, loose matches on Subject: below --
1997-06-12 20:56 Keet
1997-06-13 16:01 ` Michael Hirmke
1997-06-13 18:08 ` $Bill Luebkert
1997-06-05 18:47 rename() in b18 crvich

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).