diff options
author | Giuseppe Scrivano <gscrivano@gnu.org> | 2009-08-01 19:36:48 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-08-07 17:14:22 +0200 |
commit | a1d7469835371ded0ad8e3496bc5a5bebf94ccef (patch) | |
tree | 925945606aa919b7b48603117db6f8ca15e7b551 /src/cp.c | |
parent | ff159a605e5bc10fe871109f66cba5ee410c9138 (diff) | |
download | coreutils-a1d7469835371ded0ad8e3496bc5a5bebf94ccef.tar.xz |
cp: accept the --reflink option
* NEWS: Mention it.
* doc/coreutils.texi (cp invocation): Describe it.
* src/copy.h (struct cp_options) [reflink]: New member.
* src/copy.c (usage): Describe it.
(copy_reg): If reflink is true try to clone the file.
(main): Check for --reflink.
(cp_option_init): Initialize the new member.
* src/install.c (cp_option_init): Initialize the new member.
* src/mv.c (cp_option_init): Likewise.
* tests/cp/sparse: Add a new test case.
Diffstat (limited to 'src/cp.c')
-rw-r--r-- | src/cp.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -76,6 +76,7 @@ enum NO_PRESERVE_ATTRIBUTES_OPTION, PARENTS_OPTION, PRESERVE_ATTRIBUTES_OPTION, + REFLINK_OPTION, SPARSE_OPTION, STRIP_TRAILING_SLASHES_OPTION, UNLINK_DEST_BEFORE_OPENING @@ -121,6 +122,7 @@ static struct option const long_opts[] = {"recursive", no_argument, NULL, 'R'}, {"remove-destination", no_argument, NULL, UNLINK_DEST_BEFORE_OPENING}, {"sparse", required_argument, NULL, SPARSE_OPTION}, + {"reflink", no_argument, NULL, REFLINK_OPTION}, {"strip-trailing-slashes", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION}, {"suffix", required_argument, NULL, 'S'}, {"symbolic-link", no_argument, NULL, 's'}, @@ -190,6 +192,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ -R, -r, --recursive copy directories recursively\n\ + --reflink perform a lightweight (CoW/clone) copy\n\ --remove-destination remove each existing destination file before\n\ attempting to open it (contrast with --force)\n\ "), stdout); @@ -752,6 +755,7 @@ cp_option_init (struct cp_options *x) x->interactive = I_UNSPECIFIED; x->move_mode = false; x->one_file_system = false; + x->reflink = false; x->preserve_ownership = false; x->preserve_links = false; @@ -916,6 +920,10 @@ main (int argc, char **argv) sparse_type_string, sparse_type); break; + case REFLINK_OPTION: + x.reflink = true; + break; + case 'a': /* Like -dR --preserve=all with reduced failure diagnostics. */ x.dereference = DEREF_NEVER; x.preserve_links = true; @@ -1076,6 +1084,12 @@ main (int argc, char **argv) usage (EXIT_FAILURE); } + if (x.reflink && x.sparse_mode != SPARSE_AUTO) + { + error (0, 0, _("--reflink can be used only with --sparse=auto")); + usage (EXIT_FAILURE); + } + if (backup_suffix_string) simple_backup_suffix = xstrdup (backup_suffix_string); |