copy: don't let a failed lseek go undiagnosed
authorJim Meyering <meyering@redhat.com>
Sat, 5 Feb 2011 21:40:57 +0000 (22:40 +0100)
committerJim Meyering <meyering@redhat.com>
Sat, 5 Feb 2011 21:40:57 +0000 (22:40 +0100)
commit9f618068755b51d19b22c52bc4a2f8084946948e
treede378f0ac43363d6ab6e078721df36773b44c2b2
parent661413d8c3654e8418c5b5aab36bdba13296c8e1
copy: don't let a failed lseek go undiagnosed

Upon failed lseek, sparse_copy_finalize would mistakenly return true.
Admittedly, that is very unlikely, since that particular lseek
is attempted only if the preceding call to sparse_copy induced
a hole at EOF (via lseek on the destination FD).  However, now
that sparse_copy has an output parameter, N_READ, there is no
longer any reason to call lseek (fd, 0, SEEK_CUR), so...
* src/copy.c (sparse_copy_finalize): Remove the function.
(copy_reg): Call ftruncate with n_read, rather than
sparse_copy_finalize with its now-unnecessary lseek.
Lasse Collin spotted the bug in sparse_copy_finalize.
src/copy.c