Pádraig Brady <[email protected]> writes:
> On 15/11/2026 09:34, Collin Funk wrote:
>> Commit 0d74ac470 (copy: make backup files more reliably, 2017-07-30)
>> made 'cp' and 'install' use renameat2 to make backups, but forgot 'ln'
>> despite mentioning it in the NEWS entry. This patch makes that change
>> for 'ln'. Not sure whether it's preferred to update old NEWS entries
>> for accuracy (and then run 'make update-NEWS-hash'), so I left it
>> as-is for now.
>> There were other behavior changes WRT backups in that commit. I'll
>> have a look at that separately since the OSS scanner issue was just
>> about the race.
>
>
> Given kernel 3.15 is so old, and macOS also supports atomic rename,
> I'd simplify the NEWS to something like:
>
> 'ln' now avoids races that could lose backup data in unlikely
> - circumstances. Since the fix relies on the renameat2 system call of
> - Linux kernel 3.15 and later, the races are still present on other
> - platforms.
> + circumstances, on systems providing support for atomic rename.
> [This bug was present in "the beginning".]
Oh, I lazily copied Paul's NEWS entry (and commit subject). :)
I didn't realize macOS supports atomic rename; otherwise, I would have
changed it.
> It would be useful I think to make the original NEWS entry
> more accurate, by removing the reference to ln.
Cool, that was my preference as well. The other change from that commit
was largely reverted by a subsequent commit [1]. But the behavior still
isn't the same:
$ rm -f a a~; : > a; echo data > a~; cp --backup=simple a~ ./a
cp: backing up './a' might destroy source; 'a~' not copied
$ rm -f a a~; : > a; echo data > a~; ln --backup=simple a~ ./a; echo $?
0
I'll look at that later, but I've gone ahead and fixed the NEWS entry
for that as well to avoid needing to run 'make update-NEWS-hash' again.
> Otherwise LGTM.
Thanks for the review. Pushed with those changes and a more specific
commit subject.
Collin
[1]
https://github.com/coreutils/coreutils/commit/a04039284cca9dcbc6b71b1058e63d35925ce164