bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cp --sparse might corrupt DEST


From: Szakacsits Szabolcs
Subject: cp --sparse might corrupt DEST
Date: Wed, 25 Feb 2004 20:37:47 +0100 (MET)

On Wed, 25 Feb 2004, Szakacsits Szabolcs wrote:
> On Wed, 25 Feb 2004, Per Olofsson wrote:
> 
> > This is what I thought would be unreliable:
> > 
> > cp --sparse=always sparse-image-file.img /dev/hda1
> > 
> > But since you're saying that cp won't allow that, this apparently
> > isn't an issue.
> 
> You were right. Unfortunately this is possible and nobody should ever use
> it. I must definitely mention this in the ntfsclone manual ... thank you!

I had some time to think about the issue, not just quickly answer email ;)

Actually it's a bug in cp. What's cp job? To copy files reliable. Can it
do that when used in the above case (block device as the destination)? No.

Sure it's a bug. If cp detects sparseness in the source file it will skip
on the destination file and leave the skipped data unchanged. Source and
destination won't be the same. It wasn't a copy operation. cp should fill
those skipped areas with zeros, well actually never skip in these cases.

cp should check the file type of the destination and if it's block device
then fallback to --sparse=never.

% cp --version
cp (coreutils) 5.0

        Szaka





reply via email to

[Prev in Thread] Current Thread [Next in Thread]