bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add renameat2 function [BZ #17662]


From: Florian Weimer
Subject: Re: [PATCH] Add renameat2 function [BZ #17662]
Date: Tue, 3 Jul 2018 08:40:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

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 <https://www.gnu.org/software/gnulib/MODULES.html#module=renameat2> has 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.

Thanks,
Florian



reply via email to

[Prev in Thread] Current Thread [Next in Thread]