lose the generated ps files
[debian/dds2tar] / tar-1.11.8.patch
1 diff -ru tar-1.11.8/lib/rx.h tar-1.11.8.1/lib/rx.h
2 --- tar-1.11.8/lib/rx.h Fri May  5 14:17:10 1995
3 +++ tar-1.11.8.1/lib/rx.h       Fri May  5 14:17:10 1995
4 @@ -1382,7 +1382,7 @@
5  
6  /* If this bit is set, then `{...}' defines an interval, and \{ and \}
7       are literals.
8 -  If not smt, then `\{...\}' defines an interval.  */
9 +  If not set, then `\{...\}' defines an interval.  */
10  #define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
11  
12  /* If this bit is set, (...) defines a group, and \( and \) are literals.
13 diff -ru tar-1.11.8/src/buffer.c tar-1.11.8.1/src/buffer.c
14 --- tar-1.11.8/src/buffer.c     Mon May 29 02:26:27 1995
15 +++ tar-1.11.8.1/src/buffer.c   Mon Feb  5 20:20:19 1996
16 @@ -46,6 +46,7 @@
17  /* Where we write messages (standard messages, not errors) to.  Stdout
18     unless we're writing a pipe, in which case stderr.  */
19  FILE *stdlis;
20 +FILE *stdrec;
21  
22  #define        STDIN   0               /* standard input  file descriptor */
23  #define        STDOUT  1               /* standard output file descriptor */
24 @@ -77,7 +78,7 @@
25  static int childpid = 0;
26  
27  /* Record number of the start of this block of records  */
28 -long baserec;
29 +long baserec = 0 ;
30  
31  /* Error recovery stuff  */
32  static int r_error_count;
33 @@ -520,11 +521,64 @@
34  void
35  open_archive (int reading)
36  {
37 -  stdlis = flag_exstdout ? stderr : stdout;
38 +  time_t start_time = time(0) ;
39 +  stdrec = stdlis = flag_exstdout ? stderr : stdout;
40 +  if ( record_file_name != NULL )
41 +    {
42 +#define INSERT_TIMESTAMP
43 +#ifdef INSERT_TIMESTAMP
44 +      /*
45 +       * A record-file name with '%T' will be expanded with a decimal
46 +       * value for the timestamp of the archive. This is the time value
47 +       * stored in the label record.
48 +       * If you are using only one computer, this should be a unique number.
49 +       * You are able to create different rec-files for all your archives,
50 +       * as well as finding the index of your archive in a reliable way.
51 +       *
52 +       * Another way would be to let us set the timestamp by another option.
53 +       * tar --timestamp <ts-number> ...
54 +       */
55 +      char rfn[256];
56 +      if ( reading == 0 ) {
57 +        char*p= record_file_name ;
58 +        int i = 0 ;
59 +        int n;
60 +        while ( p[0] != '\0' ) {
61 +          if ( p[0] == '%' && p[1] == 'T' ) {
62 +            /* i += */ sprintf(rfn+i,"%d",start_time);
63 +            i = strlen(rfn) ;
64 +            p += 2 ;
65 +          } else { rfn[i++] = *p++ ; }
66 +        }
67 +        rfn[i] = '\0' ;
68 +      } else strcpy(rfn,record_file_name);
69 +#else
70 +      char*rfn=record_file_name;
71 +#endif
72 +      if ( ( stdrec = fopen(rfn,"w")) == NULL )
73 +        {
74 +          fprintf(stdlis,"Cannot open %s.\n",record_file_name);
75 +          exit(1);
76 +        }
77 +    }
78 +
79  
80    if (blocksize == 0)
81      ERROR ((TAREXIT_FAILURE, 0, _("Invalid value for blocksize")));
82  
83 +  if ( ( flag_sayblock ) && ( flag_volhdr ) )
84 +    {
85 +      fprintf(stdrec,
86 +        "loc             timestamp is %d \n",
87 +        start_time);
88 +    }
89 +  if ( flag_sayblock && (blocksize != 10240) )
90 +    {
91 +      fprintf(stdrec,
92 +        "loc             block length is %d bytes = %d * 512 bytes \n",
93 +        blocksize,blocksize>>9);
94 +    }
95 +
96    if (archive_names == 0)
97      ERROR ((TAREXIT_FAILURE, 0,
98             _("No archive name given, what should I do?")));
99 @@ -618,6 +672,38 @@
100    setmode (archive, O_BINARY);
101  #endif
102  
103 +#if defined(MTIOCGET)
104 +  /* Prints the file number of the archive */
105 +  if ( flag_sayblock )
106 +    {
107 +      struct mtget get ;
108 +      int i ;
109 +      i = ioctl(archive,MTIOCGET,&get);
110 +      if (( i == 0 ) && ( get.mt_fileno >= 0 ))
111 +        {
112 +          fprintf(stdrec,
113 +            "loc             number of the file is %d \n",
114 +            get.mt_fileno );
115 +        }
116 +    }
117 +#endif
118 +
119 +#if defined(MTIOCPOS)
120 +  /* Prints the tape block number on every Linux SCSI-device */
121 +  if ( flag_sayblock )
122 +    {
123 +      struct mtpos pos ;
124 +      int i ;
125 +      i = ioctl(archive,MTIOCPOS,&pos);
126 +      if ( i == 0 )
127 +        {
128 +          fprintf(stdrec,
129 +            "loc             number of the first block is %d\n",
130 +            pos.mt_blkno );
131 +        }
132 +    }
133 +#endif
134 +
135    if (reading)
136      {
137        ar_last = ar_block;      /* set up for 1st block = # 0 */
138 @@ -666,7 +752,7 @@
139        assign_string (&current_file_name, ar_block->header.arch_name);
140  
141        ar_block->header.linkflag = LF_VOLHDR;
142 -      to_oct (time (0), 1 + 12, ar_block->header.mtime);
143 +      to_oct (start_time , 1 + 12, ar_block->header.mtime);
144        finish_header (ar_block);
145  #if 0
146        ar_record++;
147 @@ -727,7 +813,7 @@
148    if (err != blocksize && !flag_multivol)
149      writeerror (err);
150    else if (flag_totals)
151 -    tot_written += blocksize;
152 +    tot_written += blocking;
153  
154    if (err > 0)
155      bytes_written += err;
156 @@ -816,7 +902,7 @@
157    if (err != blocksize)
158      writeerror (err);
159    else if (flag_totals)
160 -    tot_written += blocksize;
161 +    tot_written += blocking;
162  
163  
164    bytes_written = blocksize;
165 diff -ru tar-1.11.8/src/create.c tar-1.11.8.1/src/create.c
166 --- tar-1.11.8/src/create.c     Sat Jun 17 23:08:13 1995
167 +++ tar-1.11.8.1/src/create.c   Sun Dec  1 01:55:08 1996
168 @@ -315,7 +315,10 @@
169    to_oct ((long) sum, 8, header->header.chksum);
170    header->header.chksum[6] = '\0';     /* zap the space */
171  
172 -  userec (header);
173 +  /* print header first to get the same output with 'tar -tvR'
174 +   * and 'tar -cvR'
175 +   */
176 +  /* userec (header); */
177  
178    if (flag_verbose)
179      {
180 @@ -327,6 +330,8 @@
181        head_standard = flag_standard;
182        print_header ();
183      }
184 +
185 +  userec (header) ;
186  
187    return;
188  }
189 diff -ru tar-1.11.8/src/extract.c tar-1.11.8.1/src/extract.c
190 --- tar-1.11.8/src/extract.c    Sun Jun 11 15:40:21 1995
191 +++ tar-1.11.8.1/src/extract.c  Sun Dec  1 01:55:28 1996
192 @@ -684,6 +684,7 @@
193      case LF_LONGNAME:
194      case LF_LONGLINK:
195        ERROR ((0, 0, _("Visible long name error")));
196 +      print_header();
197        skip_file ((long) hstat.st_size);
198        break;
199      }
200 diff -ru tar-1.11.8/src/list.c tar-1.11.8.1/src/list.c
201 --- tar-1.11.8/src/list.c       Wed May  3 05:28:17 1995
202 +++ tar-1.11.8.1/src/list.c     Sun Dec  1 16:22:12 1996
203 @@ -200,7 +200,7 @@
204           if (written > size)
205             written = size;
206           errno = 0;
207 -         check = fwrite (data, sizeof (char), written, stdlis);
208 +         check = fwrite (data, sizeof (char), written, stdrec);
209           userec ((union record *) (data + written - 1));
210           if (check != written)
211             {
212 @@ -213,8 +213,8 @@
213        if (flag_multivol)
214         assign_string (&save_name, NULL);
215        saverec (NULL);          /* unsave it */
216 -      fputc ('\n', stdlis);
217 -      fflush (stdlis);
218 +      fputc ('\n', stdrec);
219 +      fflush (stdrec);
220        return;
221  
222      }
223 @@ -353,6 +353,8 @@
224           longp = ((header->header.linkflag == LF_LONGNAME)
225                    ? &next_long_name
226                    : &next_long_link);
227 +         assign_string (&current_file_name, header->header.arch_name);
228 +          print_header();
229  
230           userec (header);
231           if (*longp)
232 @@ -533,9 +535,9 @@
233    char *name;
234  
235    if (flag_sayblock)
236 -    fprintf (stdlis, _("rec %10ld: "), baserec + (ar_record - ar_block));
237 +    fprintf (stdrec, _("rec %10ld: "), baserec + (ar_record - ar_block));
238  #if 0
239 -  annofile (stdlis, (char *) NULL);
240 +  annofile (stdrec, (char *) NULL);
241  #endif
242  
243    if (flag_verbose <= 1)
244 @@ -547,11 +549,11 @@
245  
246        if (quoted_name)
247         {
248 -         fprintf (stdlis, "%s\n", quoted_name);
249 +         fprintf (stdrec, "%s\n", quoted_name);
250           free (quoted_name);
251         }
252        else
253 -       fprintf (stdlis, "%s\n", current_file_name);
254 +       fprintf (stdrec, "%s\n", current_file_name);
255      }
256    else
257      {
258 @@ -562,6 +564,11 @@
259        switch (head->header.linkflag)
260         {
261         case LF_VOLHDR:
262 +          /* dirty bug fix to display the header processing
263 +           * tar cvvf /dev/null --label 'hello world' blah...
264 +           * J"org Weule weule@cs.uni-duesseldorf.de
265 +           */
266 +          hstat.st_mtime = from_oct(1 + 12 , head->header.mtime);
267           modes[0] = 'V';
268           break;
269  
270 @@ -574,8 +581,13 @@
271           break;
272  
273         case LF_LONGNAME:
274 +         /*ERROR ((0, 0, _("Visible longname error")));*/
275 +         modes[0] = 'L';
276 +         break;
277 +
278         case LF_LONGLINK:
279 -         ERROR ((0, 0, _("Visible longname error")));
280 +         /*ERROR ((0, 0, _("Visible longname error")));*/
281 +         modes[0] = 'K';
282           break;
283  
284         case LF_SPARSE:
285 @@ -663,18 +675,18 @@
286        if (pad > ugswidth)
287         ugswidth = pad;
288  
289 -      fprintf (stdlis, "%s %s/%s %*s%s %s %s",
290 +      fprintf (stdrec, "%s %s/%s %*s%s %s %s",
291                modes, user, group, ugswidth - pad, "",
292                size, timestamp + 4, timestamp + 20);
293  
294        name = quote_copy_string (current_file_name);
295        if (name)
296         {
297 -         fprintf (stdlis, " %s", name);
298 +         fprintf (stdrec, " %s", name);
299           free (name);
300         }
301        else
302 -       fprintf (stdlis, " %s", current_file_name);
303 +       fprintf (stdrec, " %s", current_file_name);
304  
305        switch (head->header.linkflag)
306         {
307 @@ -682,26 +694,26 @@
308           name = quote_copy_string (current_link_name);
309           if (name)
310             {
311 -             fprintf (stdlis, " -> %s\n", name);
312 +             fprintf (stdrec, " -> %s\n", name);
313               free (name);
314             }
315           else
316 -           fprintf (stdlis, " -> %s\n", current_link_name);
317 +           fprintf (stdrec, " -> %s\n", current_link_name);
318           break;
319  
320         case LF_LINK:
321           name = quote_copy_string (current_link_name);
322           if (name)
323             {
324 -             fprintf (stdlis, _(" link to %s\n"), name);
325 +             fprintf (stdrec, _(" link to %s\n"), name);
326               free (name);
327             }
328           else
329 -           fprintf (stdlis, _(" link to %s\n"), current_link_name);
330 +           fprintf (stdrec, _(" link to %s\n"), current_link_name);
331           break;
332  
333         default:
334 -         fprintf (stdlis, _(" unknown file type `%c'\n"),
335 +         fprintf (stdrec, _(" unknown file type `%c'\n"),
336                    head->header.linkflag);
337           break;
338  
339 @@ -714,24 +726,32 @@
340         case LF_FIFO:
341         case LF_CONTIG:
342         case LF_DUMPDIR:
343 -         putc ('\n', stdlis);
344 +         putc ('\n', stdrec);
345 +         break;
346 +
347 +       case LF_LONGNAME:
348 +         fprintf (stdrec, _("--Long Name--\n"));
349 +         break;
350 +
351 +       case LF_LONGLINK:
352 +         fprintf (stdrec, _("--Long Link--\n"));
353           break;
354  
355         case LF_VOLHDR:
356 -         fprintf (stdlis, _("--Volume Header--\n"));
357 +         fprintf (stdrec, _("--Volume Header--\n"));
358           break;
359  
360         case LF_MULTIVOL:
361 -         fprintf (stdlis, _("--Continued at byte %ld--\n"),
362 +         fprintf (stdrec, _("--Continued at byte %ld--\n"),
363                    from_oct (1 + 12, head->header.offset));
364           break;
365  
366         case LF_NAMES:
367 -         fprintf (stdlis, _("--Mangled file names--\n"));
368 +         fprintf (stdrec, _("--Mangled file names--\n"));
369           break;
370         }
371      }
372 -  fflush (stdlis);
373 +  fflush (stdrec);
374  }
375  
376  /*--------------------------------------------------------------.
377 @@ -753,9 +773,9 @@
378        demode ((unsigned) mode, modes + 1);
379  
380        if (flag_sayblock)
381 -       fprintf (stdlis, _("rec %10ld: "), baserec + (ar_record - ar_block));
382 +       fprintf (stdrec, _("rec %10ld: "), baserec + (ar_record - ar_block));
383  #if 0
384 -      annofile (stdlis, (char *) NULL);
385 +      annofile (stdrec, (char *) NULL);
386  #endif
387        name = quote_copy_string (pathname);
388        if (!name)
389 diff -ru tar-1.11.8/src/tar.c tar-1.11.8.1/src/tar.c
390 --- tar-1.11.8/src/tar.c        Sat Jun 17 22:48:32 1995
391 +++ tar-1.11.8.1/src/tar.c      Mon Apr  8 16:54:08 1996
392 @@ -860,6 +860,7 @@
393  #define OPTION_VOLNO_FILE      15
394  #define OPTION_COMPRESS_PROG   16
395  #define OPTION_RSH_COMMAND     17
396 +#define OPTION_RECORD_FILE      18
397  
398  /* Some cleanup is made in GNU tar long options.  Using old names will send
399     a warning to stderr.  */
400 @@ -925,6 +926,7 @@
401    {"preserve-permissions", no_argument, NULL, 'p'},
402    {"read-full-blocks", no_argument, NULL, 'B'},
403    {"record-number", no_argument, NULL, 'R'},
404 +  {"record-file", required_argument, NULL, OPTION_RECORD_FILE},
405    {"remove-files", no_argument, &flag_remove_files, 1},
406    {"rsh-command", required_argument, NULL, OPTION_RSH_COMMAND},
407    {"same-order", no_argument, NULL, 's'},
408 @@ -1059,6 +1061,7 @@
409        --checkpoint      print directory names while reading the archive\n\
410        --totals          print total bytes written while creating archive\n\
411    -R, --record-number   show record number within archive with each message\n\
412 +      --record-file     print the record information to file, enable -R\n\
413    -w, --interactive     ask for confirmation for every action\n\
414        --confirmation    same as -w\n"),
415              stdout);
416 @@ -1212,6 +1215,11 @@
417         flag_rsh_command = optarg;
418         break;
419  
420 +      case OPTION_RECORD_FILE:
421 +        record_file_name = optarg ;
422 +        flag_sayblock++;         /* Print block #s for debug */
423 +        break;
424 +
425        case 'g':
426         /* We are making a GNU dump; save directories at the beginning
427            of the archive, and include in each directory its contents.  */
428 @@ -1626,9 +1634,42 @@
429        break;
430  
431      case COMMAND_CREATE:
432 +/*
433 + * Comment the next line out if you have problems. Joerg Weule
434 + */
435 +#define PRINT_TROUPUT
436 +#ifdef PRINT_TROUPUT
437 +      start_time = time(0);
438 +      create_archive ();
439 +      if (flag_totals) {
440 +       time_t end_time = time(0);
441 +       double sec = end_time - start_time ;
442 +       double t = ((double)tot_written) * RECORDSIZE ;
443 +       fprintf (stderr, _("Total bytes written: %.0f"),t);
444 +       if ( t >= 1e9 ) fprintf(stderr, _(" (%3.1f Gb)"),t/1e9 ); else
445 +       if ( t >= 1e6 ) fprintf(stderr, _(" (%3.1f Mb)"),t/1e6 ); else
446 +       if ( t >= 1024 ) fprintf(stderr, _(" (%3.1f Kb)"),t/1024 );
447 +       fprintf(stderr,"\n");
448 +       if ( sec > 0.1 ){
449 +         long s, m, h = sec ;
450 +          m = h ;
451 +         h /= 3600 ;
452 +          m -= h * 3600 ;
453 +          s = m ;
454 +          m /= 60 ;
455 +          s -= m / 60 ;
456 +         fprintf (stderr, _("Elapsed time: %02d:%02d:%02d, %g sec\n"), h,m,s,sec);
457 +         if ( !flag_multivol)
458 +           fprintf (stderr, _("Throughput per second: %.0fKb/sec\n"),
459 +             t/sec/1024);
460 +       }
461 +      }
462 +#else
463        create_archive ();
464        if (flag_totals)
465 -       fprintf (stderr, _("Total bytes written: %d\n"), tot_written);
466 +       fprintf (stderr, _("Total bytes written: %g\n")),
467 +          ((double)tot_written) * RECORDSIZE );
468 +#endif
469        break;
470  
471      case COMMAND_EXTRACT:
472 diff -ru tar-1.11.8/src/tar.h tar-1.11.8.1/src/tar.h
473 --- tar-1.11.8/src/tar.h        Sat Jun 17 20:36:49 1995
474 +++ tar-1.11.8.1/src/tar.h      Mon Feb  5 20:19:19 1996
475 @@ -183,6 +183,9 @@
476      int numbytes;
477    };
478  
479 +/* Time of writing.  */
480 +GLOBAL time_t start_time;
481 +
482  /* Start of block of archive.  */
483  GLOBAL union record *ar_block;
484  
485 @@ -207,6 +210,9 @@
486  /* File containing names to work on.  */
487  GLOBAL const char *namefile_name;
488  
489 +/* File to write record information to. */
490 +GLOBAL char *record_file_name;
491 +
492  /* \n or \0.  */
493  GLOBAL char filename_terminator;
494  
495 @@ -219,8 +225,8 @@
496  /* Initial size of the sparsearray.  */
497  GLOBAL int sp_array_size;
498  
499 -/* Total written to output.  */
500 -GLOBAL int tot_written;
501 +/* Total written to output in records.  */
502 +GLOBAL long int tot_written;
503  
504  /* Compiled regex for extract label.  */
505  GLOBAL struct re_pattern_buffer *label_pattern;
506 @@ -338,6 +344,7 @@
507  
508  extern long baserec;
509  extern FILE *stdlis;
510 +extern FILE *stdrec;
511  extern char *save_name;
512  extern long save_sizeleft;
513  extern long save_totsize;