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
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 ;
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
13 /* Where we write list messages (not errors, not interactions) to. Stdout
14 unless we're writing a pipe, in which case stderr. */
18 static void backspace_output PARAMS ((void));
19 static int new_volume PARAMS ((enum access_mode));
21 fprintf (stderr, _("Total bytes written: "));
22 print_tarlong (total_written, stderr);
23 fprintf (stderr, "\n");
24 +#define PRINT_TROUPUT
27 + * Comment the next line out if you have problems. Joerg Weule
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");
39 + long s, m, h = sec ;
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"),
56 /*--------------------------------------------------------.
59 int backed_up_flag = 0;
61 + start_time = time(0) ;
62 stdlis = to_stdout_option ? stderr : stdout;
66 setmode (archive, O_BINARY);
70 + if ( record_file_name != NULL )
72 +#define INSERT_TIMESTAMP
73 +#ifdef INSERT_TIMESTAMP
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.
82 + * Another way would be to let us set the timestamp by another option.
83 + * tar --timestamp <ts-number> ...
86 + if ( subcommand_option == CREATE_SUBCOMMAND ) {
87 + char*p= record_file_name ;
90 + while ( p[0] != '\0' ) {
91 + if ( p[0] == '%' && p[1] == 'T' ) {
92 + /* i += */ sprintf(rfn+i,"%d",start_time);
95 + } else { rfn[i++] = *p++ ; }
98 + } else strcpy(rfn,record_file_name);
100 + char*rfn=record_file_name;
102 + if ( ( stdrec = fopen(rfn,"w")) == NULL )
104 + fprintf(stdlis,"Cannot open %s.\n",record_file_name);
109 + if ( ( record_file_name ) && ( volume_label_option ) )
112 + "loc timestamp is %d \n",
115 + if ( record_file_name && (record_size != 10240) )
118 + "loc block length is %d bytes = %d * 512 bytes \n",
119 + record_size,record_size>>9);
123 +#if defined(MTIOCGET)
124 + /* Prints the file number of the archive */
125 + if ( record_file_name )
129 + i = ioctl(archive,MTIOCGET,&get);
130 + if (( i == 0 ) && ( get.mt_fileno >= 0 ))
133 + "loc number of the file is %d \n",
139 +#if defined(MTIOCPOS)
140 + /* Prints the tape block number on every Linux SCSI-device */
141 + if ( record_file_name )
145 + i = ioctl(archive,MTIOCPOS,&pos);
149 + "loc number of the first block is %d\n",
154 + if ( record_file_name )
156 + char *d = malloc(PATH_MAX);
157 + if( d && getcwd(d,PATH_MAX) )
159 + "loc current directory is %s\n",
168 assign_string (¤t_file_name, record_start->header.name);
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);
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);
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
188 /* Name of this program. */
189 GLOBAL const char *program_name;
191 +/* Time of writing. */
192 +GLOBAL time_t start_time;
194 /* Main command option. */
199 GLOBAL int block_number_option;
201 +/* Name of the index file */
202 +GLOBAL char *record_file_name;
205 GLOBAL int checkpoint_option;
208 /* Module buffer.c. */
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
219 to_oct ((long) sum, 8, header->header.chksum);
220 header->header.chksum[6] = '\0'; /* zap the space */
222 - set_next_block_after (header);
225 && header->header.typeflag != GNUTYPE_LONGLINK
227 current_format = archive_format;
231 + set_next_block_after (header);
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
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 ());
246 set_next_block_after (current_header);
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 ());
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)
267 if (multi_volume_option)
268 assign_string (&save_name, NULL);
269 - fputc ('\n', stdlis);
271 + fputc ('\n', stdrec);
280 + assign_string (¤t_file_name, header->header.name);
283 set_next_block_after (header);
289 if (block_number_option)
290 - fprintf (stdlis, _("block %10ld: "), current_block_ordinal ());
291 + fprintf (stdrec, _("block %10ld: "), current_block_ordinal ());
293 if (verbose_option <= 1)
295 @@ -624,11 +627,11 @@
299 - fprintf (stdlis, "%s\n", quoted_name);
300 + fprintf (stdrec, "%s\n", quoted_name);
304 - fprintf (stdlis, "%s\n", current_file_name);
305 + fprintf (stdrec, "%s\n", current_file_name);
312 case GNUTYPE_LONGNAME:
316 case GNUTYPE_LONGLINK:
317 - ERROR ((0, 0, _("Visible longname error")));
318 + /*ERROR ((0, 0, _("Visible longname error")));*/
323 @@ -743,22 +750,22 @@
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);
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);
337 name = quote_copy_string (current_file_name);
340 - fprintf (stdlis, " %s", name);
341 + fprintf (stdrec, " %s", name);
345 - fprintf (stdlis, " %s", current_file_name);
346 + fprintf (stdrec, " %s", current_file_name);
348 switch (current_header->header.typeflag)
350 @@ -766,26 +773,26 @@
351 name = quote_copy_string (current_link_name);
354 - fprintf (stdlis, " -> %s\n", name);
355 + fprintf (stdrec, " -> %s\n", name);
359 - fprintf (stdlis, " -> %s\n", current_link_name);
360 + fprintf (stdrec, " -> %s\n", current_link_name);
364 name = quote_copy_string (current_link_name);
367 - fprintf (stdlis, _(" link to %s\n"), name);
368 + fprintf (stdrec, _(" link to %s\n"), name);
372 - fprintf (stdlis, _(" link to %s\n"), current_link_name);
373 + fprintf (stdrec, _(" link to %s\n"), current_link_name);
377 - fprintf (stdlis, _(" unknown file type `%c'\n"),
378 + fprintf (stdrec, _(" unknown file type `%c'\n"),
379 current_header->header.typeflag);
382 @@ -798,24 +805,24 @@
385 case GNUTYPE_DUMPDIR:
386 - putc ('\n', stdlis);
387 + putc ('\n', stdrec);
391 - fprintf (stdlis, _("--Volume Header--\n"));
392 + fprintf (stdrec, _("--Volume Header--\n"));
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));
402 - fprintf (stdlis, _("--Mangled file names--\n"));
403 + fprintf (stdrec, _("--Mangled file names--\n"));
411 /*--------------------------------------------------------------.
412 @@ -836,16 +843,16 @@
413 decode_mode ((unsigned) mode, modes + 1);
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);
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);
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);
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
436 FATAL_ERROR ((0, errno, _("Cannot change to directory %s"),
439 + if ( record_file_name )
441 + char *d = malloc(PATH_MAX);
442 + if( d && getcwd(d,PATH_MAX) )
444 + "loc current directory is %s\n",
448 else if (change_dirs && strcmp (name_buffer, "-C") == 0)
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
454 #define SUFFIX_OPTION 15
455 #define USE_COMPRESS_PROGRAM_OPTION 16
456 #define VOLNO_FILE_OPTION 17
457 +#define OPTION_RECORD_FILE 18
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
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},
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"),
479 block_number_option = 1;
482 + case OPTION_RECORD_FILE:
483 + record_file_name = optarg ;
487 /* Names to extr are sorted. */