]> Dogcows Code - chaz/tar/commitdiff
*** empty log message ***
authorFrançois Pinard <pinard@iro.umontreal.ca>
Wed, 16 Nov 1994 02:46:28 +0000 (02:46 +0000)
committerFrançois Pinard <pinard@iro.umontreal.ca>
Wed, 16 Nov 1994 02:46:28 +0000 (02:46 +0000)
src/buffer.c
src/extract.c

index 90243342f83b0f33336c159ed8183bdeaa9f9e92..a159b16be3700f4f5b964447304e466d1a1c4f6a 100644 (file)
@@ -1,5 +1,5 @@
 /* Buffer management for tar.
-   Copyright (C) 1988 Free Software Foundation
+   Copyright (C) 1988, 1992 Free Software Foundation
 
 This file is part of GNU Tar.
 
@@ -33,7 +33,7 @@ extern int errno;
 #include <time.h>
 time_t time();
 
-#ifndef NO_MTIO
+#ifdef HAVE_SYS_MTIO_H
 #include <sys/ioctl.h>
 #include <sys/mtio.h>
 #endif
@@ -127,6 +127,9 @@ static int  r_error_count;
  */
 static int     hit_eof;
 
+/* Checkpointing counter */
+static int checkpoint;
+
 /* JF we're reading, but we just read the last record and its time to update */
 extern time_to_start_writing;
 int file_to_switch_to= -1;     /* If remote update, close archive, and use
@@ -134,6 +137,7 @@ int file_to_switch_to= -1;  /* If remote update, close archive, and use
 
 static int volno = 1;          /* JF which volume of a multi-volume tape
                                   we're on */
+static int global_volno = 1;   /* Volume number to print in external messages. */
 
 char *save_name = 0;           /* Name of the file we are currently writing */
 long save_totsize;             /* total size of file we are writing.  Only
@@ -650,6 +654,8 @@ fl_write()
        int copy_back;
        static long bytes_written = 0;
 
+       if (f_checkpoint && ! (++checkpoint % 10))
+         msg ("Write checkpoint %d\n", checkpoint);
        if(tape_length && bytes_written >= tape_length * 1024) {
                errno = ENOSPC;
                err = 0;
@@ -686,9 +692,11 @@ fl_write()
 
        /* We're multivol  Panic if we didn't get the right kind of response */
        /* ENXIO is for the UNIX PC */
-       if(err>0 || (err<0 && errno!=ENOSPC && errno!=EIO && errno!=ENXIO))
+       if(err<0 && errno!=ENOSPC && errno!=EIO && errno!=ENXIO)
                writeerror(err);
 
+       /* If error indicates a short write, we just move to the next tape. */
+
        if(new_volume(0)<0)
                return;
        bytes_written=0;
@@ -821,6 +829,9 @@ fl_read()
        int left;               /* Bytes left */
        char *more;             /* Pointer to next byte to read */
 
+       if (f_checkpoint && ! (++checkpoint % 10))
+         msg ("Read checkpoint %d\n", checkpoint);
+
        /*
         * Clear the count of errors.  This only applies to a single
         * call to fl_read.  We leave read_error_flag alone; it is
@@ -872,7 +883,7 @@ error_loop:
        if (err == blocksize)
                return;
 
-       if((err == 0 || (err<0 && errno==ENOSPC)) && f_multivol) {
+       if((err == 0 || (err<0 && errno==ENOSPC) || (err > 0 && !f_reblock)) && f_multivol) {
                union record *head;
 
        try_volume:
@@ -903,6 +914,7 @@ error_loop:
                                        msg("Volume mismatch! %s!=%s",f_volhdr,
                                            head->header.name);
                                        --volno;
+                                       --global_volno;
                                        goto try_volume;
                                      }
                                    
@@ -910,6 +922,7 @@ error_loop:
                                if(strcmp(ptr,head->header.name)) {
                                        msg("Volume mismatch! %s!=%s",ptr,head->header.name);
                                        --volno;
+                                       --global_volno;
                                        free(ptr);
                                        goto try_volume;
                                }
@@ -929,6 +942,7 @@ error_loop:
                        if(head->header.linkflag!=LF_MULTIVOL || strcmp(head->header.name,real_s_name)) {
                                msg("%s is not continued on this volume!",real_s_name);
                                --volno;
+                               --global_volno;
                                goto try_volume;
                        }
                        if(real_s_totsize!=from_oct(1+12,head->header.size)+from_oct(1+12,head->header.offset)) {
@@ -937,11 +951,13 @@ error_loop:
                                       from_oct(1+12,head->header.size),
                                       from_oct(1+12,head->header.offset));
                                --volno;
+                               --global_volno;
                                goto try_volume;
                        }
                        if(real_s_totsize-real_s_sizeleft!=from_oct(1+12,head->header.offset)) {
                                msg("This volume is out of sequence");
                                --volno;
+                               --global_volno;
                                goto try_volume;
                        }
                        head++;
@@ -1187,6 +1203,39 @@ anno(stream, prefix, savedp)
 }
 #endif
 
+/* Called to initialize the global volume number. */
+int
+init_volume_number ()
+{
+  FILE *vf;
+  
+  vf = fopen (f_volno_file, "r");
+  if (!vf && errno != ENOENT)
+    msg_perror ("%s", f_volno_file);
+  
+  if (vf)
+    {
+      fscanf (vf, "%d", &global_volno);
+      fclose (vf);
+    }
+}
+
+/* Called to write out the closing global volume number. */
+int
+closeout_volume_number ()
+{
+  FILE *vf;
+  
+  vf = fopen (f_volno_file, "w");
+  if (!vf)
+    msg_perror ("%s", f_volno_file);
+  else
+    {
+      fprintf (vf, "%d\n", global_volno);
+      fclose (vf);
+    }
+}
+  
 /* We've hit the end of the old volume.  Close it and open the next one */
 /* Values for type:  0: writing  1: reading  2: updating */
 int
@@ -1211,12 +1260,13 @@ int     type;
        if((c=rmtclose(archive))<0)
                msg_perror("Warning: can't close %s(%d,%d)",ar_file,archive,c);
 
+       global_volno++;
        volno++;
  tryagain:
        if (f_run_script_at_end)
                system(info_script);
        else for(;;) {
-               fprintf(msg_file,"\007Prepare volume #%d and hit return: ",volno);
+               fprintf(msg_file,"\007Prepare volume #%d and hit return: ",global_volno);
                fflush(msg_file);
                if(fgets(inbuf,sizeof(inbuf),read_file)==0) {
                        fprintf(msg_file,"EOF?  What does that mean?");
index d162cab04ec6448dcf86bf1382110ef4cc7a12be..84e6a234371f34016a98b1a355e110f22ad903ca 100644 (file)
@@ -542,7 +542,7 @@ extract_archive ()
          if (chmod (skipcrud + current_file_name,
                     notumask & (int) hstat.st_mode) < 0)
            {
-             msg_perror ("cannot change mode of file %s to %ld",
+             msg_perror ("cannot change mode of file %s to %lo",
                          skipcrud + current_file_name,
                          notumask & (int) hstat.st_mode);
            }
@@ -719,7 +719,7 @@ extract_archive ()
              if (chmod (skipcrud + current_file_name,
                         notumask & (int) hstat.st_mode) < 0)
                {
-                 msg_perror ("cannot change mode of file %s to %ld",
+                 msg_perror ("cannot change mode of file %s to %lo",
                              skipcrud + current_file_name,
                              notumask & (int) hstat.st_mode);
                }
@@ -897,7 +897,7 @@ restore_saved_dir_info ()
          if (chmod (saved_dir_info_head->path,
                     notumask & saved_dir_info_head->mode) < 0)
            {
-             msg_perror ("cannot change mode of file %s to %ld",
+             msg_perror ("cannot change mode of file %s to %lo",
                          saved_dir_info_head->path,
                          notumask & saved_dir_info_head->mode);
            }
This page took 0.030208 seconds and 4 git commands to generate.