|
|
e63663 |
From 76126e2831580d0df20530f4d6f72189bd4f0b9a Mon Sep 17 00:00:00 2001
|
|
|
e63663 |
From: Paul Eggert <eggert@cs.ucla.edu>
|
|
|
e63663 |
Date: Thu, 18 Jun 2020 22:16:24 -0700
|
|
|
e63663 |
Subject: [PATCH] cp: default to COW
|
|
|
e63663 |
MIME-Version: 1.0
|
|
|
e63663 |
Content-Type: text/plain; charset=UTF-8
|
|
|
e63663 |
Content-Transfer-Encoding: 8bit
|
|
|
e63663 |
|
|
|
e63663 |
Likewise for ‘install’. Proposed in Bug#24400, and long past due.
|
|
|
e63663 |
* NEWS:
|
|
|
e63663 |
* doc/coreutils.texi (cp invocation):
|
|
|
e63663 |
* src/copy.h (enum Reflink_type): Document this.
|
|
|
e63663 |
* src/cp.c (cp_option_init):
|
|
|
e63663 |
* src/install.c (cp_option_init): Implement this.
|
|
|
e63663 |
|
|
|
e63663 |
Upstream-commit: 25725f9d41735d176d73a757430739fb71c7d043
|
|
|
e63663 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
e63663 |
---
|
|
|
e63663 |
doc/coreutils.texi | 19 ++++++++++++-------
|
|
|
e63663 |
src/copy.h | 4 ++--
|
|
|
e63663 |
src/cp.c | 2 +-
|
|
|
e63663 |
src/install.c | 2 +-
|
|
|
e63663 |
4 files changed, 16 insertions(+), 11 deletions(-)
|
|
|
e63663 |
|
|
|
e63663 |
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
|
|
|
e63663 |
index 02e0c1c..2382a16 100644
|
|
|
e63663 |
--- a/doc/coreutils.texi
|
|
|
e63663 |
+++ b/doc/coreutils.texi
|
|
|
e63663 |
@@ -8854,12 +8854,14 @@ The @var{when} value can be one of the following:
|
|
|
e63663 |
|
|
|
e63663 |
@table @samp
|
|
|
e63663 |
@item always
|
|
|
e63663 |
-The default behavior: if the copy-on-write operation is not supported
|
|
|
e63663 |
+If the copy-on-write operation is not supported
|
|
|
e63663 |
then report the failure for each file and exit with a failure status.
|
|
|
e63663 |
+Plain @option{--reflink} is equivalent to @option{--reflink=when}.
|
|
|
e63663 |
|
|
|
e63663 |
@item auto
|
|
|
e63663 |
If the copy-on-write operation is not supported then fall back
|
|
|
e63663 |
to the standard copy behavior.
|
|
|
e63663 |
+This is the default if no @option{--reflink} option is given.
|
|
|
e63663 |
|
|
|
e63663 |
@item never
|
|
|
e63663 |
Disable copy-on-write operation and use the standard copy behavior.
|
|
|
e63663 |
@@ -8868,12 +8870,6 @@ Disable copy-on-write operation and use the standard copy behavior.
|
|
|
e63663 |
This option is overridden by the @option{--link}, @option{--symbolic-link}
|
|
|
e63663 |
and @option{--attributes-only} options, thus allowing it to be used
|
|
|
e63663 |
to configure the default data copying behavior for @command{cp}.
|
|
|
e63663 |
-For example, with the following alias, @command{cp} will use the
|
|
|
e63663 |
-minimum amount of space supported by the file system.
|
|
|
e63663 |
-
|
|
|
e63663 |
-@example
|
|
|
e63663 |
-alias cp='cp --reflink=auto --sparse=always'
|
|
|
e63663 |
-@end example
|
|
|
e63663 |
|
|
|
e63663 |
@item --remove-destination
|
|
|
e63663 |
@opindex --remove-destination
|
|
|
e63663 |
@@ -8918,6 +8914,15 @@ This is useful in creating a file for use with the @command{mkswap} command,
|
|
|
e63663 |
since such a file must not have any holes.
|
|
|
e63663 |
@end table
|
|
|
e63663 |
|
|
|
e63663 |
+For example, with the following alias, @command{cp} will use the
|
|
|
e63663 |
+minimum amount of space supported by the file system.
|
|
|
e63663 |
+(Older versions of @command{cp} can also benefit from
|
|
|
e63663 |
+@option{--reflink=auto} here.)
|
|
|
e63663 |
+
|
|
|
e63663 |
+@example
|
|
|
e63663 |
+alias cp='cp --sparse=always'
|
|
|
e63663 |
+@end example
|
|
|
e63663 |
+
|
|
|
e63663 |
@optStripTrailingSlashes
|
|
|
e63663 |
|
|
|
e63663 |
@item -s
|
|
|
e63663 |
diff --git a/src/copy.h b/src/copy.h
|
|
|
e63663 |
index 874d6f7..a0ad494 100644
|
|
|
e63663 |
--- a/src/copy.h
|
|
|
e63663 |
+++ b/src/copy.h
|
|
|
e63663 |
@@ -46,10 +46,10 @@ enum Sparse_type
|
|
|
e63663 |
/* Control creation of COW files. */
|
|
|
e63663 |
enum Reflink_type
|
|
|
e63663 |
{
|
|
|
e63663 |
- /* Default to a standard copy. */
|
|
|
e63663 |
+ /* Do a standard copy. */
|
|
|
e63663 |
REFLINK_NEVER,
|
|
|
e63663 |
|
|
|
e63663 |
- /* Try a COW copy and fall back to a standard copy. */
|
|
|
e63663 |
+ /* Try a COW copy and fall back to a standard copy; this is the default. */
|
|
|
e63663 |
REFLINK_AUTO,
|
|
|
e63663 |
|
|
|
e63663 |
/* Require a COW copy and fail if not available. */
|
|
|
e63663 |
diff --git a/src/cp.c b/src/cp.c
|
|
|
e63663 |
index 0193df8..9e7ad14 100644
|
|
|
e63663 |
--- a/src/cp.c
|
|
|
e63663 |
+++ b/src/cp.c
|
|
|
e63663 |
@@ -796,7 +796,7 @@ cp_option_init (struct cp_options *x)
|
|
|
e63663 |
x->move_mode = false;
|
|
|
e63663 |
x->install_mode = false;
|
|
|
e63663 |
x->one_file_system = false;
|
|
|
e63663 |
- x->reflink_mode = REFLINK_NEVER;
|
|
|
e63663 |
+ x->reflink_mode = REFLINK_AUTO;
|
|
|
e63663 |
|
|
|
e63663 |
x->preserve_ownership = false;
|
|
|
e63663 |
x->preserve_links = false;
|
|
|
e63663 |
diff --git a/src/install.c b/src/install.c
|
|
|
e63663 |
index 4ab44a6..aef16ca 100644
|
|
|
e63663 |
--- a/src/install.c
|
|
|
e63663 |
+++ b/src/install.c
|
|
|
e63663 |
@@ -264,7 +264,7 @@ cp_option_init (struct cp_options *x)
|
|
|
e63663 |
{
|
|
|
e63663 |
cp_options_default (x);
|
|
|
e63663 |
x->copy_as_regular = true;
|
|
|
e63663 |
- x->reflink_mode = REFLINK_NEVER;
|
|
|
e63663 |
+ x->reflink_mode = REFLINK_AUTO;
|
|
|
e63663 |
x->dereference = DEREF_ALWAYS;
|
|
|
e63663 |
x->unlink_dest_before_opening = true;
|
|
|
e63663 |
x->unlink_dest_after_failed_open = false;
|
|
|
e63663 |
--
|
|
|
e63663 |
2.25.4
|
|
|
e63663 |
|