Skip to content

cp: allow -x copies onto a mounted subdirectory - #17135

Open
qodelicious wants to merge 2 commits into
uutils:mainfrom
qodelicious:qodelicious/cp-one-file-system
Open

qodelicious wants to merge 2 commits into
uutils:mainfrom
qodelicious:qodelicious/cp-one-file-system

Conversation

@qodelicious

Copy link
Copy Markdown
Contributor

cp -rx / DIR (and cp -ax / /mnt) was refused with "cannot copy a directory into itself" because the self-copy check only compares paths, and every destination is under /. With -x the destination is never entered when it is on another filesystem, so the copy is safe.

With -x, the check now lets a nested destination through when it is on a different device than the source (including a new directory under a mount point). Copies on the same device are still refused, with or without -x. Added tests for both cases.

Closes #17101

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.

cp -rx / DIR is refused as copying a directory into itself, so a root filesystem cannot be copied onto a mounted disk

1 participant