bug-tar
[Top][All Lists]
Advanced

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

Re: [Bug-tar] tar --delete -f [file] [deadfile] truncates [file] if [dea


From: Sergey Poznyakoff
Subject: Re: [Bug-tar] tar --delete -f [file] [deadfile] truncates [file] if [deadfile] is not in the tarball.
Date: Fri, 17 Dec 2004 17:40:56 +0200

References: <address@hidden>
X-Mailer: MH-E 7.4.2+cvs; GNU Mailutils 0.5; GNU Emacs 21.3.1

Chad Page <address@hidden> wrote:

> 
>       We just migrated from 1.13 to 1.14 to fix a buffering problem, and
> we quickly found that a sideeffect of the upgrade was that --delete on a
> file no longer works correctly.  It removes the last 1-3 files when run in
> this fashion.

Thanks for reporting. It seems that the bug was present
in version 1.13.25 as well.

> I was able to workaround it by running a test delete using
> pipes, but this is suboptimal.  Is there an option I'm not seeing that
> will allow the rewriting to continue or a fix for this in 1.14.xx? Thanks,

Try attached patch.

Regards,
Sergey

Index: src/delete.c
===================================================================
RCS file: /cvsroot/tar/tar/src/delete.c,v
retrieving revision 1.20
diff -p -u -r1.20 delete.c
--- src/delete.c        6 Sep 2004 14:28:56 -0000       1.20
+++ src/delete.c        17 Dec 2004 14:49:18 -0000
@@ -359,33 +359,32 @@ delete_archive_members (void)
                write_record (1);
            }
        }
-    }
 
-  if (logical_status == HEADER_END_OF_FILE)
-    {
-      /* Write the end of tape.  FIXME: we can't use write_eot here,
-        as it gets confused when the input is at end of file.  */
+      if (logical_status == HEADER_END_OF_FILE)
+       {
+         /* Write the end of tape.  FIXME: we can't use write_eot here,
+            as it gets confused when the input is at end of file.  */
+
+         int total_zero_blocks = 0;
 
-      int total_zero_blocks = 0;
+         do
+           {
+             int zero_blocks = blocking_factor - new_blocks;
+             memset (new_record + new_blocks, 0, BLOCKSIZE * zero_blocks);
+             total_zero_blocks += zero_blocks;
+             write_record (total_zero_blocks < 2);
+           }
+         while (total_zero_blocks < 2);
+       }
 
-      do
+      if (! acting_as_filter && ! _isrmt (archive))
        {
-         int zero_blocks = blocking_factor - new_blocks;
-         memset (new_record + new_blocks, 0, BLOCKSIZE * zero_blocks);
-         total_zero_blocks += zero_blocks;
-         write_record (total_zero_blocks < 2);
+         if (sys_truncate (archive))
+           truncate_warn (archive_name_array[0]);
        }
-      while (total_zero_blocks < 2);
     }
-
   free (new_record);
 
-  if (! acting_as_filter && ! _isrmt (archive))
-    {
-      if (sys_truncate (archive))
-       truncate_warn (archive_name_array[0]);
-    }
-
   close_archive ();
   names_notfound ();
 }

reply via email to

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