]> arthur.barton.de Git - bup.git/commit
Rework write_sparsely() to fix in-buffer zero runs
authorRob Browning <rlb@defaultvalue.org>
Sun, 15 Mar 2015 21:43:47 +0000 (16:43 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sat, 28 Mar 2015 16:59:15 +0000 (11:59 -0500)
commit534c64edcf41a5f57010aec6447dcf5bcb5d2b57
tree9e3c6eac4a982870424603fbaa365b9325feff66
parentbc95228067069baef92d9085ee925d3bae89d70d
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>
lib/bup/_helpers.c
t/test-sparse-files.sh