mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-21 11:16:16 +02:00
cp,install,mv: add --debug to explain how a file is copied
How a file is copied is dependent on the sparseness of the file,
what file system it is on, what file system the destination is on,
the attributes of the file, and whether they're being copied or not.
Also the --reflink and --sparse options directly impact the operation.
Given it's hard to reason about the combination of all of the above,
the --debug option is useful for users to directly identify if
copy offloading, reflinking, or sparse detection are being used.
It will also be useful for tests to directly query if
these operations are supported.
The new output looks as follows:
$ src/cp --debug src/cp file.sparse
'src/cp' -> 'file.sparse'
copy offload: yes, reflink: unsupported, sparse detection: no
$ truncate -s+1M file.sparse
$ src/cp --debug file.sparse file.sparse.cp
'file.sparse' -> 'file.sparse.cp'
copy offload: yes, reflink: unsupported, sparse detection: SEEK_HOLE
$ src/cp --reflink=never --debug file.sparse file.sparse.cp
'file.sparse' -> 'file.sparse.cp'
copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE
* doc/coreutils.texi (cp invocation): Describe the --debug option.
(mv invocation): Likewise.
(install invocation): Likewise.
* src/copy.h: Add a new DEBUG member to cp_options, to control
whether to output debug info or not.
* src/copy.c (copy_debug): A new global structure to
unconditionally store debug into from the last copy_reg operations.
(copy_debug_string, emit_debug): New functions to print debug info.
* src/cp.c: if ("--debug") x->debug=true;
* src/install.c: Likewise.
* src/mv.c: Likewise.
* tests/cp/debug.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
This commit is contained in:
@@ -8922,6 +8922,15 @@ Copy symbolic links as symbolic links rather than copying the files that
|
||||
they point to, and preserve hard links between source files in the copies.
|
||||
Equivalent to @option{--no-dereference --preserve=links}.
|
||||
|
||||
@macro optDebugCopy
|
||||
@item --debug
|
||||
@opindex --debug
|
||||
@cindex debugging, copying
|
||||
Print extra information to stdout, explaining how files are copied.
|
||||
This option implies the @option{--verbose} option.
|
||||
@end macro
|
||||
@optDebugCopy
|
||||
|
||||
@item -f
|
||||
@itemx --force
|
||||
@opindex -f
|
||||
@@ -9959,6 +9968,8 @@ Create any missing parent directories, giving them the default
|
||||
attributes. Then create each given directory, setting their owner,
|
||||
group and mode as given on the command line or to the defaults.
|
||||
|
||||
@optDebugCopy
|
||||
|
||||
@item -g @var{group}
|
||||
@itemx --group=@var{group}
|
||||
@opindex -g
|
||||
@@ -10121,6 +10132,8 @@ The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@optBackup
|
||||
|
||||
@optDebugCopy
|
||||
|
||||
@item -f
|
||||
@itemx --force
|
||||
@opindex -f
|
||||
|
||||
Reference in New Issue
Block a user