+
+#ifdef USE_QFA
+/*
+ * get the current position of the tape
+ */
+int
+GetTapePos(long long *pos)
+{
+ int err = 0;
+
+#ifdef RDUMP
+ if (host) {
+ *pos = (long long) rmtseek(0, SEEK_CUR);
+ err = *pos < 0;
+ }
+ else
+#endif
+ {
+ if (magtapein) {
+ long mtpos;
+ *pos = 0;
+ err = (ioctl(mt, MTIOCPOS, &mtpos) < 0);
+ *pos = (long long)mtpos;
+ }
+ else {
+ *pos = LSEEK(mt, 0, SEEK_CUR);
+ err = (*pos < 0);
+ }
+ }
+ if (err) {
+ err = errno;
+ fprintf(stdout, "[%ld] error: %d (getting tapepos: %lld)\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 long pos)
+{
+ int err = 0;
+
+#ifdef RDUMP
+ if (host)
+ err = (rmtseek((long)pos, SEEK_SET) < 0);
+ else
+#endif
+ {
+ if (magtapein) {
+ struct mt_pos buf;
+ buf.mt_op = MTSEEK;
+ buf.mt_count = (int) pos;
+ err = (ioctl(mt, MTIOCTOP, &buf) < 0);
+ }
+ else {
+ pos = LSEEK(mt, pos, SEEK_SET);
+ err = (pos < 0);
+ }
+ }
+ if (err) {
+ err = errno;
+ fprintf(stdout, "[%ld] error: %d (setting tapepos: %lld)\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
+ReReadInodeFromTape(dump_ino_t theino)
+{
+ long cntloop = 0;
+
+ FLUSHTAPEBUF();
+ noresyncmesg = 1;
+ do {
+ cntloop++;
+ gethead(&spcl);
+ } while (!(spcl.c_inumber == theino && spcl.c_type == TS_INODE && spcl.c_date == dumpdate) && (cntloop < 32));
+#ifdef DEBUG_QFA
+ fprintf(stderr, "%ld reads\n", cntloop);
+ if (cntloop == 32) {
+ fprintf(stderr, "DEBUG: bufsize %d\n", bufsize);
+ fprintf(stderr, "DEBUG: ntrec %ld\n", ntrec);
+ fprintf(stderr, "DEBUG: %ld reads\n", cntloop);
+ }
+#endif
+ findinode(&spcl);
+ noresyncmesg = 0;
+}
+#endif /* USE_QFA */
+
+void
+RequestVol(long tnum)
+{
+ FLUSHTAPEBUF();
+ getvol(tnum);
+}