4 ms·
And CoW filesystems are getting more common, so cp's best case can be almost as fast as mv's.
by wtallis 14y ago
And CoW filesystems are getting more common, so cp's best case can be almost as fast as mv's.
- loeg 14y agoReally? After some quick digging, nope. Tl;dr: Not by default, and only on Linux, and only with btrfs (still marked experimental) and only with the `--reflink` flag. FreeBSD `cp(1)`: `copy_file()` does a simple `read()`/`write()` loop with a buffer[0] (despite ZFS maybe supporting CoW). GNU coreutils `cp(1)`: `copy_reg()` calls out to `clone_file()` if and only if `--reflink` was passed[1], and `clone_file()` fails on everything but btrfs[2]. [0]: FreeBSD `copy_file()`: https://github.com/freebsd/freebsd/blob/master/bin/cp/utils.c#L205 https://github.com/freebsd/freebsd/blob/master/bin/cp/utils.... [1]: coreutils `copy_reg()`: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/copy.c;h=5c0ee1e703d8494b71eda67436a12c5d79a9a5ef;hb=HEAD#l978 http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f... [2]: coreutils `clone_file()`: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/copy.c;h=5c0ee1e703d8494b71eda67436a12c5d79a9a5ef;hb=HEAD#l223 http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f...