]> git.wh0rd.org - dump.git/blobdiff - restore/tape.c
New config.guess and config.sub version, + minor cleanup.
[dump.git] / restore / tape.c
index 63eae65ef23cf95a29dd747bed9f3e0a08496bd2..f46ac48a1f5ea0a9f60efd916fb66ae4a661f546 100644 (file)
@@ -46,7 +46,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.31 2001/03/27 08:09:21 stelian Exp $";
+       "$Id: tape.c,v 1.34 2001/04/12 16:03:30 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -82,6 +82,9 @@ static const char rcsid[] =
 #include "extern.h"
 #include "pathnames.h"
 
+#ifdef USE_QFA
+int            noresyncmesg = 0;
+#endif /* USE_QFA */
 static long    fssize = MAXBSIZE;
 static int     mt = -1;
 static int     pipein = 0;
@@ -147,7 +150,7 @@ static void readtape_comprtape __P((char *));
 static char    *decompress_tapebuf __P((struct tapebuf *, int));
 static void    msg_read_error __P((char *));
 #endif
-static int     read_a_block __P((int, void *, size_t, long *));
+static int     read_a_block __P((int, char *, size_t, long *));
 #define PREFIXSIZE     sizeof(struct tapebuf)
 
 #define COMPARE_ONTHEFLY 1
@@ -838,6 +841,11 @@ loop:
                (*fill)((char *)buf, (size_t)(curblk * TP_BSIZE) + size);
                last_write_was_hole = 0;
        }
+       if (size > 0) {
+               fprintf(stderr, "Missing blocks at the end of %s, assuming hole\n", curfile.name);
+               (*skip)(clearedbuf, size);
+               last_write_was_hole = 1;
+       }
        if (last_write_was_hole) {
                ftruncate(ofile, origsize);
        }
@@ -1784,7 +1792,7 @@ findtapeblksize(void)
 /*
  * Read a block of data handling all of the messy details.
  */
-static int read_a_block(int fd, void *buf, size_t len, long *lengthread)
+static int read_a_block(int fd, char *buf, size_t len, long *lengthread)
 {
        long i = 1, size;
 
@@ -2095,8 +2103,11 @@ findinode(struct s_spcl *header)
                }
        } while (header->c_type == TS_ADDR);
        if (skipcnt > 0)
-               fprintf(stderr, "resync restore, skipped %ld blocks\n",
-                   skipcnt);
+#ifdef USE_QFA
+               if (!noresyncmesg)
+#endif
+                       fprintf(stderr, "resync restore, skipped %ld blocks\n",
+                               skipcnt);
        skipcnt = 0;
 }
 
@@ -2250,3 +2261,72 @@ swabl(u_long x)
        return (x);
 }
 #endif
+
+#ifdef USE_QFA
+/*
+ * get the current position of the tape
+ */
+int
+GetTapePos(long *pos)
+{
+       int err = 0;
+
+       *pos = 0;
+       if (ioctl(mt, MTIOCPOS, pos) == -1) {
+               err = errno;
+               fprintf(stdout, "[%ld] error: %d (getting tapepos: %ld)\n", 
+                       (unsigned long)getpid(), err, *pos);
+               return err;
+       }
+       return err;
+}
+
+typedef struct mt_pos {
+       short    mt_op;
+       int      mt_count;
+} MTPosRec, *MTPosPtr;
+
+/*
+ * go to specified position on tape
+ */
+int
+GotoTapePos(long pos)
+{
+       int err = 0;
+       struct mt_pos buf;
+
+       buf.mt_op = MTSEEK;
+       buf.mt_count = pos;
+       if (ioctl(mt, MTIOCTOP, &buf) == -1) {
+               err = errno;
+               fprintf(stdout, "[%ld] error: %d (setting tapepos: %ld)\n", 
+                       (unsigned long)getpid(), err, pos);
+               return err;
+       }
+       return err;
+}
+
+/*
+ * read next data from tape to re-sync
+ */
+void
+ReReadFromTape(void)
+{
+       FLUSHTAPEBUF();
+       noresyncmesg = 1;
+       if (gethead(&spcl) == FAIL) {
+#ifdef DEBUG_QFA
+               fprintf(stdout, "DEBUG 1 gethead failed\n");
+#endif
+       }
+       findinode(&spcl);
+       noresyncmesg = 0;
+}
+
+void
+RequestVol(long tnum)
+{
+       FLUSHTAPEBUF();
+       getvol(tnum);
+}
+#endif /* USE_QFA */