[PATCH] adding two new options to 'cp'

Ivan Voras ivoras at fer.hr
Tue Aug 1 21:49:06 UTC 2006


Mike Meyer wrote:

> I always think of cp as a tool for making *copies of files*, not for
> creating an archive of a directory tree. We've got lots of tools that
> do the latter. Do we really need another one?

But, but, but - I only asked for cp to be able to copy my sparse files 
as sparse files, not do magic with them :)

The side-effect that it will sparsify other files is both unavoidable 
and actually useful.

OTOH, for copying/sparisfying single files, dd should be fixed.

vsdev:/tmp> l
total 2
drwx------  2 ivoras  wheel  512 Jul  9 00:08 mc-ivoras/
vsdev:/tmp> dd if=/dev/zero of=file bs=1024 seek=100 count=1
1+0 records in
1+0 records out
1024 bytes transferred in 0.016648 secs (61509 bytes/sec)
vsdev:/tmp> l
total 8
-rw-r--r--  1 ivoras  wheel  103424 Aug  1 21:40 file
drwx------  2 ivoras  wheel     512 Jul  9 00:08 mc-ivoras/
vsdev:/tmp> du -shc file
6.0K    file
6.0K    total
vsdev:/tmp> l
total 8
-rw-r--r--  1 ivoras  wheel  103424 Aug  1 21:40 file
drwx------  2 ivoras  wheel     512 Jul  9 00:08 mc-ivoras/
vsdev:/tmp> dd if=file of=file2 bs=1024 conv=sparse
101+0 records in
101+0 records out
103424 bytes transferred in 0.130216 secs (794250 bytes/sec)
vsdev:/tmp> l
total 110
-rw-r--r--  1 ivoras  wheel  103424 Aug  1 21:40 file
-rw-r--r--  1 ivoras  wheel  103424 Aug  1 21:41 file2
drwx------  2 ivoras  wheel     512 Jul  9 00:08 mc-ivoras/
vsdev:/tmp> du -shc file*
6.0K    file
102K    file2
108K    total



More information about the freebsd-hackers mailing list