add a config file git-buildpackage
[debian/dds2tar] / tar-1.12.patch
1 diff -ru tar-1.12/src/buffer.c tar-1.12.1/src/buffer.c
2 --- tar-1.12/src/buffer.c       Fri Apr 25 15:48:46 1997
3 +++ tar-1.12.1/src/buffer.c     Fri Jul  3 12:46:24 1998
4 @@ -55,6 +55,7 @@
5  
6  static tarlong total_written;  /* bytes written on all volumes */
7  static tarlong bytes_written;  /* bytes written on this volume */
8 +static time_t start_time ;
9  
10  /* FIXME: The following four variables should ideally be static to this
11     module.  However, this cannot be done yet, as update.c uses the first
12 @@ -71,6 +72,7 @@
13  /* Where we write list messages (not errors, not interactions) to.  Stdout
14     unless we're writing a pipe, in which case stderr.  */
15  FILE *stdlis;
16 +FILE *stdrec;
17  
18  static void backspace_output PARAMS ((void));
19  static int new_volume PARAMS ((enum access_mode));
20 @@ -160,6 +162,36 @@
21    fprintf (stderr, _("Total bytes written: "));
22    print_tarlong (total_written, stderr);
23    fprintf (stderr, "\n");
24 +#define PRINT_TROUPUT
25 +#ifdef PRINT_TROUPUT
26 +/*
27 + * Comment the next line out if you have problems. Joerg Weule
28 + */
29 +  {
30 +       time_t end_time = time(0);
31 +       double sec = end_time - start_time ;
32 +       double t = ((double)total_written) ;
33 +       fprintf (stderr, _("Total bytes written: %.0f"),t);
34 +       if ( t >= 1e9 ) fprintf(stderr, _(" (%3.1f Gb)"),t/1e9 ); else
35 +       if ( t >= 1e6 ) fprintf(stderr, _(" (%3.1f Mb)"),t/1e6 ); else
36 +       if ( t >= 1024 ) fprintf(stderr, _(" (%3.1f Kb)"),t/1024 );
37 +       fprintf(stderr,"\n");
38 +       if ( sec > 0.1 ){
39 +         long s, m, h = sec ;
40 +          m = h ;
41 +         h /= 3600 ;
42 +          m -= h * 3600 ;
43 +          s = m ;
44 +          m /= 60 ;
45 +          s -= m / 60 ;
46 +         fprintf (stderr, _("Elapsed time: %02d:%02d:%02d, %g sec\n"), h,m,s,sec);
47 +         if ( NULL == volume_label_option )
48 +           fprintf (stderr, _("Throughput per second: %.0fKb/sec\n"),
49 +             t/sec/1024);
50 +       }
51 +  }
52 +#endif
53 +
54  }
55  
56  /*--------------------------------------------------------.
57 @@ -669,6 +701,7 @@
58  {
59    int backed_up_flag = 0;
60  
61 +  start_time = time(0) ;
62    stdlis = to_stdout_option ? stderr : stdout;
63  
64    if (record_size == 0)
65 @@ -823,6 +856,101 @@
66    setmode (archive, O_BINARY);
67  #endif
68  
69 +  stdrec = stdlis ;
70 +  if ( record_file_name != NULL )
71 +    {
72 +#define INSERT_TIMESTAMP
73 +#ifdef INSERT_TIMESTAMP
74 +      /*
75 +       * A record-file name with '%T' will be expanded with a decimal
76 +       * value for the timestamp of the archive. This is the time value
77 +       * stored in the label record.
78 +       * If you are using only one computer, this should be a unique number.
79 +       * You are able to create different rec-files for all your archives,
80 +       * as well as finding the index of your archive in a reliable way.
81 +       *
82 +       * Another way would be to let us set the timestamp by another option.
83 +       * tar --timestamp <ts-number> ...
84 +       */
85 +      char rfn[256];
86 +      if ( subcommand_option == CREATE_SUBCOMMAND ) {
87 +        char*p= record_file_name ;
88 +        int i = 0 ;
89 +        int n;
90 +        while ( p[0] != '\0' ) {
91 +          if ( p[0] == '%' && p[1] == 'T' ) {
92 +            /* i += */ sprintf(rfn+i,"%d",start_time);
93 +            i = strlen(rfn) ;
94 +            p += 2 ;
95 +          } else { rfn[i++] = *p++ ; }
96 +        }
97 +        rfn[i] = '\0' ;
98 +      } else strcpy(rfn,record_file_name);
99 +#else
100 +      char*rfn=record_file_name;
101 +#endif
102 +      if ( ( stdrec = fopen(rfn,"w")) == NULL )
103 +        {
104 +          fprintf(stdlis,"Cannot open %s.\n",record_file_name);
105 +          exit(1);
106 +        }
107 +    }
108 +
109 +  if ( ( record_file_name ) && ( volume_label_option ) )
110 +    {
111 +      fprintf(stdrec,
112 +        "loc             timestamp is %d \n",
113 +        start_time);
114 +    }
115 +  if ( record_file_name && (record_size != 10240) )
116 +    {
117 +      fprintf(stdrec,
118 +        "loc             block length is %d bytes = %d * 512 bytes \n",
119 +        record_size,record_size>>9);
120 +    }
121 +
122 +
123 +#if defined(MTIOCGET)
124 +  /* Prints the file number of the archive */
125 +  if ( record_file_name )
126 +    {
127 +      struct mtget get ;
128 +      int i ;
129 +      i = ioctl(archive,MTIOCGET,&get);
130 +      if (( i == 0 ) && ( get.mt_fileno >= 0 ))
131 +        {
132 +          fprintf(stdrec,
133 +            "loc             number of the file is %d \n",
134 +            get.mt_fileno );
135 +        }
136 +    }
137 +#endif
138 +
139 +#if defined(MTIOCPOS)
140 +  /* Prints the tape block number on every Linux SCSI-device */
141 +  if ( record_file_name )
142 +    {
143 +      struct mtpos pos ;
144 +      int i ;
145 +      i = ioctl(archive,MTIOCPOS,&pos);
146 +      if ( i == 0 )
147 +        {
148 +          fprintf(stdrec,
149 +            "loc             number of the first block is %d\n",
150 +            pos.mt_blkno );
151 +        }
152 +    }
153 +#endif
154 +  if ( record_file_name )
155 +    {
156 +      char *d = malloc(PATH_MAX);
157 +      if( d && getcwd(d,PATH_MAX) )
158 +        fprintf(stdrec,
159 +            "loc             current directory is %s\n",
160 +            d);
161 +    }
162 +
163 +
164    switch (access)
165      {
166      case ACCESS_READ:
167 @@ -856,7 +984,7 @@
168           assign_string (&current_file_name, record_start->header.name);
169  
170           record_start->header.typeflag = GNUTYPE_VOLHDR;
171 -         to_oct (time (0), 1 + 12, record_start->header.mtime);
172 +         to_oct (start_time, 1 + 12, record_start->header.mtime);
173           finish_header (record_start);
174  #if 0
175           current_block++;
176 @@ -958,6 +1086,7 @@
177        memset ((void *) record_start, 0, BLOCKSIZE);
178        sprintf (record_start->header.name, "%s Volume %d", volume_label_option, volno);
179        to_oct (time (0), 1 + 12, record_start->header.mtime);
180 +      to_oct (start_time, 1 + 12, record_start->header.mtime);
181        record_start->header.typeflag = GNUTYPE_VOLHDR;
182        finish_header (record_start);
183      }
184 diff -ru tar-1.12/src/common.h tar-1.12.1/src/common.h
185 --- tar-1.12/src/common.h       Tue Apr 22 08:31:03 1997
186 +++ tar-1.12.1/src/common.h     Thu Jan 29 01:36:57 1998
187 @@ -93,6 +93,9 @@
188  /* Name of this program.  */
189  GLOBAL const char *program_name;
190  
191 +/* Time of writing.  */
192 +GLOBAL time_t start_time;
193 +
194  /* Main command option.  */
195  
196  enum subcommand
197 @@ -141,6 +144,9 @@
198  /* Boolean value.  */
199  GLOBAL int block_number_option;
200  
201 +/* Name of the index file */
202 +GLOBAL char *record_file_name;
203 +
204  /* Boolean value.  */
205  GLOBAL int checkpoint_option;
206  
207 @@ -335,6 +341,7 @@
208  /* Module buffer.c.  */
209  
210  extern FILE *stdlis;
211 +extern FILE *stdrec;
212  extern char *save_name;
213  extern long save_sizeleft;
214  extern long save_totsize;
215 diff -ru tar-1.12/src/create.c tar-1.12.1/src/create.c
216 --- tar-1.12/src/create.c       Fri Apr 25 15:48:48 1997
217 +++ tar-1.12.1/src/create.c     Thu Jan 29 01:00:13 1998
218 @@ -329,7 +329,6 @@
219    to_oct ((long) sum, 8, header->header.chksum);
220    header->header.chksum[6] = '\0';     /* zap the space */
221  
222 -  set_next_block_after (header);
223  
224    if (verbose_option
225        && header->header.typeflag != GNUTYPE_LONGLINK
226 @@ -342,6 +341,8 @@
227        current_format = archive_format;
228        print_header ();
229      }
230 +
231 +  set_next_block_after (header);
232  }
233  \f
234  /* Sparse file processing.  */
235 diff -ru tar-1.12/src/list.c tar-1.12.1/src/list.c
236 --- tar-1.12/src/list.c Fri Apr 25 22:16:30 1997
237 +++ tar-1.12.1/src/list.c       Thu Jan 29 11:57:27 1998
238 @@ -120,7 +120,7 @@
239  
240         case HEADER_ZERO_BLOCK:
241           if (block_number_option)
242 -           fprintf (stdlis, _("block %10ld: ** Block of NULs **\n"),
243 +           fprintf (stdrec, _("block %10ld: ** Block of NULs **\n"),
244                      current_block_ordinal ());
245  
246           set_next_block_after (current_header);
247 @@ -131,7 +131,7 @@
248  
249         case HEADER_END_OF_FILE:
250           if (block_number_option)
251 -           fprintf (stdlis, _("block %10ld: ** End of File **\n"),
252 +           fprintf (stdrec, _("block %10ld: ** End of File **\n"),
253                      current_block_ordinal ());
254           break;
255  
256 @@ -208,7 +208,7 @@
257           if (written > size)
258             written = size;
259           errno = 0;            /* FIXME: errno should be read-only */
260 -         check = fwrite (data_block->buffer, sizeof (char), written, stdlis);
261 +         check = fwrite (data_block->buffer, sizeof (char), written, stdrec);
262           set_next_block_after ((union block *)
263                                 (data_block->buffer + written - 1));
264           if (check != written)
265 @@ -221,8 +221,8 @@
266         }
267        if (multi_volume_option)
268         assign_string (&save_name, NULL);
269 -      fputc ('\n', stdlis);
270 -      fflush (stdlis);
271 +      fputc ('\n', stdrec);
272 +      fflush (stdrec);
273        return;
274  
275      }
276 @@ -367,6 +367,9 @@
277                    ? &next_long_name
278                    : &next_long_link);
279  
280 +          assign_string (&current_file_name, header->header.name);
281 +          print_header();
282 +
283           set_next_block_after (header);
284           if (*longp)
285             free (*longp);
286 @@ -614,7 +617,7 @@
287    char *name;
288  
289    if (block_number_option)
290 -    fprintf (stdlis, _("block %10ld: "), current_block_ordinal ());
291 +    fprintf (stdrec, _("block %10ld: "), current_block_ordinal ());
292  
293    if (verbose_option <= 1)
294      {
295 @@ -624,11 +627,11 @@
296  
297        if (quoted_name)
298         {
299 -         fprintf (stdlis, "%s\n", quoted_name);
300 +         fprintf (stdrec, "%s\n", quoted_name);
301           free (quoted_name);
302         }
303        else
304 -       fprintf (stdlis, "%s\n", current_file_name);
305 +       fprintf (stdrec, "%s\n", current_file_name);
306      }
307    else
308      {
309 @@ -650,8 +653,12 @@
310           break;
311  
312         case GNUTYPE_LONGNAME:
313 +         modes[0] = 'L';
314 +         break;
315 +
316         case GNUTYPE_LONGLINK:
317 -         ERROR ((0, 0, _("Visible longname error")));
318 +         /*ERROR ((0, 0, _("Visible longname error")));*/
319 +         modes[0] = 'K';
320           break;
321  
322         case GNUTYPE_SPARSE:
323 @@ -743,22 +750,22 @@
324         ugswidth = pad;
325  
326  #if USE_OLD_CTIME
327 -      fprintf (stdlis, "%s %s/%s %*s%s %s %s",
328 +      fprintf (stdrec, "%s %s/%s %*s%s %s %s",
329                modes, user, group, ugswidth - pad, "",
330                size, timestamp + 4, timestamp + 20);
331  #else
332 -      fprintf (stdlis, "%s %s/%s %*s%s %s",
333 +      fprintf (stdrec, "%s %s/%s %*s%s %s",
334                modes, user, group, ugswidth - pad, "", size, timestamp);
335  #endif
336  
337        name = quote_copy_string (current_file_name);
338        if (name)
339         {
340 -         fprintf (stdlis, " %s", name);
341 +         fprintf (stdrec, " %s", name);
342           free (name);
343         }
344        else
345 -       fprintf (stdlis, " %s", current_file_name);
346 +       fprintf (stdrec, " %s", current_file_name);
347  
348        switch (current_header->header.typeflag)
349         {
350 @@ -766,26 +773,26 @@
351           name = quote_copy_string (current_link_name);
352           if (name)
353             {
354 -             fprintf (stdlis, " -> %s\n", name);
355 +             fprintf (stdrec, " -> %s\n", name);
356               free (name);
357             }
358           else
359 -           fprintf (stdlis, " -> %s\n", current_link_name);
360 +           fprintf (stdrec, " -> %s\n", current_link_name);
361           break;
362  
363         case LNKTYPE:
364           name = quote_copy_string (current_link_name);
365           if (name)
366             {
367 -             fprintf (stdlis, _(" link to %s\n"), name);
368 +             fprintf (stdrec, _(" link to %s\n"), name);
369               free (name);
370             }
371           else
372 -           fprintf (stdlis, _(" link to %s\n"), current_link_name);
373 +           fprintf (stdrec, _(" link to %s\n"), current_link_name);
374           break;
375  
376         default:
377 -         fprintf (stdlis, _(" unknown file type `%c'\n"),
378 +         fprintf (stdrec, _(" unknown file type `%c'\n"),
379                    current_header->header.typeflag);
380           break;
381  
382 @@ -798,24 +805,24 @@
383         case FIFOTYPE:
384         case CONTTYPE:
385         case GNUTYPE_DUMPDIR:
386 -         putc ('\n', stdlis);
387 +         putc ('\n', stdrec);
388           break;
389  
390         case GNUTYPE_VOLHDR:
391 -         fprintf (stdlis, _("--Volume Header--\n"));
392 +         fprintf (stdrec, _("--Volume Header--\n"));
393           break;
394  
395         case GNUTYPE_MULTIVOL:
396 -         fprintf (stdlis, _("--Continued at byte %ld--\n"),
397 +         fprintf (stdrec, _("--Continued at byte %ld--\n"),
398                    from_oct (1 + 12, current_header->oldgnu_header.offset));
399           break;
400  
401         case GNUTYPE_NAMES:
402 -         fprintf (stdlis, _("--Mangled file names--\n"));
403 +         fprintf (stdrec, _("--Mangled file names--\n"));
404           break;
405         }
406      }
407 -  fflush (stdlis);
408 +  fflush (stdrec);
409  }
410  
411  /*--------------------------------------------------------------.
412 @@ -836,16 +843,16 @@
413        decode_mode ((unsigned) mode, modes + 1);
414  
415        if (block_number_option)
416 -       fprintf (stdlis, _("block %10ld: "), current_block_ordinal ());
417 +       fprintf (stdrec, _("block %10ld: "), current_block_ordinal ());
418        name = quote_copy_string (pathname);
419        if (name)
420         {
421 -         fprintf (stdlis, "%s %*s %.*s\n", modes, ugswidth + DATEWIDTH,
422 +         fprintf (stdrec, "%s %*s %.*s\n", modes, ugswidth + DATEWIDTH,
423                    _("Creating directory:"), length, name);
424           free (name);
425         }
426        else
427 -       fprintf (stdlis, "%s %*s %.*s\n", modes, ugswidth + DATEWIDTH,
428 +       fprintf (stdrec, "%s %*s %.*s\n", modes, ugswidth + DATEWIDTH,
429                  _("Creating directory:"), length, pathname);
430      }
431  }
432 diff -ru tar-1.12/src/names.c tar-1.12.1/src/names.c
433 --- tar-1.12/src/names.c        Tue Apr 22 07:35:50 1997
434 +++ tar-1.12.1/src/names.c      Fri Jul  3 12:46:24 1998
435 @@ -332,6 +332,14 @@
436             FATAL_ERROR ((0, errno, _("Cannot change to directory %s"),
437                           name_buffer));
438           chdir_flag = 0;
439 +          if ( record_file_name )
440 +            {
441 +              char *d = malloc(PATH_MAX);
442 +              if( d && getcwd(d,PATH_MAX) )
443 +                fprintf(stdrec,
444 +                    "loc             current directory is %s\n",
445 +                    d);
446 +            }
447         }
448        else if (change_dirs && strcmp (name_buffer, "-C") == 0)
449         chdir_flag = 1;
450 diff -ru tar-1.12/src/tar.c tar-1.12.1/src/tar.c
451 --- tar-1.12/src/tar.c  Fri Apr 25 22:09:49 1997
452 +++ tar-1.12.1/src/tar.c        Tue Jul 28 15:44:57 1998
453 @@ -163,6 +163,7 @@
454  #define SUFFIX_OPTION                  15
455  #define USE_COMPRESS_PROGRAM_OPTION    16
456  #define VOLNO_FILE_OPTION              17
457 +#define OPTION_RECORD_FILE              18
458  
459  /* Some cleanup is being made in GNU tar long options.  Using old names is
460     allowed for a while, but will also send a warning to stderr.  Take old
461 @@ -251,6 +252,7 @@
462    {"read-full-records", no_argument, NULL, 'B'},
463    /* FIXME: --partial-blocks might be a synonym for --read-full-records?  */
464    {"record-number", no_argument, NULL, OBSOLETE_BLOCK_NUMBER},
465 +  {"record-file", required_argument, NULL, OPTION_RECORD_FILE},
466    {"record-size", required_argument, NULL, RECORD_SIZE_OPTION},
467    {"remove-files", no_argument, &remove_files_option, 1},
468    {"rsh-command", required_argument, NULL, RSH_COMMAND_OPTION},
469 @@ -410,6 +412,7 @@
470        --checkpoint      print directory names while reading the archive\n\
471        --totals          print total bytes written while creating archive\n\
472    -R, --block-number    show block number within archive with each message\n\
473 +      --record-file      print the record information to file, enable -R\n\
474    -w, --interactive     ask for confirmation for every action\n\
475        --confirmation    same as -w\n"),
476              stdout);
477 @@ -754,6 +757,10 @@
478  
479         block_number_option = 1;
480         break;
481 +
482 +      case OPTION_RECORD_FILE:
483 +        record_file_name = optarg ;
484 +        break;
485  
486        case 's':
487         /* Names to extr are sorted.  */