Skip to content

mv across volumes turns a symlink into a regular-file copy of its target's contents — and leaves the source link in place #1365

Closed

Description

@caomengxuan666

Probe-verified (same-source mingw+Wine harness, two runs, GNU coreutils 9.4):

Fixture: file real.txt containing real\n, symlink lnk -> real.txt (relative). Command: mv lnk C:\v2mv\lnk (cross-volume; C: is a different drive).

  • WinuxCmd: exit 0. The destination C:\v2mv\lnk is a regular file containing the target's contents (real\n, 5 bytes) — the symlink was silently converted into a content copy. Worse, the source link lnk is still present afterwards (ls of the source dir shows lnk -> real.txt): the move did not move anything.
  • GNU (same fixture, mv lnk /dev/shm/v2mv/lnk across filesystems): the destination is a symlink whose text is still real.txt, and the source link is gone.

Expected (GNU)

A cross-volume move of a symlink recreates the link at the destination with its text preserved verbatim and removes the source. If link recreation is impossible, the command must fail — it must never silently substitute a regular-file copy and/or leave the source behind while reporting success.

Source

src/commands/mv.cpp: the cross-volume fallback resolves the link through GetFinalPathNameByHandleW and copies content; the recreate-link path and its source-removal step lose the link semantics.

Regression seed

In-repo test named with this issue number: the fixture above; assert destination is a symlink with text real.txt, source no longer exists, exit 0. A directory-symlink variant asserted too.

Activity

  1. added
    bug
    compat-gap
    on Oct 26, 2026
  2. added a commit that references this issue on Oct 27, 2026
  3. caomengxuan666 commented on Oct 27, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by #1403 (commit e7cac22): cross-volume mv of a symlink recreates the link verbatim at the destination (reads the link text, never CopyFileW of the target's contents) and removes the source. Regression pin issue1365_cross_volume_symlink_recreated_not_copied landed with the PR.

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

Metadata

Metadata

Labels

bugcompat-gap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions