]> Dogcows Code - chaz/tar/blobdiff - src/buffer.c
Report record size only if the archive refers to a device.
[chaz/tar] / src / buffer.c
index 02a3e4c620aeffc0ef6714fc951c05bd59f2fb43..a01af374c3b4a00d77992d057e739f4274757c75 100644 (file)
@@ -1,7 +1,7 @@
 /* Buffer management for tar.
 
    Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001,
-   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    Written by John Gilmore, on 1985-08-25.
 
@@ -204,7 +204,8 @@ enum compress_type {
   ct_gzip,
   ct_bzip2,
   ct_lzma,
-  ct_lzop
+  ct_lzop,
+  ct_xz
 };
 
 struct zip_magic
@@ -222,8 +223,9 @@ static struct zip_magic const magic[] = {
   { ct_compress, 2, "\037\235", "compress", "-Z" },
   { ct_gzip,     2, "\037\213", "gzip", "-z"  },
   { ct_bzip2,    3, "BZh",      "bzip2", "-j" },
-  { ct_lzma,     6, "\xFFLZMA", "lzma", "-J" }, /* FIXME: ???? */
+  { ct_lzma,     6, "\xFFLZMA", "lzma", "--lzma" }, /* FIXME: ???? */
   { ct_lzop,     4, "\211LZO",  "lzop", "--lzop" },
+  { ct_xz,       6, "\0xFD7zXZ", "-J" },
 };
 
 #define NMAGIC (sizeof(magic)/sizeof(magic[0]))
@@ -677,6 +679,19 @@ archive_read_error (void)
   return;
 }
 
+static bool
+archive_is_dev ()
+{
+  struct stat st;
+
+  if (fstat (archive, &st))
+    {
+      stat_diag (*archive_name_cursor);
+      return false;
+    }
+  return S_ISBLK (st.st_mode) || S_ISCHR (st.st_mode);
+}
+
 static void
 short_read (size_t status)
 {
@@ -688,7 +703,8 @@ short_read (size_t status)
 
   if (left && left % BLOCKSIZE == 0
       && verbose_option
-      && record_start_block == 0 && status != 0)
+      && record_start_block == 0 && status != 0
+      && archive_is_dev ())
     {
       unsigned long rsize = status / BLOCKSIZE;
       WARN ((0, 0,
@@ -848,8 +864,6 @@ close_archive (void)
         flush_archive ();
     }
 
-  sys_drain_input_pipe ();
-
   compute_duration ();
   if (verify_option)
     verify_volume ();
@@ -857,7 +871,7 @@ close_archive (void)
   if (rmtclose (archive) != 0)
     close_error (*archive_name_cursor);
 
-  sys_wait_for_child (child_pid);
+  sys_wait_for_child (child_pid, hit_eof);
 
   tar_stat_destroy (&current_stat_info);
   if (save_name)
This page took 0.026954 seconds and 4 git commands to generate.