-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Larry Ploetz wrote:
> Or ripping cp's "crude heuristic" out and
> putting it here.
That's probably your best bet. It doesn't look too complex:
/* Even with --sparse=always, try to create holes only
if the destination is a regular file. */
if (x->sparse_mode == SPARSE_ALWAYS && S_ISREG (sb.st_mode))
make_holes = true;
#if HAVE_STRUCT_STAT_ST_BLOCKS
if (x->sparse_mode == SPARSE_AUTO && S_ISREG (sb.st_mode))
{
/* Use a heuristic to determine whether SRC_NAME contains any
sparse blocks. */
if (fstat (source_desc, &sb))
{
error (0, errno, _("cannot fstat %s"), quote (src_name));
return_val = false;
goto close_src_and_dst_desc;
}
/* If the file has fewer blocks than would normally
be needed for a file of its size, then
at least one of the blocks in the file is a hole. */
if (S_ISREG (sb.st_mode)
&& sb.st_size / ST_NBLOCKSIZE > ST_NBLOCKS (sb))
make_holes = true;
}
#endif
The loop where it does the actual file copying is a bit longer and more
complex (long enough to be annoying in an email), but can be found in
copy.c in the coreutils srpm. Hopefully it should be possible to copy
the ideas to logrotate.
Let me know if you'd like my help.
- -- Pat
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAklpY6AACgkQNObCqA8uBswTwQCbBkQNMk7+ebbuQoTJp8D9VH7B
Fd4AnRWc/n2VoxvZV5PHz/ZPzGv6xKnl
=NRzg
-----END PGP SIGNATURE-----
----------------------------------------------------------------------
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