bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] Superfluous zero blocks following sparse files


From: Sergey Poznyakoff
Subject: Re: [Bug-tar] Superfluous zero blocks following sparse files
Date: Fri, 19 Jan 2007 15:49:53 +0200

Hello, Lars
 
> I discovered a problem in tar 1.16.1 when I archive sparse
> files. The options I use are "--posix --sparse".

Thanks for reporting that. Here is the fix:

Index: src/sparse.c
===================================================================
RCS file: /cvsroot/tar/tar/src/sparse.c,v
retrieving revision 1.25
diff -p -u -r1.25 sparse.c
--- src/sparse.c        25 Jun 2006 12:45:16 -0000      1.25
+++ src/sparse.c        19 Jan 2007 13:47:10 -0000
@@ -466,7 +466,7 @@ sparse_skip_file (struct tar_stat_info *
   file.fd = -1;
 
   rc = tar_sparse_decode_header (&file);
-  skip_file (file.stat_info->archive_file_size);
+  skip_file (file.stat_info->archive_file_size - file.dumped_size);
   return (tar_sparse_done (&file) && rc) ? dump_status_ok : dump_status_short;
 }
 
@@ -1014,6 +1014,7 @@ pax_dump_header_1 (struct tar_sparse_fil
     }
   size = (size + BLOCKSIZE - 1) / BLOCKSIZE;
   file->stat_info->archive_file_size += size * BLOCKSIZE;
+  file->dumped_size += size * BLOCKSIZE;
   
   /* Store sparse file identification */
   xheader_store ("GNU.sparse.major", file->stat_info, NULL);
@@ -1104,7 +1105,8 @@ pax_decode_header (struct tar_sparse_fil
        if (src == endp)                                            \
         {                                                         \
           set_next_block_after (b);                               \
-          b = find_next_block ();                                 \
+           file->dumped_size += BLOCKSIZE;                         \
+           b = find_next_block ();                                 \
            src = b->buffer;                                        \
           endp = b->buffer + BLOCKSIZE;                           \
         }                                                         \
@@ -1115,6 +1117,7 @@ pax_decode_header (struct tar_sparse_fil
  } while (0)                       
 
       set_next_block_after (current_header);
+      file->dumped_size += BLOCKSIZE;
       blk = find_next_block ();
       p = blk->buffer;
       COPY_BUF (blk,nbuf,p);

Regards,
Sergey
       




reply via email to

[Prev in Thread] Current Thread [Next in Thread]