coreutils' `--reflink` behavior with `cp`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 40.5k
- Forks
- 2.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 85
Description
Related problem
On some filesystems that support Copy-on-Write (CoW), GNU coreutils' cp supports "instant" copy by default, but this can be optionally disabled by supplying --reflink=never to create an actual duplicate block.
Based on some simple testing, it seems like nu's cp does CoW copy when -p is not supplied, but does actual copy when -p is supplied. However, it doesn't seem like this is documented in the help or the docs.
Describe the solution you'd like
Make an option, cp --nocow, that allows users to manually specify the behavior of cp on CoW systems, similar to coreutils' one.
Describe alternatives you've considered
Alternative would be to just document the -p's behavior to not use CoW, but this is unideal:
-poption should only do what the option suggests it will do, which is showing the progress, with no side effects.- When a user is copying a large directory, they might want to observe the progress, but would want the operation to finish ASAP, utilizing CoW whenever possible.
Additional context and details
I have tested this on Btrfs, using following commands:
# create a random file
dd if=/dev/urandom of=~/Desktop/testfile bs=1M count=16384
# copy w/o `-p` option
cp testfile testfile_cow
# copy w/ `-p` option
cp -p testfile testfile_nocow
# observe the `Exclusive` column of output
btrfs filesystem du .
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Nushell's cp command implementation and its help output, then read the cp documentation at nushell.sh/commands/docs/cp.html. Reproduce the Btrfs behavior from the issue and determine where copy mode is selected. Done means cp exposes a documented --nocow option with behavior that can be verified against the CoW and non-CoW examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, operating-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100