Skip to content

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

Open
krosci wants to merge 2 commits into
uutils:mainfrom
krosci:mv-fchown-cross-device
Open

krosci wants to merge 2 commits 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:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/retry (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/seq/seq-epipe 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!

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