rename2 check for existing file
Corinna Vinschen
corinna-cygwin@cygwin.com
Wed Jan 9 14:53:00 GMT 2019
Hi Ken,
your patch to support renameat2(..., RENAME_NOREPLACE),
commit f665b1cef30f9032877081ac63ea94910825be6a, also
introduced a new check
+ /* Should we replace an existing file? */
+ if ((removepc || dstpc->exists ()) && noreplace)
+ {
+ set_errno (EEXIST);
+ __leave;
+ }
However, the noreplace flag also adds the same check to the actual
NtSetInformationFile call to rename the file:
- pfri->ReplaceIfExists = TRUE;
+ pfri->ReplaceIfExists = !noreplace;
So, isn't the first check redundant? Can't we just drop it? The
rename2 function already has so many checks to perform before actually
calling NtSetInformationFile, every check we can remove is a boon, I
think.
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20190109/d18b2385/attachment.sig>
More information about the Cygwin-developers
mailing list