cp --sparse=always sparse-image-file.img /dev/hda1 could

produce an invalid copy on the destination device.

(copy_reg): Even with --sparse=always, try to
make `holes' only if the destination is a regular file.
Reported by Szakacsits Szabolcs.
This commit is contained in:
Jim Meyering 2004-03-06 17:40:56 +00:00
parent aad4245695
commit 0ede5ec7f9

View File

@ -214,7 +214,7 @@ copy_reg (const char *src_path, const char *dst_path,
int return_val = 0;
off_t n_read_total = 0;
int last_write_made_hole = 0;
int make_holes = (x->sparse_mode == SPARSE_ALWAYS);
int make_holes = 0;
source_desc = open (src_path, O_RDONLY);
if (source_desc < 0)
@ -286,6 +286,11 @@ copy_reg (const char *src_path, const char *dst_path,
buf_size = ST_BLKSIZE (sb);
/* Even with --sparse=always, try to create holes only
if the destination is a regular file. */
if (x->sparse_mode == SPARSE_ALWAYS && S_ISREG (sb.st_mode))
make_holes = 1;
#if HAVE_STRUCT_STAT_ST_BLOCKS
if (x->sparse_mode == SPARSE_AUTO && S_ISREG (sb.st_mode))
{