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