[PATCH] adding two new options to 'cp'

Julian Elischer julian at elischer.org
Tue Aug 1 18:54:39 UTC 2006


Eric Anderson wrote:

> On 08/01/06 12:40, Rick C. Petty wrote:
>
>> On Tue, Aug 01, 2006 at 12:27:54PM -0500, Eric Anderson wrote:
>>
>>> Wouldn't this be incorrect for files that are really full of zeros?  
>>> It would turn them in to sparse files when they shouldn't be, 
>>> correct?  Is that what happens with other tools?
>>
>>
>> Why is this bad?  I'm not suggesting that the default implementation
>> should change but that this "-s" option be added to properly optimize
>> for sparse files.  A sparse file is one which contains blocks of pure
>> zeros.  My example wouldn't vary in how the destination file is read
>> but in how many blocks are allocated in the underlying file system.
>
>
> It could possibly be bad if you have a real file (say a 10GB file, 
> partially filled with zeros - a disk image created with dd for 
> instance), and you use cp with something like -spR to recursively copy 
> all files.  Your destination disk image would then be a sparse file, 
> so additional changes and modifications to the file (block 
> allocations) would fragment the image and make it slower.  That would 
> be unexpected and probably go unnoticed for some time.  I do see the 
> usefulness in this, but I think one needs to be careful to either 
> clearly note in the man page that it will make sparse files from *any* 
> file containing a string of zeros larger than the block size, or it 
> needs to 'do the right thing' and determine if it's sparse or not.
>

the option to copy sparsly is an option and not forced down the user's 
throat.
I agree it would be a useful OPTION.
at the moment there is no way to "sparsify" :-)   a file easily.
As long as the documentation warns that copying it without the sparse 
option
might unexpectedly fill up your disk (or whatever your favourite trap is)
then, it is UNIX's job to give you all teh tools you need
and your job to decide when and where you shoot yorself in the foot.

to "approximatly" quote Terry Lambert:
" It is not unix's job to stop you from shooting your foot. If you so 
choose to
do so, then it is UNIX's job to deliver Mr. Bullet to Mr Foot in the 
most efficient
way it knows."

> Eric
>


More information about the freebsd-hackers mailing list