[PATCH] adding two new options to 'cp'

Rick C. Petty rick-freebsd at kiwi-computer.com
Tue Aug 1 17:40:50 UTC 2006


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.

One of my biggest gripes with cp(1) was how a recursive tree copy was
always larger than the source, if the source contained any sparse files.
This is similar to your desire to add "-l" for doing hard links.  Both
have their usefulness.  And your "-a" option could be a replacement for
"-pRs" if so desired (or "-S", it's all the same to me).

While we're at it, I think we should add the -S option to bsdtar.  I'm
willing to do the work and make patches (to cp & tar), if someone is
willing to review and commit them.

-- Rick C. Petty


More information about the freebsd-hackers mailing list