]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp: default to COW
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 Jun 2020 05:16:24 +0000 (22:16 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 Jun 2020 05:38:06 +0000 (22:38 -0700)
Likewise for â€˜install’.  Proposed in Bug#24400, and long past due.
* NEWS:
* doc/coreutils.texi (cp invocation):
* src/copy.h (enum Reflink_type): Document this.
* src/cp.c (cp_option_init):
* src/install.c (cp_option_init): Implement this.

NEWS
doc/coreutils.texi
src/copy.h
src/cp.c
src/install.c

diff --git a/NEWS b/NEWS
index 8ddd0e22f6777152588b7f3398c773e1a06a9cd6..655ff779f3f8fd09fff5505fbc24d0562982cc68 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Changes in behavior
 
+  cp and install now default to copy-on-write (COW) if available.
+
   On GNU/Linux systems, ls no longer issues an error message on
   directory merely because it was removed.  This reverts a change
   that was made in release 8.32.
index 3432fb294f1f6188fca17049f10b8562ee9ea741..4bbb960b7328311ccdf314a63990d5012f500a83 100644 (file)
@@ -8864,12 +8864,14 @@ The @var{when} value can be one of the following:
 
 @table @samp
 @item always
-The default behavior: if the copy-on-write operation is not supported
+If the copy-on-write operation is not supported
 then report the failure for each file and exit with a failure status.
+Plain @option{--reflink} is equivalent to @option{--reflink=when}.
 
 @item auto
 If the copy-on-write operation is not supported then fall back
 to the standard copy behavior.
+This is the default if no @option{--reflink} option is given.
 
 @item never
 Disable copy-on-write operation and use the standard copy behavior.
@@ -8878,12 +8880,6 @@ Disable copy-on-write operation and use the standard copy behavior.
 This option is overridden by the @option{--link}, @option{--symbolic-link}
 and @option{--attributes-only} options, thus allowing it to be used
 to configure the default data copying behavior for @command{cp}.
-For example, with the following alias, @command{cp} will use the
-minimum amount of space supported by the file system.
-
-@example
-alias cp='cp --reflink=auto --sparse=always'
-@end example
 
 @item --remove-destination
 @opindex --remove-destination
@@ -8928,6 +8924,15 @@ This is useful in creating a file for use with the @command{mkswap} command,
 since such a file must not have any holes.
 @end table
 
+For example, with the following alias, @command{cp} will use the
+minimum amount of space supported by the file system.
+(Older versions of @command{cp} can also benefit from
+@option{--reflink=auto} here.)
+
+@example
+alias cp='cp --sparse=always'
+@end example
+
 @optStripTrailingSlashes
 
 @item -s
index 874d6f71c0f708e57c95c03ffb9afebb2bde6dda..a0ad494b9384d26423b1cb71a3134aa6dfec63c4 100644 (file)
@@ -46,10 +46,10 @@ enum Sparse_type
 /* Control creation of COW files.  */
 enum Reflink_type
 {
-  /* Default to a standard copy.  */
+  /* Do a standard copy.  */
   REFLINK_NEVER,
 
-  /* Try a COW copy and fall back to a standard copy.  */
+  /* Try a COW copy and fall back to a standard copy; this is the default.  */
   REFLINK_AUTO,
 
   /* Require a COW copy and fail if not available.  */
index 8db2c4b9e2ad3a386b99090349199474961bbe71..a4ecbbc9fc9916a744b235d0207d3e07bb996b59 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -793,7 +793,7 @@ cp_option_init (struct cp_options *x)
   x->move_mode = false;
   x->install_mode = false;
   x->one_file_system = false;
-  x->reflink_mode = REFLINK_NEVER;
+  x->reflink_mode = REFLINK_AUTO;
 
   x->preserve_ownership = false;
   x->preserve_links = false;
index 22124d51b13831c076bcbf43058983cb013f9f51..a94053f4d3b985867719ec026c67acccb5343857 100644 (file)
@@ -264,7 +264,7 @@ cp_option_init (struct cp_options *x)
 {
   cp_options_default (x);
   x->copy_as_regular = true;
-  x->reflink_mode = REFLINK_NEVER;
+  x->reflink_mode = REFLINK_AUTO;
   x->dereference = DEREF_ALWAYS;
   x->unlink_dest_before_opening = true;
   x->unlink_dest_after_failed_open = false;