Use ftruncate() at the end of a --sparse file.