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

rpms/tar/FC-3 tar-1.14-lseek.patch, NONE, 1.1 tar-1.14-skipSparseFile.patch, NONE, 1.1 tar-1.14-spMapSizeInit.patch, NONE, 1.1 tar-1.14-sparseTotals.patch, NONE, 1.1 tar.spec, 1.15, 1.16



Author: pvrabec

Update of /cvs/dist/rpms/tar/FC-3
In directory cvs.devel.redhat.com:/tmp/cvs-serv6251

Modified Files:
	tar.spec 
Added Files:
	tar-1.14-lseek.patch tar-1.14-skipSparseFile.patch 
	tar-1.14-spMapSizeInit.patch tar-1.14-sparseTotals.patch 
Log Message:
- A file is dumpable if it is sparse and both --sparse
  and --totals are specified (#154882)
- exclude err.patch, it causes SEGV (#158743)
- Extract sparse files even if the output fd is not seekable. (#146225)
- (sparse_scan_file): Bugfix. offset had incorrect type
- (sparse_add_map): Fixed improper initializations of sparse_map_size
- fix skipping sparse members in archive(#143969)


tar-1.14-lseek.patch:
 sparse.c |   73 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 59 insertions(+), 14 deletions(-)

--- NEW FILE tar-1.14-lseek.patch ---
--- tar-1.14/src/sparse.c.lseek	2004-09-06 13:30:57.000000000 +0200
+++ tar-1.14/src/sparse.c	2005-04-15 10:33:17.990735744 +0200
@@ -46,6 +46,9 @@
 struct tar_sparse_file
 {
   int fd;                           /* File descriptor */
+  bool seekable;                    /* Is fd seekable? */
+  size_t offset;                    /* Current offset in fd if seekable==false.
+				       Otherwise unused */
   size_t dumped_size;               /* Number of bytes actually written
 				       to the archive */
   struct tar_stat_info *stat_info;  /* Information about the file */
@@ -54,6 +57,39 @@
 				       reqiure */
 };
 
+/* Dump zeros to file->fd until offset is reached. It is used instead of
+   lseek if the output file is not seekable */
+static long
+dump_zeros (struct tar_sparse_file *file, off_t offset)
+{
+  char buf[BLOCKSIZE];
+  
+  if (offset - file->offset < 0)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  memset (buf, 0, sizeof buf);
+  while (file->offset < offset)
+    {
+      size_t size = offset - file->offset;
+      size_t wrbytes;
+      
+      if (size > sizeof buf)
+	size = sizeof buf;
+      wrbytes = write (file->fd, buf, size);
+      if (wrbytes <= 0)
+	{
+	  if (wrbytes == 0)
+	    errno = EINVAL;
+	  return -1;
+	}
+      file->offset += wrbytes;
+    }
+  return file->offset;
+}
+
 static bool
 tar_sparse_member_p (struct tar_sparse_file *file)
 {
@@ -130,9 +166,16 @@
 
 
 static bool
-lseek_or_error (struct tar_sparse_file *file, off_t offset, int whence)
+lseek_or_error (struct tar_sparse_file *file, off_t offset)
 {
-  if (lseek (file->fd, offset, whence) < 0)
+  off_t off;
+
+  if (file->seekable)
+    off = lseek (file->fd, offset, SEEK_SET);
+  else
+    off = dump_zeros (file, offset);
+  
+  if (off < 0)
     {
       seek_diag_details (file->stat_info->orig_file_name, offset);
       return false;
@@ -182,10 +225,10 @@
 {
   static char buffer[BLOCKSIZE];
   size_t count;
-  size_t offset = 0;
+  off_t offset = 0;
   struct sp_array sp = {0, 0};
 
-  if (!lseek_or_error (file, 0, SEEK_SET))
+  if (!lseek_or_error (file, 0))
     return false;
   clear_block (buffer);
 
@@ -269,8 +312,7 @@
   union block *blk;
   off_t bytes_left = file->stat_info->sparse_map[i].numbytes;
 
-  if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset,
-		       SEEK_SET))
+  if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset))
     return false;
 
   while (bytes_left > 0)
@@ -304,8 +346,7 @@
 {
   size_t write_size;
 
-  if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset,
-		       SEEK_SET))
+  if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset))
     return false;
 
   write_size = file->stat_info->sparse_map[i].numbytes;
@@ -313,7 +354,7 @@
   if (write_size == 0)
     {
       /* Last block of the file is a hole */
-      if (sys_truncate (file->fd))
+      if (file->seekable && sys_truncate (file->fd))
 	truncate_warn (file->stat_info->orig_file_name);
     }
   else while (write_size > 0)
@@ -330,6 +371,7 @@
       count = full_write (file->fd, blk->buffer, wrbytes);
       write_size -= count;
       file->dumped_size += count;
+      file->offset += count;
       if (count != wrbytes)
 	{
 	  write_error_details (file->stat_info->orig_file_name,
@@ -351,7 +393,9 @@
 
   file.stat_info = st;
   file.fd = fd;
-
+  file.seekable = true; /* File *must* be seekable for dump to work */
+  file.offset = 0;
+  
   if (!sparse_select_optab (&file)
       || !tar_sparse_init (&file))
     return dump_status_not_implemented;
@@ -414,7 +458,9 @@
 
   file.stat_info = st;
   file.fd = fd;
-
+  file.seekable = lseek (fd, 0, SEEK_SET) == 0;
+  file.offset = 0;
+  
   if (!sparse_select_optab (&file)
       || !tar_sparse_init (&file))
     return dump_status_not_implemented;
@@ -450,7 +496,7 @@
 static bool
 check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end)
 {
-  if (!lseek_or_error (file, beg, SEEK_SET))
+  if (!lseek_or_error (file, beg))
     return false;
 
   while (beg < end)
@@ -486,8 +532,7 @@
 {
   size_t size_left;
 
-  if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset,
-		       SEEK_SET))
+  if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset))
     return false;
   size_left = file->stat_info->sparse_map[i].numbytes;
   while (size_left > 0)

tar-1.14-skipSparseFile.patch:
 list.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)

--- NEW FILE tar-1.14-skipSparseFile.patch ---
--- tar-1.14/src/list.c.skipSparseFile	2005-07-27 14:33:31.000000000 +0200
+++ tar-1.14/src/list.c	2005-07-27 14:34:57.000000000 +0200
@@ -118,6 +118,7 @@
 			   quotearg_colon (current_stat_info.file_name)));
 		  /* Fall through.  */
 		default:
+		  decode_header (current_header, &current_stat_info, &current_format, 0);
 		  skip_member ();
 		  continue;
 		}
@@ -1258,7 +1259,8 @@
     }
 }
 
-/* Skip the current member in the archive.  */
+/* Skip the current member in the archive.  
+   NOTE: Current header must be decoded before calling this function. */
 void
 skip_member (void)
 {

tar-1.14-spMapSizeInit.patch:
 sparse.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

--- NEW FILE tar-1.14-spMapSizeInit.patch ---
--- tar-1.14/src/sparse.c.spMapSizeInit	2005-04-15 11:02:37.904225580 +0200
+++ tar-1.14/src/sparse.c	2005-04-15 11:04:20.115447794 +0200
@@ -189,7 +189,7 @@
     return false;
   clear_block (buffer);
 
-  file->stat_info->sparse_map_size = 0;
+  file->stat_info->sparse_map_avail = 0;
   file->stat_info->archive_file_size = 0;
 
   if (!tar_sparse_scan (file, scan_begin, NULL))
@@ -626,7 +626,7 @@
   int ext_p;
   static enum oldgnu_add_status rc;
 
-  file->stat_info->sparse_map_size = 0;
+  file->stat_info->sparse_map_avail = 0;
   for (i = 0; i < SPARSES_IN_OLDGNU_HEADER; i++)
     {
       rc = oldgnu_add_sparse (file, &h->oldgnu_header.sp[i]);
@@ -752,7 +752,7 @@
   int ext_p;
   static enum oldgnu_add_status rc;
 
-  file->stat_info->sparse_map_size = 0;
+  file->stat_info->sparse_map_avail = 0;
 
   if (h->star_in_header.prefix[0] == '\0'
       && h->star_in_header.sp[0].offset[10] != '\0')

tar-1.14-sparseTotals.patch:
 create.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

--- NEW FILE tar-1.14-sparseTotals.patch ---
--- tar-1.14/src/create.c.sparseTotals	2005-07-25 10:11:29.000000000 +0200
+++ tar-1.14/src/create.c	2005-07-25 10:16:36.000000000 +0200
@@ -332,16 +332,20 @@
 }
 
 
-/* A file is not dumpable if
+/* A file is considered dumpable if it is sparse and both --sparse and --totals
+   are specified.
+   Otherwise, it is dumpable unless any of the following conditions occur:
+
    a) it is empty *and* world-readable, or
    b) current archive is /dev/null */
 
 bool
 file_dumpable_p (struct tar_stat_info *st)
 {
-  return !(dev_null_output
-	   || (st->archive_file_size == 0
-	       && (st->stat.st_mode & MODE_R) == MODE_R));
+  if (dev_null_output)
+    return totals_option && sparse_option && sparse_file_p (st);
+  return !(st->archive_file_size == 0
+          && (st->stat.st_mode & MODE_R) == MODE_R);
 }
 
 
@@ -1383,7 +1387,7 @@
 	  else
 	    fd = -1;
 
-	  if (sparse_option && sparse_file_p (st))
+	  if (fd != -1 && sparse_option && sparse_file_p (st))
 	    {
 	      status = sparse_dump_file (fd, st);
 	      if (status == dump_status_not_implemented)


Index: tar.spec
===================================================================
RCS file: /cvs/dist/rpms/tar/FC-3/tar.spec,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- tar.spec	11 Oct 2004 12:47:27 -0000	1.15
+++ tar.spec	27 Jul 2005 12:55:15 -0000	1.16
@@ -1,7 +1,7 @@
 Summary: A GNU file archiving program.
 Name: tar
 Version: 1.14
-Release: 4
+Release: 5.FC3
 License: GPL
 Group: Applications/Archiving
 URL: http://www.gnu.org/software/tar/
@@ -9,8 +9,12 @@
 Source1: ftp://ftp.gnu.org/pub/gnu/tar/tar-%{version}.tar.bz2.sig
 Patch0: tar-1.13.18-manpage.patch
 Patch6: tar-1.14-nolibrt.patch
-Patch7: tar-1.14-err.patch
+#Patch7: tar-1.14-err.patch
 Patch8: tar-1.14-loneZeroWarning.patch
+Patch9: tar-1.14-sparseTotals.patch
+Patch10: tar-1.14-lseek.patch
+Patch11: tar-1.14-spMapSizeInit.patch
+Patch12: tar-1.14-skipSparseFile.patch
 Prereq: info
 BuildRequires: autoconf automake gzip
 Buildroot: %{_tmppath}/%{name}-%{version}-root
@@ -31,8 +35,12 @@
 %setup -q
 %patch0 -p1 -b .manpage
 %patch6 -p1 -b .librt
-%patch7 -p1 -b .err
+#%patch7 -p1 -b .err
 %patch8 -p1 -b .loneZeroWarning
+%patch9 -p1 -b .sparseTotals
+%patch10 -p1 -b .lseek
+%patch11 -p1 -b  .spMapSizeInit
+%patch12 -p1 -b .skipSparseFile
 
 %build
 
@@ -101,6 +109,15 @@
 %{_infodir}/tar.info*
 
 %changelog
+* Wed Jul 27 2005 Peter Vrabec <pvrabec redhat com> 1.14-5.FC3
+- A file is dumpable if it is sparse and both --sparse
+  and --totals are specified (#154882)
+- exclude err.patch, it causes SEGV (#158743)
+- Extract sparse files even if the output fd is not seekable. (#146225)
+- (sparse_scan_file): Bugfix. offset had incorrect type
+- (sparse_add_map): Fixed improper initializations of sparse_map_size
+- fix skipping sparse members in archive(#143969)
+
 * Mon Oct 11 2004 Peter Vrabec <pvrabec redhat com>
 - patch to stop issuing lone zero block warnings
 - rebuilt


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