On 1/7/09 1:44 PM, John Summerfield wrote:

I see no reason logrotate should not handle sparse files well when
copying them.

Yeah, there's no reason why it shouldn't, but it doesn't (see my empiric
test in previous post).


06:42 [sum...@numbat ~]$ cp --help | grep sparse
      --sparse=WHEN            control creation of sparse files

This is probably the best way of cleaning the NULs people are concerned
about.

I've always interpreted "crude heuristic" to mean that cp reads all the
virtual \x00's, but writes sparsely. Since what I want with sparse log
files, where the sparse-ness is always at the beginning (corresponding
to the previously archived portions of the log file),  this didn't seem
as efficient as skipping over the beginning blocks that were only sparse:

$ man cp | grep -iwC1 sparse
       --sparse=WHEN
              control creation of sparse files

--

       By default, sparse SOURCE files are detected by a crude
heuristic  and
       the  corresponding  DEST  file  is  made  sparse as well.  That
is the
       behavior selected by --sparse=auto.  Specify --sparse=always to
create
       a  sparse  DEST  file  whenever the SOURCE file contains a long
enough
       sequence of zero bytes.  Use --sparse=never  to  inhibit
creation  of
       sparse files.

And since it's so easy to determine which block first contains real
data, I figured, "why not start copying there?"

Again, this is only for log files -- only appended to, for when they get
sparse because of logrotate copytruncate or "> filename" or similar
truncation, sparse-ness at the beginning of the file.

- Larry

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to