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