This is the mail archive of the
mailing list for the Cygwin project.
rename() cannot replace the file which is opened with writable access
- From: Masamichi Hosoda <trueroad at trueroad dot jp>
- To: cygwin at cygwin dot com
- Cc: trueroad at trueroad dot jp
- Date: Thu, 12 Jan 2017 09:07:46 +0900 (JST)
- Subject: rename() cannot replace the file which is opened with writable access
- Authentication-results: sourceware.org; auth=none
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 ()
struct flock fl;
char buff = "test";
/* create oldpath file */
fd = open (OLDPATH, O_CREAT | O_RDWR | O_TRUNC, 0666);
/* create newpath file */
fd = open (NEWPATH, O_CREAT | O_RDWR | O_TRUNC, 0666);
/* rename *** FAILED on Cygwin *** */
if (rename (OLDPATH, NEWPATH) < 0)
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple