shared: Ensure COPY_HOLES copies trailing holes
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 26 Jan 2022 12:08:50 +0000 (12:08 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 26 Jan 2022 16:15:22 +0000 (01:15 +0900)
commitf82f0b993740f4a9a3719c4df7c185411710df2b
tree5efe212f6730da41995d5b05b1fa2ffbfdc2dc8e
parente3f7ed944ae750a40685c52349f3cc850db0876e
shared: Ensure COPY_HOLES copies trailing holes

Previously, files with a hole at the end would get silently truncated
which breaks reading journal files. This commit makes sure that holes
are punched in existing space and if no more space is available, that
we grow the file and the hole by using ftruncate().

The corresponding test is extended to put a hole at the end of the file
and we make sure that hole is copied correctly.
src/shared/copy.c
src/test/test-copy.c