diff options
author | Pádraig Brady <P@draigBrady.com> | 2009-08-26 00:32:43 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2009-08-29 00:24:49 +0100 |
commit | 72f98388c36676e5c9ba6a72df5693c207862204 (patch) | |
tree | f0f54bfdb3a16d87cd180226021de9a7570bd9e7 /src/copy.h | |
parent | f296cf4052c5299c7e6b1c14dcffa4785982a8ce (diff) | |
download | coreutils-72f98388c36676e5c9ba6a72df5693c207862204.tar.gz |
cp --reflink: add an "auto" parameter to fall back to a normal copy
* doc/coreutils.texi (cp invocation): Document the new
"auto" and "always" options to --reflink.
* src/copy.c (copy_reg): Fall back to a standard copy
when reflink() is not supported and --reflink=auto specified.
* src/copy.h [struct cp_options] (reflink): Change type s/bool/enum/.
* src/cp.c (usage): Describe the --reflink={always,auto} options
and expand a little on what --reflink does.
(main): parse the new parameters to --reflink and allow all
--sparse options with --reflink=auto.
* src/install.c (cp_option_init): Init the enum instead of bool.
* src/mv.c (cp_option_init): Likewise.
* tests/cp/reflink-auto: A new test for falling back to normal copy.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the new feature.
Diffstat (limited to 'src/copy.h')
-rw-r--r-- | src/copy.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/copy.h b/src/copy.h index cdef64a7f..745533aec 100644 --- a/src/copy.h +++ b/src/copy.h @@ -43,6 +43,19 @@ enum Sparse_type SPARSE_ALWAYS }; +/* Control creation of COW files. */ +enum Reflink_type +{ + /* Default to a standard copy. */ + REFLINK_NEVER, + + /* Try a COW copy and fall back to a standard copy. */ + REFLINK_AUTO, + + /* Require a COW copy and fail if not available. */ + REFLINK_ALWAYS +}; + /* This type is used to help mv (via copy.c) distinguish these cases. */ enum Interactive { @@ -73,6 +86,11 @@ enum Dereference_symlink || (Mode) == SPARSE_AUTO \ || (Mode) == SPARSE_ALWAYS) +# define VALID_REFLINK_MODE(Mode) \ + ((Mode) == REFLINK_NEVER \ + || (Mode) == REFLINK_AUTO \ + || (Mode) == REFLINK_ALWAYS) + /* These options control how files are copied by at least the following programs: mv (when rename doesn't work), cp, install. So, if you add a new member, be sure to initialize it in @@ -219,8 +237,8 @@ struct cp_options such a symlink) and returns false. */ bool open_dangling_dest_symlink; - /* If true, attempt to clone the file instead of copying it. */ - bool reflink; + /* Control creation of COW files. */ + enum Reflink_type reflink_mode; /* This is a set of destination name/inode/dev triples. Each such triple represents a file we have created corresponding to a source file name |