Two sparse fixes from Yuxuan Shui.
authorWayne Davison <wayne@opencoder.net>
Mon, 25 May 2020 21:01:52 +0000 (14:01 -0700)
committerWayne Davison <wayne@opencoder.net>
Mon, 25 May 2020 21:01:52 +0000 (14:01 -0700)
- Make "len" parameter of do_punch_hole an OFF_T.
- Clear sparse_past_write in sparse_end(), otherwise when write_sparse()
  is called for the next file, do_punch_hole() will be called with a pos
  that's not actually the current position in file, causing it to fail.

fileio.c
syscall.c

index bd2e36ae3cff51826266d332c6612950c9e9c5e5..32dc62da9d6a833e9c69014425eec87f785fa27d 100644 (file)
--- a/fileio.c
+++ b/fileio.c
@@ -44,6 +44,8 @@ int sparse_end(int f, OFF_T size)
 {
        int ret;
 
+       sparse_past_write = 0;
+
        if (!sparse_seek)
                return 0;
 
index e1a02a3c6a61b6b8a94c4529692f08b1222c2b65..e8ce7d5c61c1295ac2e2c6ef8ec01e2d5d8ac184 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -523,7 +523,7 @@ OFF_T do_fallocate(int fd, OFF_T offset, OFF_T length)
 
 /* Punch a hole at pos for len bytes. The current file position must be at pos and will be
  * changed to be at pos + len. */
-int do_punch_hole(int fd, UNUSED(OFF_T pos), int len)
+int do_punch_hole(int fd, UNUSED(OFF_T pos), OFF_T len)
 {
 #ifdef HAVE_FALLOCATE
 # ifdef HAVE_FALLOC_FL_PUNCH_HOLE