This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Florian Weimer wrote:
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).

No, it's intended behavior, not a bug. GNU mv uses renameat2 with RENAME_NOREPLACE. mv wants the noreplace semantics on platforms that support it (currently only recent Linux and macOS kernels); otherwise it wants exactly that race because that's the best that can be done on other platforms. If Gnulib renameat2 simply failed with EINVAL because RENAME_NOREPLACE was not supported, GNU mv would simply use the same racy fallback that Gnulib renameat2 already uses.

Other GNU applications are similar to GNU mv in this respect.

The gnulib function should simply be called something else, not renameat2.

Although Gnulib will do that if necessary, it'll be unfortunate if GNU applications typically don't call glibc renameat2 directly (because it will be such a pain to use in the typical case) and use the Gnulib function instead. It'd be nicer if Glibc supported GNU applications rather than fought with them, and the RENAME_NONATOMIC flag I suggested would provide a more convenient and logical way to do that than a newly-named Gnulib function would.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]