diff options
author | Pádraig Brady <P@draigBrady.com> | 2014-10-07 19:48:53 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-10-15 02:19:48 +0100 |
commit | 84616da89dbfc81e22f8c2fd077f1d61d788522c (patch) | |
tree | 4af9c72d495fbfc51d7db3e5636748c1b997196a /src | |
parent | cce161dc05c05e1356e6e563e7628637cc54a134 (diff) | |
download | coreutils-84616da89dbfc81e22f8c2fd077f1d61d788522c.tar.xz |
copy: avoid an extraneous error when reporting errors
* src/copy.c (copy_reg): If sparse_copy() failed, then an
erroneous error about failing to extend the file would be reported.
Diffstat (limited to 'src')
-rw-r--r-- | src/copy.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/copy.c b/src/copy.c index b8e12c2bd..446e72d6d 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1282,13 +1282,16 @@ copy_reg (char const *src_name, char const *dst_name, off_t n_read; bool wrote_hole_at_eof; - if ( ! sparse_copy (source_desc, dest_desc, buf, buf_size, - make_holes ? hole_size : 0, - x->sparse_mode == SPARSE_ALWAYS, src_name, dst_name, - UINTMAX_MAX, &n_read, - &wrote_hole_at_eof) - || (wrote_hole_at_eof - && ftruncate (dest_desc, n_read) < 0)) + if (! sparse_copy (source_desc, dest_desc, buf, buf_size, + make_holes ? hole_size : 0, + x->sparse_mode == SPARSE_ALWAYS, src_name, dst_name, + UINTMAX_MAX, &n_read, + &wrote_hole_at_eof)) + { + return_val = false; + goto close_src_and_dst_desc; + } + else if (wrote_hole_at_eof && ftruncate (dest_desc, n_read) < 0) { error (0, errno, _("failed to extend %s"), quote (dst_name)); return_val = false; |