Re: rename() cannot replace the file which is opened with writable access

2017-01-14 Thread Corinna Vinschen
On Jan 14 13:00, Masamichi Hosoda wrote:
> >> I've found that rename() cannot replace the file
> >> which is opened with writable access on Cygwin.
> >> On Linux, it works.
> >> 
> >> If I understand correctly, it should work under POSIX.
> >> 
> >> Here's sample code for reproduce.
> > 
> > Thanks for the testcase.  I applied a patch(*) and will upload a new
> > developer snapshot for testing to https://cygwin.com/snapshots/
> > at some point tomorrow.
> > 
> > 
> > Corinna
> > 
> > (*) https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=6ed4753
> 
> The snapshot has been fixed the issue.
> Thank you.

Thanks for your feedback!


Corinna

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


signature.asc
Description: PGP signature


Re: rename() cannot replace the file which is opened with writable access

2017-01-13 Thread Masamichi Hosoda
>> I've found that rename() cannot replace the file
>> which is opened with writable access on Cygwin.
>> On Linux, it works.
>> 
>> If I understand correctly, it should work under POSIX.
>> 
>> Here's sample code for reproduce.
> 
> Thanks for the testcase.  I applied a patch(*) and will upload a new
> developer snapshot for testing to https://cygwin.com/snapshots/
> at some point tomorrow.
> 
> 
> Corinna
> 
> (*) https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=6ed4753

The snapshot has been fixed the issue.
Thank you.

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: rename() cannot replace the file which is opened with writable access

2017-01-12 Thread Corinna Vinschen
On Jan 12 09:07, Masamichi Hosoda wrote:
> Hello,
> 
> I've found that rename() cannot replace the file
> which is opened with writable access on Cygwin.
> On Linux, it works.
> 
> If I understand correctly, it should work under POSIX.
> 
> Here's sample code for reproduce.

Thanks for the testcase.  I applied a patch(*) and will upload a new
developer snapshot for testing to https://cygwin.com/snapshots/
at some point tomorrow.


Corinna

(*) https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=6ed4753

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


signature.asc
Description: PGP signature


Re: rename() cannot replace the file which is opened with writable access

2017-01-12 Thread L. A. Walsh

Masamichi Hosoda wrote:

Hello,

I've found that rename() cannot replace the file
which is opened with writable access on Cygwin.
On Linux, it works.

If I understand correctly, it should work under POSIX.

Here's sample code for reproduce.

---

#define OLDPATH "oldpath"
#define NEWPATH "newpath"

int main () {
  int fd;
  struct flock fl;
  char buff[] = "test";
  fd = open (OLDPATH, O_CREAT | O_RDWR | O_TRUNC, 0666);
  close (fd);
  fd = open (NEWPATH, O_CREAT | O_RDWR | O_TRUNC, 0666);
  if (rename (OLDPATH, NEWPATH) < 0)  perror ("rename");
  


   What are you trying to do by renaming the oldfile
over the top of a still-open-for-write, "newfile".

   Why rename over the top of another file?  What are you trying
to do?  Maybe there is a better way to do it?  ;-). 


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: rename() cannot replace the file which is opened with writable access

2017-01-12 Thread cyg Simple
On 1/12/2017 10:36 AM, Corinna Vinschen wrote:
> On Jan 12 15:30, Nellis, Kenneth (Conduent) wrote:
>> From: Masamichi Hosoda
>>> If I understand correctly,
>>> POSIX behavior should be able to replace the writable opened file by
>>> rename().
>>> But, It does not work on my Cygwin environment.
>>>
>>> Is it no problem if Cygwin's behavior is different from POSIX behavior?
>>> If so, we need different application handling for Cygwin and POSIX.
>>
>> I thought it would be informative to respond by referring the OP
>> to a section of the Cygwin User's Guide or FAQ that mentioned the
>> limitations of Cygwin, but I could not find it.
> 
> Needs debugging.  Off the top of my head I have no clue why this
> doesn't work.  I'm just not near any Windows machine ATM...

Possibly BLODA.  In the sample code provided, the rename is trying to
rename the open file to an existing filename that was recently (within
microseconds) created.

-- 
cyg Simple

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: rename() cannot replace the file which is opened with writable access

2017-01-12 Thread Corinna Vinschen
On Jan 12 15:30, Nellis, Kenneth (Conduent) wrote:
> From: Masamichi Hosoda
> > If I understand correctly,
> > POSIX behavior should be able to replace the writable opened file by
> > rename().
> > But, It does not work on my Cygwin environment.
> > 
> > Is it no problem if Cygwin's behavior is different from POSIX behavior?
> > If so, we need different application handling for Cygwin and POSIX.
> 
> I thought it would be informative to respond by referring the OP
> to a section of the Cygwin User's Guide or FAQ that mentioned the
> limitations of Cygwin, but I could not find it.

Needs debugging.  Off the top of my head I have no clue why this
doesn't work.  I'm just not near any Windows machine ATM...


Corinna

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


signature.asc
Description: PGP signature


RE: rename() cannot replace the file which is opened with writable access

2017-01-12 Thread Nellis, Kenneth (Conduent)
From: Masamichi Hosoda
> If I understand correctly,
> POSIX behavior should be able to replace the writable opened file by
> rename().
> But, It does not work on my Cygwin environment.
> 
> Is it no problem if Cygwin's behavior is different from POSIX behavior?
> If so, we need different application handling for Cygwin and POSIX.

I thought it would be informative to respond by referring the OP
to a section of the Cygwin User's Guide or FAQ that mentioned the
limitations of Cygwin, but I could not find it.

--Ken Nellis

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: rename() cannot replace the file which is opened with writable access

2017-01-12 Thread Masamichi Hosoda
>> I've found that rename() cannot replace the file
>> which is opened with writable access on Cygwin.
>> On Linux, it works.
> 
> It is OS dependent behavior, and vary even on same OS.
> Windows may let you rename a file, or may not, depends on how exactly it is
> opened.

Thank you for your answer.

If I understand correctly,
POSIX behavior should be able to replace the writable opened file by rename().
But, It does not work on my Cygwin environment.

Is it no problem if Cygwin's behavior is different from POSIX behavior?
If so, we need different application handling for Cygwin and POSIX.

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: rename() cannot replace the file which is opened with writable access

2017-01-11 Thread Andrey Repin
Greetings, Masamichi Hosoda!

> I've found that rename() cannot replace the file
> which is opened with writable access on Cygwin.
> On Linux, it works.

It is OS dependent behavior, and vary even on same OS.
Windows may let you rename a file, or may not, depends on how exactly it is
opened.


-- 
With best regards,
Andrey Repin
Thursday, January 12, 2017 08:38:15

Sorry for my terrible english...


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple