/* Buffer management for tar.
- Copyright 1988, 92, 93, 94, 96, 97, 99, 2000 Free Software Foundation, Inc.
+
+ Copyright 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001 Free
+ Software Foundation, Inc.
+
Written by John Gilmore, on 1985-08-25.
This program is free software; you can redistribute it and/or modify it
#include "system.h"
#include <signal.h>
-#include <time.h>
-#ifndef time
-time_t time ();
-#endif
#if MSDOS
# include <process.h>
static tarlong prev_written; /* bytes written on previous volumes */
static tarlong bytes_written; /* bytes written on this volume */
-/* FIXME: The following four variables should ideally be static to this
- module. However, this cannot be done yet, as update.c uses the first
- three a lot, and compare.c uses the fourth. The cleanup continues! */
+/* FIXME: The following variables should ideally be static to this
+ module. However, this cannot be done yet. The cleanup continues! */
union block *record_start; /* start of record of archive */
union block *record_end; /* last+1 block of archive record */
union block *current_block; /* current block of archive */
enum access_mode access_mode; /* how do we handle the archive */
+off_t records_read; /* number of records read from this archive */
+off_t records_written; /* likewise, for records written */
+
static struct stat archive_stat; /* stat block for archive file */
static off_t record_start_block; /* block ordinal at record_start */
off_t save_sizeleft; /* where we are in the file we are writing,
only valid if save_name is nonzero */
-int write_archive_to_stdout;
+bool write_archive_to_stdout;
/* Used by flush_read and flush_write to store the real info about saved
names. */
while (maximum)
{
count = maximum < BLOCKSIZE ? maximum : BLOCKSIZE;
- status = full_write (STDOUT_FILENO, cursor, count);
- if (status < 0)
+ if (full_write (STDOUT_FILENO, cursor, count) != count)
write_error (use_compress_program_option);
-
- if (status != count)
- {
- ERROR ((0, 0, _("Write to compression program short %lu bytes"),
- (unsigned long) (count - status)));
- count = status;
- }
-
cursor += count;
maximum -= count;
}
switch (wanted_access)
{
- case ACCESS_READ:
case ACCESS_UPDATE:
+ records_written = 0;
+ case ACCESS_READ:
+ records_read = 0;
record_end = record_start; /* set up for 1st record = # 0 */
find_next_block (); /* read it in, check for EOF */
break;
case ACCESS_WRITE:
+ records_written = 0;
if (volume_label_option)
{
memset (record_start, 0, BLOCKSIZE);
archive_write_error (status);
if (status > 0)
- bytes_written += status;
+ {
+ records_written++;
+ bytes_written += status;
+ }
if (status == record_size)
{
}
cursor = save_name + FILESYSTEM_PREFIX_LEN (save_name);
- while (*cursor == '/')
+ while (ISSLASH (*cursor))
cursor++;
assign_string (&real_s_name, cursor);
{
char *cursor = save_name + FILESYSTEM_PREFIX_LEN (save_name);
- while (*cursor == '/')
+ while (ISSLASH (*cursor))
cursor++;
assign_string (&real_s_name, cursor);
{
char *cursor = save_name + FILESYSTEM_PREFIX_LEN (save_name);
- while (*cursor == '/')
+ while (ISSLASH (*cursor))
cursor++;
assign_string (&real_s_name, cursor);
error_loop:
status = rmtread (archive, record_start->buffer, record_size);
if (status == record_size)
- return;
+ {
+ records_read++;
+ return;
+ }
if ((status == 0
|| (status < 0 && errno == ENOSPC)
cursor++;
}
current_block = cursor;
+ records_read++;
return;
}
else if (status < 0)
(unsigned long) ((record_size - left) / BLOCKSIZE)));
record_end = record_start + (record_size - left) / BLOCKSIZE;
+ records_read++;
}
/* Flush the current buffer to/from the archive. */
{
if (volno_file_option)
closeout_volume_number ();
- system (info_script_option);
+ if (system (info_script_option) != 0)
+ FATAL_ERROR ((0, 0, _("`%s' command failed"), info_script_option));
}
else
while (1)