Rework write_sparsely() to fix in-buffer zero runs
Fix the sparse restoration of buffers that have non-zero bytes, followed
by a run of zero bytes that's longer than the minimum sparse run
length (currently 512), followed by non-zero bytes.
Previously, the initial non-zero bytes would be *lost*.
In the new code, don't unconditionally output previous zero bytes --
merge them with any leading zeros in the current block.
And allow arbitrarily large sparse regions; use append_sparse_region()
to break up runs that are too large for off_t into a sequence of seeks
of no more than INT_MAX bytes each.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>