[it seems this message was lost, sending again...]
-------------------------------------------------------

On Tue 11. of December 2007 13:55:53 you wrote:
> Radek Brich <[EMAIL PROTECTED]> ha escrit:
> > Although it'd need some cleaning, I'd like to hear what
> > you think about the idea?
>
> Generally speaking, looks nice, except that fstat may fail (e.g. if
> stdout is closed) in which case st_stdout would contain garbage.
>
> Regards,
> Sergey

Yes, I said it's not final.
This one should be better.

-- 
           Radek Brich
   /__\    Base OS/core services
 ~~~~~~~~  Red Hat, Brno, Czech Rep.
diff -up tar-1.17/src/buffer.c.stdoutlist tar-1.17/src/buffer.c
--- tar-1.17/src/buffer.c.stdoutlist	2007-06-01 12:17:10.000000000 +0200
+++ tar-1.17/src/buffer.c	2007-12-11 14:23:30.000000000 +0100
@@ -465,6 +465,13 @@ _open_archive (enum access_mode wanted_a
 
   records_read = 0;
 
+  struct stat st_buf;
+  ino_t stdout_ino = fstat(STDOUT_FILENO, &st_buf) == -1 ?
+                     0 : st_buf.st_ino;
+  ino_t archive_ino = stat(archive_name_array[0], &st_buf) == -1 ?
+                     0 : st_buf.st_ino;
+  bool archive_is_stdout = (archive_ino != 0 && archive_ino == stdout_ino);
+
   if (use_compress_program_option)
     {
       switch (wanted_access)
@@ -486,10 +493,10 @@ _open_archive (enum access_mode wanted_a
 
       if (!index_file_name
 	  && wanted_access == ACCESS_WRITE
-	  && strcmp (archive_name_array[0], "-") == 0)
+	  && (strcmp (archive_name_array[0], "-") == 0 || archive_is_stdout))
 	stdlis = stderr;
     }
-  else if (strcmp (archive_name_array[0], "-") == 0)
+  else if (strcmp (archive_name_array[0], "-") == 0 || archive_is_stdout)
     {
       read_full_records = true; /* could be a pipe, be safe */
       if (verify_option)

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to