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
5 /* Where we write list messages (not errors, not interactions) to. Stdout
6 unless we're writing a pipe, in which case stderr. */
10 static void backspace_output PARAMS ((void));
11 static int new_volume PARAMS ((enum access_mode));
13 /* PID of child program, if compress_option or remote archive access. */
14 static pid_t child_pid;
16 +/* Record number of the start of this block of records */
19 /* Error recovery stuff */
20 static int read_error_count;
24 #endif /* DEBUG FORK */
28 init_total_written (void)
30 + start_time = time(0);
31 clear_tarlong (total_written);
32 clear_tarlong (bytes_written);
36 print_total_written (void)
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");
48 open_archive (enum access_mode access)
50 int backed_up_flag = 0;
51 + time_t start_time = time(0) ;
53 - stdlis = to_stdout_option ? stderr : stdout;
54 + stdrec = stdlis = to_stdout_option ? stderr : stdout;
56 + if ( record_file_name != NULL )
58 +#define INSERT_TIMESTAMP
59 +#ifdef INSERT_TIMESTAMP
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.
68 + * Another way would be to let us set the timestamp by another option.
69 + * tar --timestamp <ts-number> ...
72 + if ( access == ACCESS_READ ) {
73 + char*p= record_file_name ;
76 + while ( p[0] != '\0' ) {
77 + if ( p[0] == '%' && p[1] == 'T' ) {
78 + /* i += */ sprintf(rfn+i,"%d",start_time);
81 + } else { rfn[i++] = *p++ ; }
84 + } else strcpy(rfn,record_file_name);
86 + char*rfn=record_file_name;
88 + if ( ( stdrec = fopen(rfn,"w")) == NULL )
90 + fprintf(stdlis,"Cannot open %s.\n",record_file_name);
96 FATAL_ERROR ((0, 0, _("Invalid value for record_size")));
98 setmode (archive, O_BINARY);
101 +#if defined(MTIOCGET)
102 + /* Prints the file number of the archive */
103 + if ( block_number_option )
107 + i = ioctl(archive,MTIOCGET,&get);
108 + if (( i == 0 ) && ( get.mt_fileno >= 0 ))
111 + "loc number of the file is %d \n",
117 +#if defined(MTIOCPOS)
118 + /* Prints the tape block number on every Linux SCSI-device */
119 + if ( block_number_option )
123 + i = ioctl(archive,MTIOCPOS,&pos);
127 + "loc number of the first block is %d\n",
133 + /* Prints the size of the blocks */
134 + if ( block_number_option && blocking_factor != 20 )
137 + "loc block length is %d bytes = %d * 512 bytes\n",
138 + blocking_factor*512,blocking_factor);
145 assign_string (¤t_file_name, record_start->header.name);
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);
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
158 /* Initial size of the sparsearray. */
159 GLOBAL int sp_array_size;
161 +/* Time of writing. */
162 +GLOBAL time_t start_time;
164 +/* File to write record information to. */
165 +GLOBAL char *record_file_name;
167 /* Declarations for each module. */
171 /* Module buffer.c. */
173 +extern long baserec;
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
184 uintmax_to_oct ((uintmax_t) sum, header->header.chksum, 7);
186 - set_next_block_after (header);
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 */
195 /* These globals are parameters to print_header, sigh. */
198 current_format = archive_format;
202 + set_next_block_after (header);
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
211 case GNUTYPE_LONGNAME:
212 case GNUTYPE_LONGLINK:
213 ERROR ((0, 0, _("Visible long name error")));
215 skip_file (current_stat.st_size);
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
222 if (block_number_option)
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));
231 if (block_number_option)
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));
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)
250 if (multi_volume_option)
251 assign_string (&save_name, NULL);
252 - fputc ('\n', stdlis);
254 + fputc ('\n', stdrec);
260 longp = ((header->header.typeflag == GNUTYPE_LONGNAME)
263 + assign_string (¤t_file_name, header->header.name);
266 set_next_block_after (header);
268 @@ -763,10 +765,18 @@
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));
277 + annofile (stdrec, (char *) NULL);
280 if (block_number_option)
282 char buf[UINTMAX_STRSIZE_BOUND];
283 - fprintf (stdlis, _("block %s: "),
284 + fprintf (stdrec, _("block %s: "),
285 STRINGIFY_BIGINT (current_block_ordinal (), buf));
288 @@ -778,11 +788,11 @@
292 - fprintf (stdlis, "%s\n", quoted_name);
293 + fprintf (stdrec, "%s\n", quoted_name);
297 - fprintf (stdlis, "%s\n", current_file_name);
298 + fprintf (stdrec, "%s\n", current_file_name);
303 switch (current_header->header.typeflag)
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
310 + current_stat.st_mtime = time_from_oct(current_block->header.mtime,1+12);
317 case GNUTYPE_LONGNAME:
321 case GNUTYPE_LONGLINK:
322 - ERROR ((0, 0, _("Visible longname error")));
323 + /* ERROR ((0, 0, _("Visible longname error"))); */
328 @@ -898,22 +917,22 @@
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);
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);
342 name = quote_copy_string (current_file_name);
345 - fprintf (stdlis, " %s", name);
346 + fprintf (stdrec, " %s", name);
350 - fprintf (stdlis, " %s", current_file_name);
351 + fprintf (stdrec, " %s", current_file_name);
353 switch (current_header->header.typeflag)
355 @@ -921,26 +940,26 @@
356 name = quote_copy_string (current_link_name);
359 - fprintf (stdlis, " -> %s\n", name);
360 + fprintf (stdrec, " -> %s\n", name);
364 - fprintf (stdlis, " -> %s\n", current_link_name);
365 + fprintf (stdrec, " -> %s\n", current_link_name);
369 name = quote_copy_string (current_link_name);
372 - fprintf (stdlis, _(" link to %s\n"), name);
373 + fprintf (stdrec, _(" link to %s\n"), name);
377 - fprintf (stdlis, _(" link to %s\n"), current_link_name);
378 + fprintf (stdrec, _(" link to %s\n"), current_link_name);
382 - fprintf (stdlis, _(" unknown file type `%c'\n"),
383 + fprintf (stdrec, _(" unknown file type `%c'\n"),
384 current_header->header.typeflag);
387 @@ -953,11 +972,11 @@
390 case GNUTYPE_DUMPDIR:
391 - putc ('\n', stdlis);
392 + putc ('\n', stdrec);
396 - fprintf (stdlis, _("--Volume Header--\n"));
397 + fprintf (stdrec, _("--Volume Header--\n"));
400 case GNUTYPE_MULTIVOL:
401 @@ -965,15 +984,15 @@
403 (UINTMAX_FROM_OCT (current_header->oldgnu_header.offset),
405 - fprintf (stdlis, _("--Continued at byte %s--\n"), size);
406 + fprintf (stdrec, _("--Continued at byte %s--\n"), size);
410 - fprintf (stdlis, _("--Mangled file names--\n"));
411 + fprintf (stdrec, _("--Mangled file names--\n"));
419 /*--------------------------------------------------------------.
421 if (block_number_option)
423 char buf[UINTMAX_STRSIZE_BOUND];
424 - fprintf (stdlis, _("block %s: "),
425 + fprintf (stdrec, _("block %s: "),
426 STRINGIFY_BIGINT (current_block_ordinal (), buf));
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
433 FATAL_ERROR ((0, errno, _("Cannot change to directory %s"),
436 + if ( record_file_name )
438 + char *d = malloc(PATH_MAX);
439 + if( d && getcwd(d,PATH_MAX) )
441 + "loc current directory is %s\n",
445 else if (change_dirs && strcmp (name_buffer, "-C") == 0)
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
452 USE_COMPRESS_PROGRAM_OPTION,
454 + RECORD_FILE_OPTION,
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
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'},
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"),
475 volno_file_option = optarg;
478 + case RECORD_FILE_OPTION:
479 + record_file_name = optarg ;
480 + block_number_option++; /* Print block #s for debug */
483 case USE_COMPRESS_PROGRAM_OPTION:
484 set_use_compress_program_option (optarg);
486 @@ -1155,14 +1163,52 @@
489 case CREATE_SUBCOMMAND:
492 + * Comment the next line out if you have problems. Joerg Weule
494 +#define PRINT_TROUPUT
495 +#ifdef PRINT_TROUPUT
496 + start_time = time(0);
498 - init_total_written ();
499 + init_total_written ();
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 ();
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");
513 + long s, m, h = sec ;
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"),
529 + init_total_written ();
535 - print_total_written ();
536 + print_total_written ();
540 case EXTRACT_SUBCOMMAND: