lose the generated ps files
[debian/dds2tar] / tar-1.13.patch
1 diff -ru tar-1.13/src/buffer.c tar-1.13.1/src/buffer.c
2 --- tar-1.13/src/buffer.c       Mon Jul  5 08:47:59 1999
3 +++ tar-1.13.1/src/buffer.c     Sun Aug  6 23:37:01 2000
4 @@ -68,6 +68,7 @@
5  /* Where we write list messages (not errors, not interactions) to.  Stdout
6     unless we're writing a pipe, in which case stderr.  */
7  FILE *stdlis;
8 +FILE *stdrec;
9  
10  static void backspace_output PARAMS ((void));
11  static int new_volume PARAMS ((enum access_mode));
12 @@ -83,6 +84,9 @@
13  /* PID of child program, if compress_option or remote archive access.  */
14  static pid_t child_pid;
15  
16 +/* Record number of the start of this block of records  */
17 +long baserec = 0 ;
18 +
19  /* Error recovery stuff  */
20  static int read_error_count;
21  
22 @@ -144,9 +148,11 @@
23  
24  #endif /* DEBUG FORK */
25  
26 +time_t start_time ;
27  void
28  init_total_written (void)
29  {
30 +  start_time = time(0);
31    clear_tarlong (total_written);
32    clear_tarlong (bytes_written);
33  }
34 @@ -154,8 +160,12 @@
35  void
36  print_total_written (void)
37  {
38 +  time_t end_time = time(0);
39    fprintf (stderr, _("Total bytes written: "));
40    print_tarlong (total_written, stderr);
41 +  fprintf (stderr, _(" ("));
42 +  print_tarlong ((total_written/(end_time-start_time))>>10, stderr);
43 +  fprintf (stderr,"KB per second)");
44    fprintf (stderr, "\n");
45  }
46  
47 @@ -680,8 +690,48 @@
48  open_archive (enum access_mode access)
49  {
50    int backed_up_flag = 0;
51 +  time_t start_time = time(0) ;
52  
53 -  stdlis = to_stdout_option ? stderr : stdout;
54 +  stdrec = stdlis = to_stdout_option ? stderr : stdout;
55 +
56 +  if ( record_file_name != NULL )
57 +    {
58 +#define INSERT_TIMESTAMP
59 +#ifdef INSERT_TIMESTAMP
60 +      /*
61 +       * A record-file name with '%T' will be expanded with a decimal
62 +       * value for the timestamp of the archive. This is the time value
63 +       * stored in the label record.
64 +       * If you are using only one computer, this should be a unique number.
65 +       * You are able to create different rec-files for all your archives,
66 +       * as well as finding the index of your archive in a reliable way.
67 +       *
68 +       * Another way would be to let us set the timestamp by another option.
69 +       * tar --timestamp <ts-number> ...
70 +       */
71 +      char rfn[256];
72 +      if ( access == ACCESS_READ ) {
73 +        char*p= record_file_name ;
74 +        int i = 0 ;
75 +        int n;
76 +        while ( p[0] != '\0' ) {
77 +          if ( p[0] == '%' && p[1] == 'T' ) {
78 +            /* i += */ sprintf(rfn+i,"%d",start_time);
79 +            i = strlen(rfn) ;
80 +            p += 2 ;
81 +          } else { rfn[i++] = *p++ ; }
82 +        }
83 +        rfn[i] = '\0' ;
84 +      } else strcpy(rfn,record_file_name);
85 +#else
86 +      char*rfn=record_file_name;
87 +#endif
88 +      if ( ( stdrec = fopen(rfn,"w")) == NULL )
89 +        {
90 +          fprintf(stdlis,"Cannot open %s.\n",record_file_name);
91 +          exit(1);
92 +        }
93 +    }
94  
95    if (record_size == 0)
96      FATAL_ERROR ((0, 0, _("Invalid value for record_size")));
97 @@ -841,6 +891,46 @@
98    setmode (archive, O_BINARY);
99  #endif
100  
101 +#if defined(MTIOCGET)
102 +  /* Prints the file number of the archive */
103 +  if ( block_number_option )
104 +    {
105 +      struct mtget get ;
106 +      int i ;
107 +      i = ioctl(archive,MTIOCGET,&get);
108 +      if (( i == 0 ) && ( get.mt_fileno >= 0 ))
109 +        {
110 +          fprintf(stdrec,
111 +            "loc             number of the file is %d \n",
112 +            get.mt_fileno );
113 +        }
114 +    }
115 +#endif
116 +
117 +#if defined(MTIOCPOS)
118 +  /* Prints the tape block number on every Linux SCSI-device */
119 +  if ( block_number_option )
120 +    {
121 +      struct mtpos pos ;
122 +      int i ;
123 +      i = ioctl(archive,MTIOCPOS,&pos);
124 +      if ( i == 0 )
125 +        {
126 +          fprintf(stdrec,
127 +            "loc             number of the first block is %d\n",
128 +            pos.mt_blkno );
129 +        }
130 +    }
131 +#endif
132 +
133 +  /* Prints the size of the blocks */
134 +  if ( block_number_option && blocking_factor != 20 )
135 +    {
136 +      fprintf(stdrec,
137 +        "loc             block length is %d bytes = %d * 512 bytes\n",
138 +       blocking_factor*512,blocking_factor);
139 +    }
140 +
141    switch (access)
142      {
143      case ACCESS_READ:
144 @@ -874,7 +964,7 @@
145           assign_string (&current_file_name, record_start->header.name);
146  
147           record_start->header.typeflag = GNUTYPE_VOLHDR;
148 -         TIME_TO_OCT (time (0), record_start->header.mtime);
149 +         TIME_TO_OCT (start_time, record_start->header.mtime);
150           finish_header (record_start);
151  #if 0
152           current_block++;
153 diff -ru tar-1.13/src/common.h tar-1.13.1/src/common.h
154 --- tar-1.13/src/common.h       Wed Jul  7 08:07:30 1999
155 +++ tar-1.13.1/src/common.h     Mon Feb 21 23:30:56 2000
156 @@ -311,6 +311,12 @@
157  
158  /* Initial size of the sparsearray.  */
159  GLOBAL int sp_array_size;
160 +
161 +/* Time of writing.  */
162 +GLOBAL time_t start_time;
163 +
164 +/* File to write record information to. */
165 +GLOBAL char *record_file_name;
166  \f
167  /* Declarations for each module.  */
168  
169 @@ -327,7 +333,9 @@
170  
171  /* Module buffer.c.  */
172  
173 +extern long baserec;
174  extern FILE *stdlis;
175 +extern FILE *stdrec;
176  extern char *save_name;
177  extern off_t save_sizeleft;
178  extern off_t save_totsize;
179 diff -ru tar-1.13/src/create.c tar-1.13.1/src/create.c
180 --- tar-1.13/src/create.c       Wed Jul  7 07:27:04 1999
181 +++ tar-1.13.1/src/create.c     Sun Aug  6 22:29:50 2000
182 @@ -435,11 +435,9 @@
183  
184    uintmax_to_oct ((uintmax_t) sum, header->header.chksum, 7);
185  
186 -  set_next_block_after (header);
187 -
188 -  if (verbose_option
189 -      && header->header.typeflag != GNUTYPE_LONGLINK
190 -      && header->header.typeflag != GNUTYPE_LONGNAME)
191 +  if (verbose_option)
192 +      /* && header->header.typeflag != GNUTYPE_LONGLINK */
193 +      /* && header->header.typeflag != GNUTYPE_LONGNAME */
194      {
195        /* These globals are parameters to print_header, sigh.  */
196  
197 @@ -448,6 +446,9 @@
198        current_format = archive_format;
199        print_header ();
200      }
201 +
202 +  set_next_block_after (header);
203 +
204  }
205  \f
206  /* Sparse file processing.  */
207 diff -ru tar-1.13/src/extract.c tar-1.13.1/src/extract.c
208 --- tar-1.13/src/extract.c      Fri Jul  2 23:24:36 1999
209 +++ tar-1.13.1/src/extract.c    Mon Feb 21 21:32:07 2000
210 @@ -962,6 +962,7 @@
211      case GNUTYPE_LONGNAME:
212      case GNUTYPE_LONGLINK:
213        ERROR ((0, 0, _("Visible long name error")));
214 +      print_header();
215        skip_file (current_stat.st_size);
216        if (backup_option)
217         undo_last_backup ();
218 diff -ru tar-1.13/src/list.c tar-1.13.1/src/list.c
219 --- tar-1.13/src/list.c Wed Jul  7 07:46:52 1999
220 +++ tar-1.13.1/src/list.c       Sun Aug  6 22:25:28 2000
221 @@ -124,7 +124,7 @@
222           if (block_number_option)
223             {
224               char buf[UINTMAX_STRSIZE_BOUND];
225 -             fprintf (stdlis, _("block %s: ** Block of NULs **\n"),
226 +             fprintf (stdrec, _("block %s: ** Block of NULs **\n"),
227                        STRINGIFY_BIGINT (current_block_ordinal (), buf));
228             }
229  
230 @@ -138,7 +138,7 @@
231           if (block_number_option)
232             {
233               char buf[UINTMAX_STRSIZE_BOUND];
234 -             fprintf (stdlis, _("block %s: ** End of File **\n"),
235 +             fprintf (stdrec, _("block %s: ** End of File **\n"),
236                        STRINGIFY_BIGINT (current_block_ordinal (), buf));
237             }
238           break;
239 @@ -217,7 +217,7 @@
240           if (written > size)
241             written = size;
242           errno = 0;            /* FIXME: errno should be read-only */
243 -         check = fwrite (data_block->buffer, sizeof (char), written, stdlis);
244 +         check = fwrite (data_block->buffer, sizeof (char), written, stdrec);
245           set_next_block_after ((union block *)
246                                 (data_block->buffer + written - 1));
247           if (check != written)
248 @@ -231,8 +231,8 @@
249         }
250        if (multi_volume_option)
251         assign_string (&save_name, NULL);
252 -      fputc ('\n', stdlis);
253 -      fflush (stdlis);
254 +      fputc ('\n', stdrec);
255 +      fflush (stdrec);
256        return;
257  
258      }
259 @@ -381,6 +381,8 @@
260           longp = ((header->header.typeflag == GNUTYPE_LONGNAME)
261                    ? &next_long_name
262                    : &next_long_link);
263 +          assign_string (&current_file_name, header->header.name);
264 +            print_header();
265  
266           set_next_block_after (header);
267           if (*longp)
268 @@ -763,10 +765,18 @@
269    int pad;
270    char *name;
271  
272 +  extern union block *record_start;
273 +  extern union block *current_block;
274 +  if (block_number_option)
275 +    fprintf (stdrec, _("rec %10ld: "), baserec + (current_block - record_start));
276 +#if 0
277 +  annofile (stdrec, (char *) NULL);
278 +#endif
279 +
280    if (block_number_option)
281      {
282        char buf[UINTMAX_STRSIZE_BOUND];
283 -      fprintf (stdlis, _("block %s: "),
284 +      fprintf (stdrec, _("block %s: "),
285                STRINGIFY_BIGINT (current_block_ordinal (), buf));
286      }
287  
288 @@ -778,11 +788,11 @@
289  
290        if (quoted_name)
291         {
292 -         fprintf (stdlis, "%s\n", quoted_name);
293 +         fprintf (stdrec, "%s\n", quoted_name);
294           free (quoted_name);
295         }
296        else
297 -       fprintf (stdlis, "%s\n", current_file_name);
298 +       fprintf (stdrec, "%s\n", current_file_name);
299      }
300    else
301      {
302 @@ -792,6 +802,11 @@
303        switch (current_header->header.typeflag)
304         {
305         case GNUTYPE_VOLHDR:
306 +          /* dirty bug fix to display the header processing
307 +           * tar cvvf /dev/null --label 'hello world' blah...
308 +           * J"org Weule weule@cs.uni-duesseldorf.de
309 +           */
310 +          current_stat.st_mtime = time_from_oct(current_block->header.mtime,1+12);
311           modes[0] = 'V';
312           break;
313  
314 @@ -804,8 +819,12 @@
315           break;
316  
317         case GNUTYPE_LONGNAME:
318 +          modes[0] = 'L';
319 +          break;
320 +
321         case GNUTYPE_LONGLINK:
322 -         ERROR ((0, 0, _("Visible longname error")));
323 +         /* ERROR ((0, 0, _("Visible longname error"))); */
324 +          modes[0] = 'K' ;
325           break;
326  
327         case GNUTYPE_SPARSE:
328 @@ -898,22 +917,22 @@
329         ugswidth = pad;
330  
331  #if USE_OLD_CTIME
332 -      fprintf (stdlis, "%s %s/%s %*s%s %s %s",
333 +      fprintf (stdrec, "%s %s/%s %*s%s %s %s",
334                modes, user, group, ugswidth - pad, "",
335                size, timestamp + 4, timestamp + 20);
336  #else
337 -      fprintf (stdlis, "%s %s/%s %*s%s %s",
338 +      fprintf (stdrec, "%s %s/%s %*s%s %s",
339                modes, user, group, ugswidth - pad, "", size, timestamp);
340  #endif
341  
342        name = quote_copy_string (current_file_name);
343        if (name)
344         {
345 -         fprintf (stdlis, " %s", name);
346 +         fprintf (stdrec, " %s", name);
347           free (name);
348         }
349        else
350 -       fprintf (stdlis, " %s", current_file_name);
351 +       fprintf (stdrec, " %s", current_file_name);
352  
353        switch (current_header->header.typeflag)
354         {
355 @@ -921,26 +940,26 @@
356           name = quote_copy_string (current_link_name);
357           if (name)
358             {
359 -             fprintf (stdlis, " -> %s\n", name);
360 +             fprintf (stdrec, " -> %s\n", name);
361               free (name);
362             }
363           else
364 -           fprintf (stdlis, " -> %s\n", current_link_name);
365 +           fprintf (stdrec, " -> %s\n", current_link_name);
366           break;
367  
368         case LNKTYPE:
369           name = quote_copy_string (current_link_name);
370           if (name)
371             {
372 -             fprintf (stdlis, _(" link to %s\n"), name);
373 +             fprintf (stdrec, _(" link to %s\n"), name);
374               free (name);
375             }
376           else
377 -           fprintf (stdlis, _(" link to %s\n"), current_link_name);
378 +           fprintf (stdrec, _(" link to %s\n"), current_link_name);
379           break;
380  
381         default:
382 -         fprintf (stdlis, _(" unknown file type `%c'\n"),
383 +         fprintf (stdrec, _(" unknown file type `%c'\n"),
384                    current_header->header.typeflag);
385           break;
386  
387 @@ -953,11 +972,11 @@
388         case FIFOTYPE:
389         case CONTTYPE:
390         case GNUTYPE_DUMPDIR:
391 -         putc ('\n', stdlis);
392 +         putc ('\n', stdrec);
393           break;
394  
395         case GNUTYPE_VOLHDR:
396 -         fprintf (stdlis, _("--Volume Header--\n"));
397 +         fprintf (stdrec, _("--Volume Header--\n"));
398           break;
399  
400         case GNUTYPE_MULTIVOL:
401 @@ -965,15 +984,15 @@
402                   STRINGIFY_BIGINT
403                   (UINTMAX_FROM_OCT (current_header->oldgnu_header.offset),
404                    uintbuf));
405 -         fprintf (stdlis, _("--Continued at byte %s--\n"), size);
406 +         fprintf (stdrec, _("--Continued at byte %s--\n"), size);
407           break;
408  
409         case GNUTYPE_NAMES:
410 -         fprintf (stdlis, _("--Mangled file names--\n"));
411 +         fprintf (stdrec, _("--Mangled file names--\n"));
412           break;
413         }
414      }
415 -  fflush (stdlis);
416 +  fflush (stdrec);
417  }
418  
419  /*--------------------------------------------------------------.
420 @@ -996,7 +1015,7 @@
421        if (block_number_option)
422         {
423           char buf[UINTMAX_STRSIZE_BOUND];
424 -         fprintf (stdlis, _("block %s: "),
425 +         fprintf (stdrec, _("block %s: "),
426                    STRINGIFY_BIGINT (current_block_ordinal (), buf));
427         }
428        name = quote_copy_string (pathname);
429 diff -ru tar-1.13/src/names.c tar-1.13.1/src/names.c
430 --- tar-1.13/src/names.c        Wed Jul  7 07:46:51 1999
431 +++ tar-1.13.1/src/names.c      Sun Aug  6 22:20:43 2000
432 @@ -375,6 +375,14 @@
433             FATAL_ERROR ((0, errno, _("Cannot change to directory %s"),
434                           name_buffer));
435           chdir_flag = 0;
436 +          if ( record_file_name )
437 +            {
438 +              char *d = malloc(PATH_MAX);
439 +              if( d && getcwd(d,PATH_MAX) )
440 +                fprintf(stdrec,
441 +                        "loc             current directory is %s\n",
442 +                        d);
443 +            }
444         }
445        else if (change_dirs && strcmp (name_buffer, "-C") == 0)
446         chdir_flag = 1;
447 diff -ru tar-1.13/src/tar.c tar-1.13.1/src/tar.c
448 --- tar-1.13/src/tar.c  Wed Jul  7 07:49:50 1999
449 +++ tar-1.13.1/src/tar.c        Tue Feb 22 00:27:07 2000
450 @@ -132,6 +132,7 @@
451    SUFFIX_OPTION,
452    USE_COMPRESS_PROGRAM_OPTION,
453    VOLNO_FILE_OPTION,
454 +  RECORD_FILE_OPTION,
455  
456    /* Some cleanup is being made in GNU tar long options.  Using old names is
457       allowed for a while, but will also send a warning to stderr.  Take old
458 @@ -220,6 +221,7 @@
459    /* FIXME: --partial-blocks might be a synonym for --read-full-records?  */
460    {"record-number", no_argument, NULL, OBSOLETE_BLOCK_NUMBER},
461    {"record-size", required_argument, NULL, RECORD_SIZE_OPTION},
462 +  {"record-file", required_argument, NULL, RECORD_FILE_OPTION},
463    {"remove-files", no_argument, &remove_files_option, 1},
464    {"rsh-command", required_argument, NULL, RSH_COMMAND_OPTION},
465    {"same-order", no_argument, NULL, 's'},
466 @@ -378,6 +380,7 @@
467        --checkpoint      print directory names while reading the archive\n\
468        --totals          print total bytes written while creating archive\n\
469    -R, --block-number    show block number within archive with each message\n\
470 +      --record-file     print the record information to file, enable -R\n\
471    -w, --interactive     ask for confirmation for every action\n\
472        --confirmation    same as -w\n"),
473              stdout);
474 @@ -904,6 +907,11 @@
475         volno_file_option = optarg;
476         break;
477  
478 +      case RECORD_FILE_OPTION:
479 +        record_file_name = optarg ;
480 +        block_number_option++;         /* Print block #s for debug */
481 +        break;
482 +
483        case USE_COMPRESS_PROGRAM_OPTION:
484         set_use_compress_program_option (optarg);
485         break;
486 @@ -1155,14 +1163,52 @@
487        break;
488  
489      case CREATE_SUBCOMMAND:
490 +
491 +/*
492 + * Comment the next line out if you have problems. Joerg Weule
493 + */
494 +#define PRINT_TROUPUT
495 +#ifdef PRINT_TROUPUT
496 +      start_time = time(0);
497        if (totals_option)
498 -       init_total_written ();
499 +        init_total_written ();
500 +      create_archive ();
501 +      if (totals_option) {
502 +        time_t end_time = time(0);
503 +        double sec = end_time - start_time ;
504 +        /* double t = ((double)total_written) * BLOCKSIZE ; */
505 +       print_total_written ();
506 +        /*
507 +        fprintf (stderr, _("Total bytes written: %.0f"),t);
508 +        if ( t >= 1e9 ) fprintf(stderr, _(" (%3.1f Gb)"),t/1e9 ); else
509 +        if ( t >= 1e6 ) fprintf(stderr, _(" (%3.1f Mb)"),t/1e6 ); else
510 +        if ( t >= 1024 ) fprintf(stderr, _(" (%3.1f Kb)"),t/1024 );
511 +        fprintf(stderr,"\n");
512 +        if ( sec > 0.1 ){
513 +          long s, m, h = sec ;
514 +              m = h ;
515 +          h /= 3600 ;
516 +          m -= h * 3600 ;
517 +          s = m ;
518 +          m /= 60 ;
519 +          s -= m / 60 ;
520 +          fprintf (stderr, _("Elapsed time: %02d:%02d:%02d, %g sec\n"), h,m,s,sec);
521 +          if ( !flag_multivol)
522 +            fprintf (stderr, _("Throughput per second: %.0fKb/sec\n"),
523 +              t/sec/1024);
524 +        }
525 +        */
526 +      }
527 +#else
528 +      if (totals_option)
529 +        init_total_written ();
530  
531        create_archive ();
532        name_close ();
533  
534        if (totals_option)
535 -       print_total_written ();
536 +        print_total_written ();
537 +#endif
538        break;
539  
540      case EXTRACT_SUBCOMMAND: