diff options
author | Pádraig Brady <P@draigBrady.com> | 2014-10-06 11:02:34 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-10-15 02:19:48 +0100 |
commit | cce161dc05c05e1356e6e563e7628637cc54a134 (patch) | |
tree | d35985c9f0054cedf235a1013721400b0d2ac320 /src | |
parent | eafa6ebf10924ec36cb5d28fd9d97a23de089bd0 (diff) | |
download | coreutils-cce161dc05c05e1356e6e563e7628637cc54a134.tar.xz |
cp: read sparse files more efficiently with non regular destination
* src.copy.c (copy_reg): Use fiemap to read sparse files, even
if the output is not to a regular file.
* NEWS: Mention the improvement.
Diffstat (limited to 'src')
-rw-r--r-- | src/copy.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/copy.c b/src/copy.c index 85a4c5965..b8e12c2bd 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1214,7 +1214,7 @@ copy_reg (char const *src_name, char const *dst_name, /* Deal with sparse files. */ bool make_holes = false; - bool sparse_src = false; + bool sparse_src = is_probably_sparse (&src_open_sb); if (S_ISREG (sb.st_mode)) { @@ -1227,7 +1227,6 @@ copy_reg (char const *src_name, char const *dst_name, blocks. If the file has fewer blocks than would normally be needed for a file of its size, then at least one of the blocks in the file is a hole. */ - sparse_src = is_probably_sparse (&src_open_sb); if (x->sparse_mode == SPARSE_AUTO && sparse_src) make_holes = true; } @@ -1270,7 +1269,7 @@ copy_reg (char const *src_name, char const *dst_name, any extents to read more efficiently. */ if (extent_copy (source_desc, dest_desc, buf, buf_size, hole_size, src_open_sb.st_size, - S_ISREG (sb.st_mode) ? x->sparse_mode : SPARSE_NEVER, + make_holes ? x->sparse_mode : SPARSE_NEVER, src_name, dst_name, &normal_copy_required)) goto preserve_metadata; |