Fri Aug 18 22:25:00 GMT 2017
On 08/18/2017 08:21 AM, Ken Brown wrote:
> Linux has a system call 'renameat2' which is like renameat but has an
> extra 'flags' argument. In particular, one can pass the
> RENAME_NOREPLACE flag to cause the rename to fail with EEXIST if the
> target of the rename exists. See
> macOS has a similar functionality, provided by the function
> 'renameatx_np' with the flag RENAME_EXCL.
> Define the RENAME_* flags in <cygwin/fs.h> as defined on Linux in
> <linux/fs.h>, but support only RENAME_NOREPLACE.
> +++ b/winsup/cygwin/include/cygwin/fs.h
> @@ -19,4 +19,9 @@ details. */
> #define BLKPBSZGET 0x0000127b
> #define BLKGETSIZE64 0x00041268
> +/* Flags for renameat2, from /usr/include/linux/fs.h. */
> +#define RENAME_NOREPLACE (1 << 0)
> +#define RENAME_EXCHANGE (1 << 1)
> +#define RENAME_WHITEOUT (1 << 2)
Please only define RENAME_NOREPLACE for now; that way, software can
probe what is defined to know what will work (defining a flag that will
always be an error is not as useful as leaving it undefined - and while
we may add RENAME_EXCHANGE support, I don't see how we can ever do
> diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
> index efd4ac017..7640abfad 100644
> --- a/winsup/cygwin/include/cygwin/version.h
> +++ b/winsup/cygwin/include/cygwin/version.h
> @@ -481,12 +481,14 @@ details. */
> 314: Export explicit_bzero.
> 315: Export pthread_mutex_timedlock.
> 316: Export pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock.
> + 317: Export renameat2. Add RENAME_NOREPLACE, RENAME_EXCHANGE,
> + RENAME_WHITEOUT.
This needs tweaks to match.
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 619 bytes
Desc: OpenPGP digital signature
More information about the Cygwin-patches