cp: honor --reflink=never on macOS - #14076
Open
nagendramohan wants to merge 1 commit into
Open
Conversation
On macOS, copy_on_write() called clonefile(2) unconditionally and never consulted reflink_mode, so `--reflink=never` still cloned. Because clonefile(2) COW-shares the source's blocks and copies its metadata (including mtime), a plain `cp` on APFS gave the destination the source's mtime, where GNU and BSD cp stamp the copy's own time. Skip the clonefile attempt when reflink_mode is Never and fall through to the existing byte-copy path, mirroring the Linux ReflinkMode::Never handling (the fix in uutils#13065 only covered platform/linux.rs). Add a macOS regression test: --reflink=never must not leave the destination with the source's (old) mtime. Fixes uutils#14052
|
GNU testsuite comparison: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On macOS,
copy_on_write()calledclonefile(2)unconditionally and never consultedreflink_mode, so--reflink=neverstill cloned. Becauseclonefile(2)COW-shares thesource's blocks and copies its metadata (including mtime), a plain
cpon APFS gave thedestination the source's mtime, where GNU and BSD
cpstamp the copy's own time.This is the same class as #13064; the fix in #13065 only touched
platform/linux.rs, leavingthe macOS path uncovered.
Fix: skip the
clonefile(2)attempt whenreflink_modeisNeverand fall through to theexisting byte-copy path, mirroring the Linux
ReflinkMode::Neverhandling.Verified on APFS: with
--reflink=never, a 40 MB copy now consumes ~40 MB and the destinationgets its own mtime; default
cpstill clones (no regression to the fast path). Added a macOSregression test asserting
--reflink=neverdoes not leave the destination with the source's mtime.Fixes #14052