diff options
author | Jim Meyering <jim@meyering.net> | 2004-03-06 17:40:56 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2004-03-06 17:40:56 +0000 |
commit | 0ede5ec7f9de3cf6d79c80184420feadddea9b4b (patch) | |
tree | ba2ee94579bbb3507fa89a93881e32c6ea94d0ed /src | |
parent | aad4245695797b9cbdd3bd51376d9e6c3112b6c1 (diff) | |
download | coreutils-0ede5ec7f9de3cf6d79c80184420feadddea9b4b.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/copy.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/copy.c b/src/copy.c index b38b535ae..8685234e5 100644 --- a/src/copy.c +++ b/src/copy.c @@ -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)) { |