Skip to content

mv: don't put a symlink in its target's hardlink group - #14170

Open
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:mv-symlink-hardlink-group
Open

mv: don't put a symlink in its target's hardlink group#14170
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:mv-symlink-hardlink-group

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

The hardlink tracker keyed the inode map on Path::metadata(), which follows symlinks, so a symlink pointing at a hardlinked sibling joined its target's group. On a cross-device directory move, if the symlink was visited first, the regular files were "preserved" by linking to the copied symlink instead of being copied, then the source was unlinked: content destroyed, exit 0, no diagnostic. GNU mv moves all entries intact.

Use symlink_metadata() at the three lookup sites and only group regular files.

Thanks to @mtvb for the report and the diagnosis.

Copilot AI lite review requested due to automatic review settings August 27, 2026 06:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The hardlink tracker keyed the inode map on Path::metadata(), which follows
symlinks, so a symlink pointing at a hardlinked sibling joined its target's
group. On a cross-device directory move, if the symlink was visited first,
the regular files were "preserved" by linking to the copied symlink instead
of being copied, then the source was unlinked: content destroyed, exit 0,
no diagnostic. GNU mv moves all entries intact.

Use symlink_metadata() at the three lookup sites and only group regular
files.

Thanks to @mtvb for the report and the diagnosis.
@sylvestre
sylvestre force-pushed the mv-symlink-hardlink-group branch from 1de1203 to 9c49e02 Compare August 27, 2026 06:49
Copilot AI review requested due to automatic review settings August 27, 2026 06:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/retry (passes in this run but fails in the 'main' branch)

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.

2 participants