renameat2 works differently than on Linux
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue Apr 18 16:21:48 GMT 2023
Hi Bruno,
On Apr 18 14:47, Bruno Haible via Cygwin wrote:
> Hi,
>
> The renameat2 function is "Linux-specific", says the man page [1]; however,
> Cygwin implements it as well.
>
> In Cygwin 3.4.6, in a specific case, it operates differently than the
> Linux function. Namely, if the old* arguments and the new* arguments
> are the same and the flag RENAME_NOREPLACE is specified.
> [...]
> Output on Linux (glibc, musl libc):
> ret=-1, errno=17=EEXIST
>
> Output on Cygwin 3.4.6:
> ret=0
>
> Note that there is some ambiguity about this case in [1]: One one hand,
> there is the general statement about rename():
> "If oldpath and newpath are existing hard links referring to the
> same file, then rename() does nothing, and returns a success status."
> On the other hand, the text regarding RENAME_NOREPLACE says:
> "Return an error if newpath already exists."
Thanks for the testcase. I guess the ambiguity doesn't matter, given
it's a Linux function anyway. It makes sense to behave the same, if
possible.
I pushed a patch. The next test release cygwin-3.5.0-0.284.gd30a5917a9c4
will contain the patch for testing.
Thanks,
Corinna
More information about the Cygwin
mailing list