public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Paul Eggert <eggert@cs.ucla.edu>, libc-alpha@sourceware.org
Cc: Gnulib bugs <bug-gnulib@gnu.org>
Subject: Re: [PATCH] Add renameat2 function [BZ #17662]
Date: Tue, 03 Jul 2018 06:40:00 -0000	[thread overview]
Message-ID: <eb0ebdfa-e55d-3d51-f03a-fa2e03d8741d@redhat.com> (raw)
In-Reply-To: <4a9cb334-48f4-139f-d917-457ce8ece57a@cs.ucla.edu>

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

  parent reply	other threads:[~2018-07-03  6:40 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-30 12:15 Florian Weimer
2018-06-30 20:22 ` Joseph Myers
2018-06-30 21:11   ` Florian Weimer
2018-06-30 22:26     ` Joseph Myers
2018-07-01 21:49 ` Yury Norov
2018-07-02  6:48   ` Florian Weimer
2018-07-02  8:46     ` Yury Norov
2018-07-02  9:32       ` Florian Weimer
2018-07-02  8:59   ` Andreas Schwab
2018-07-02 15:11   ` Joseph Myers
2018-07-02 17:38 ` Paul Eggert
2018-07-02 19:46   ` Joseph Myers
2018-07-02 19:58     ` Paul Eggert
2018-07-03  6:40   ` Florian Weimer [this message]
2018-07-03 19:06     ` Paul Eggert
2018-07-04  9:04       ` Andreas Schwab
2018-07-04 10:39         ` Florian Weimer
2018-07-04 16:31         ` Carlos O'Donell
2018-07-04 19:36           ` Paul Eggert
2018-07-04 20:13             ` Carlos O'Donell
2018-07-04 20:26               ` Florian Weimer
2018-07-04 20:46                 ` Paul Eggert
2018-07-05 13:19                 ` Carlos O'Donell
2018-07-04 20:47               ` Paul Eggert
2018-07-04 19:21 ` Carlos O'Donell
2018-07-04 19:53   ` Paul Eggert
2018-07-04 20:28     ` Florian Weimer
2018-07-04 20:36       ` Paul Eggert
2018-07-05 14:01   ` Florian Weimer
2018-07-05 14:25     ` Paul Eggert
2018-07-05 15:26       ` Florian Weimer
2018-07-05 16:53         ` Paul Eggert
2018-07-05 16:57     ` Carlos O'Donell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eb0ebdfa-e55d-3d51-f03a-fa2e03d8741d@redhat.com \
    --to=fweimer@redhat.com \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).