AW: WG: cp command - problem with sparse [sparse file support under NTFS (Win2k)]
Wed Feb 2 12:33:00 GMT 2005
I am not sure whether this is a 128 k problem. I tested with a file that
had 1 MB of data at the beginning and another 1 MB of data at the end. In
between there were some 18 MB of zeroes (checked this with a hex-editor).
I produced that file by using eMule for downloading random files. So, I
could produce a real sparse file on my NTFS volume which was 20 MB in
properties but only occupied 2 MB on my disk. The sparse attribute was
properly set as well (checked with fsutil.exe from WinXP)
However, even when I tried to copy that file -- which was already
"sparse" -- with cp.exe to another folder on the same disk, the sparse
attribute was gone and the file now occupied 20 MB of disk space.
To me it looks as if neither the copy command for copying already existing
sparse files, nor the copy command for producing sparse files from files
with "holes" works on Windows NTFS 5.0-
Once again, this is the commands I typed in:
"cp --sparse=always c:\test.cfg c:\test2.cfg"
Hope I sent this mail to the correct address now, because I had some
problems with being blacklisted at cygwin.com, at least that's what an
autoresponder told me.
Cheers for now,
Von: Corinna Vinschen [mailto:firstname.lastname@example.org]
Gesendet: Mittwoch, 2. Februar 2005 12:21
Betreff: Re: WG: cp command - problem with sparse [sparse file suuport
under NTFS (Win2k)]
[Please don't CC me, send everything just to the ML]
On Feb 2 11:29, RE wrote:
> Hi Corinna,
> Eric Blake send me a mail with a reference to your post
> Well, I am not a programmer but I am looking for a solution for the
> following. And I think that cp.exe from fileutils/coreutils might do the
> job. But so far I wasn't successful.
> I have files on my HD that contain large amounts of zeroes (between 4 and
> 100 MB of zeroes) and I want to convert them into sparse files. I already
> tried the GNU fileutils with their cp command. They say that it converts
> standard files into sparse files by using the command
> "cp --sparse=always c:\test.cfg c:\test2.cfg"
> Everything works fine with that cp command, except the fact that I do not
> get a sparse file. Even when I copy a sparse file, the sparse attribute
> no longer present in the copy and the occupied space on my HD is the same
> with the original file.
> What am I doing wrong? Is there a bug with cp.exe? Is the command I am
> using not correct?
That's something which has to be debugged. Erik, your call. The question
is, does cp use lseek to skip over 128K of 0-bits and then simply writes
further? What Cygwin does is this, basically:
did_lseek = true;
if (current_position > actual_length)
if (filesystem supports sparse
AND current_position >= actual_length + (128 * 1024))
If make_file_sparse doesn't work, the strace will have an entry along
the lines of
0 = DeviceIoControl(1234, FSCTL_SET_SPARSE, ...
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader mailto:email@example.com
Red Hat, Inc.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
More information about the Cygwin