Skip to content

mv: create the cross-device destination exclusively and chown it by fd - #14631

Open
krosci wants to merge 1 commit into
uutils:mainfrom
krosci:mv-fchown-cross-device
Open

krosci wants to merge 1 commit into
uutils:mainfrom
krosci:mv-fchown-cross-device

Conversation

@krosci

@krosci krosci commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

rename_file_fallback kept the destination descriptor across the copy but preserve_ownership re-resolved the destination by path and called lchown, so a concurrent path-swap could redirect the chown to another inode. The comment above the block claimed a guarantee the code did not provide.

The cross-device leaf now chowns through the descriptor it already holds with fchown, and the destination is created with O_EXCL, matching GNU. create_dest_restrictive gains an exclusive flag, while cp keeps truncating a pre-existing destination.

Fixes #14599.

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/misc/io-errors (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/pid-pipe (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/pipe-f (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/cp/cp-mv-enotsup-xattr is no longer failing!
Congrats! The gnu test tests/csplit/csplit is no longer failing!
Congrats! The gnu test tests/date/date-tz is no longer failing!
Congrats! The gnu test tests/dd/nocache is no longer failing!
Congrats! The gnu test tests/df/df-output is no longer failing!
Congrats! The gnu test tests/du/max-depth is no longer failing!
Congrats! The gnu test tests/env/env is no longer failing!
Congrats! The gnu test tests/fold/fold is no longer failing!
Congrats! The gnu test tests/id/setgid is no longer failing!
Congrats! The gnu test tests/join/join is no longer failing!
Congrats! The gnu test tests/ls/ls-time is no longer failing!
Congrats! The gnu test tests/ls/m-option is no longer failing!
Congrats! The gnu test tests/misc/printenv is no longer failing!
Congrats! The gnu test tests/mv/mv-special-1 is no longer failing!
Congrats! The gnu test tests/od/od is no longer failing!
Congrats! The gnu test tests/printf/printf is no longer failing!
Congrats! The gnu test tests/ptx/ptx is no longer failing!
Congrats! The gnu test tests/seq/seq-precision is no longer failing!
Congrats! The gnu test tests/shred/shred-remove is no longer failing!
Congrats! The gnu test tests/shuf/shuf is no longer failing!
Congrats! The gnu test tests/sort/sort is no longer failing!
Congrats! The gnu test tests/split/split-io-err is no longer failing!
Congrats! The gnu test tests/stat/stat-fmt is no longer failing!
Congrats! The gnu test tests/stat/stat-nanoseconds is no longer failing!
Congrats! The gnu test tests/test/test is no longer failing!
Congrats! The gnu test tests/touch/now-owned-by-other is no longer failing!
Congrats! The gnu test tests/wc/wc is no longer failing!
Note: The gnu test tests/csplit/csplit-heap is now being skipped but was previously passing.

@krosci
krosci force-pushed the mv-fchown-cross-device branch from d9a2a1a to 376f213 Compare September 17, 2026 11:06
@krosci

krosci commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

@sylvestre could you take a look at it? Thanks!

@krosci
krosci force-pushed the mv-fchown-cross-device branch from 1d4153a to a54986e Compare September 20, 2026 10:33
@codspeed

codspeed Bot commented Sep 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 377 untouched benchmarks
⏩ 54 skipped benchmarks1


Comparing krosci:mv-fchown-cross-device (80d3d5b) with main (5eb255f)

Open in CodSpeed

Footnotes

  1. 54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@krosci
krosci force-pushed the mv-fchown-cross-device branch from a54986e to 85e99f7 Compare September 21, 2026 12:57
@krosci
krosci force-pushed the mv-fchown-cross-device branch from 85e99f7 to 80d3d5b Compare September 21, 2026 16:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mv: cross-device leaf chowns by path, contradicting the comment above it (GNU uses fchown)

1 participant