bug-coreutils
[Top][All Lists]
Advanced

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

Re: cp command - problem with sparse


From: Eric Blake
Subject: Re: cp command - problem with sparse
Date: Wed, 02 Feb 2005 21:07:30 -0700
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to James Youngman on 2/1/2005 3:17 AM:
> 
> Unix systems automatically generate sparse files when programs seek
> forwards on their output file.  There is no need to have a "sparse"
> attribute.  This is what coreutils' "cp" does.  

Right now, the tests/du/8gb test uses dd to try to create a sparse file;
and strace'ing that on cygwin shows that it uses just lseek() followed by
ftruncate() (no intervening write()).  But the code in src/copy.c goes to
great lengths to write() before calling ftruncate(), with the comment that
 "the kernel would truncate the file at the end of the last write
operation".  Which is it?  Is copy doing more work than it should, or
should dd also be doing a write before truncate?  POSIX does say that
ftruncate shall increase the size of the file in XSI systems, but allows
it return an error and keep the size unchanged on non-XSI systems.

I ask, because at the moment, cygwin's implementation only makes a sparse
file on write() after lseek(), although the developers are considering
making ftruncate() after lseek() also create a sparse file.

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCAaOB84KuGfSFAYARAoXxAJ9nbKLwI8fGcdAJ9vVggGwehujbFwCgnIuv
kmBzebHsRNu4iHb7q1vPGE0=
=Wpzz
-----END PGP SIGNATURE-----




reply via email to

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