This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Add renameat2 function [BZ #17662]
- From: Florian Weimer <fweimer at redhat dot com>
- To: Paul Eggert <eggert at cs dot ucla dot edu>, libc-alpha at sourceware dot org
- Cc: Gnulib bugs <bug-gnulib at gnu dot org>
- Date: Tue, 3 Jul 2018 08:40:42 +0200
- Subject: Re: [PATCH] Add renameat2 function [BZ #17662]
- References: <20180630121447.E4C8643994575@oldenburg.str.redhat.com> <firstname.lastname@example.org>
On 07/02/2018 07:38 PM, Paul Eggert wrote:
Florian Weimer wrote:
Without kernel support, a non-zero argument returns EINVAL, not ENOSYS.
This mirrors what the kernel does for invalid renameat2 flags.
The Gnulib renameat2 function
different semantics with non-zero flags. On GNU/Linux if
flags==RENAME_NOREPLACE and the Linux syscall fails due to
EINVAL/ENOSYS/ENOTSUP, Gnulib renameat2 falls back on fstatatting the
destination, failing if fstatat succeeds, and using ordinary renameat
otherwise. Of course this implementation has a race condition, but
Gnulib-using applications like GNU 'mv' prefer this implementation since
if the kernel doesn't support RENAME_NOREPLACE they'd just fall back on
fstatat themselves anyway, if renameat2 didn't do that for them.
Surely that's a gnulib bug because the main reason for the
RENAME_NOREPLACE variant renameat2 was to avoid exactly that race (or
the other race where the file exists under both the old and new path).
The gnulib function should simply be called something else, not
renameat2. The present situation is unfortunate, but I don't think it
would be an improvement if glibc copies the buggy gnulib behavior.