Skip to content

cp --reflink=always on an unsupported volume copies the file via fallback but still exits 1 with 'failed to clone' — the target exists yet the command reports failure #1369

Closed

Description

@caomengxuan666

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

Fixture: file f containing payload\n. Command: cp --reflink=always f C:\v2reflink\out.txt where the destination volume does not support cloning.

  • WinuxCmd: prints cp: failed to clone 'C:\v2reflink\out.txt' from 'f': Not supported, exit 1 — but the destination file exists afterwards with the full correct contents (a silent fallback copy happened despite --reflink=always).
  • GNU (cp --reflink=always across filesystems): exit 1 with a clone failure and no destination file is created.

Expected (GNU)

--reflink=always means "clone or fail": on failure the command exits non-zero without producing the copy. A fallback copy that is then reported as a failure is the worst of both worlds — scripts see an error, clean up nothing, and a stray file with valid contents remains.

Source

src/commands/cp.cpp: the reflink error path falls through to the regular copy engine and then still returns the clone failure.

Regression seed

In-repo test named with this issue number: the cross-volume fixture above; assert exit 1 and destination absent afterwards.

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 275785f): on the two failure paths after destination creation, cp closes the handle and deletes the half-written target — --reflink=always on an unsupported volume now fails loudly and leaves no destination behind; the auto fallback is unchanged. Regression pin issue1369_reflink_always_failure_leaves_no_destination 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