+ return (got < 0 ? got : (ssize_t)count - need);
+}
+
+
+/*
+int
+SetLogicalPos(void)
+{
+ int err = 0;
+ struct mt_pos buf;
+
+ buf.mt_op = MTSETDRVBUFFER;
+ buf.mt_count = MT_ST_BOOLEANS | MT_ST_SCSI2LOGICAL;
+ if (ioctl(tapefd, MTIOCTOP, &buf) == -1) {
+ err = errno;
+ msg("[%ld] error: %d (setting logical)\n",
+ (unsigned long)getpid(), err);
+ }
+ return err;
+}
+*/
+
+#ifdef USE_QFA
+#define LSEEK_GET_TAPEPOS 10
+#define LSEEK_GO2_TAPEPOS 11
+/*
+ * read the current tape position
+ */
+static int
+GetTapePos(long long *pos)
+{
+ int err = 0;
+
+#ifdef RDUMP
+ if (host) {
+ *pos = (long long) rmtseek((OFF_T)0, (int)LSEEK_GET_TAPEPOS);
+ err = *pos < 0;
+ }
+ else
+#endif
+ {
+ if (magtapeout) {
+ long mtpos;
+ *pos = 0;
+ err = (ioctl(tapefd, MTIOCPOS, &mtpos) < 0);
+ *pos = (long long)mtpos;
+ }
+ else {
+ *pos = LSEEK(tapefd, 0, SEEK_CUR);
+ err = (*pos < 0);
+ }
+ }
+ if (err) {
+ err = errno;
+ msg("[%ld] error: %d (getting tapepos: %lld)\n", getpid(),
+ err, *pos);
+ return err;
+ }
+ return err;
+}
+
+static int
+MkTapeString(struct s_spcl *spclptr, long long curtapepos)
+{
+ int err = 0;
+
+#ifdef DEBUG_QFA
+ msg("inode %ld at tapepos %lld\n", spclptr->c_inumber, curtapepos);
+#endif
+
+ snprintf(gTps, sizeof(gTps), "%ld\t%d\t%lld\n",
+ (unsigned long)spclptr->c_inumber,
+ tapeno,
+ curtapepos);
+ gTps[sizeof(gTps) - 1] = '\0';
+ if (write(gTapeposfd, gTps, strlen(gTps)) != (ssize_t)strlen(gTps)) {
+ err = errno;
+ warn("error writing tapepos file. (error %d)\n", errno);
+ }
+ return err;