+ if (!magtape) { /* traditional */
+ switch (atoi(pos)) {
+ case SEEK_SET:
+ case SEEK_CUR:
+ case SEEK_END:
+ rval = LSEEK(tape, (OFF_T)atoll(count), atoi(pos));
+ break;
+#ifdef USE_QFA
+ case LSEEK_GET_TAPEPOS:
+ rval = LSEEK(tape, (OFF_T)0, SEEK_CUR);
+ break;
+ case LSEEK_GO2_TAPEPOS:
+ rval = LSEEK(tape, (OFF_T)atoll(count), SEEK_SET);
+ break;
+#endif /* USE_QFA */
+ default:
+ errno = EINVAL;
+ goto ioerror;
+ break;
+ }
+ }
+ else {
+ switch (atoi(pos)) {
+ case SEEK_SET:
+ case SEEK_CUR:
+ case SEEK_END:
+ rval = LSEEK(tape, (OFF_T)atoll(count), atoi(pos));
+ break;
+#ifdef USE_QFA
+ case LSEEK_GET_TAPEPOS: /* QFA */
+ case LSEEK_GO2_TAPEPOS:
+ {
+ struct mtop buf;
+ long mtpos;
+
+ buf.mt_op = MTSETDRVBUFFER;
+ buf.mt_count = MT_ST_BOOLEANS | MT_ST_SCSI2LOGICAL;
+ if (ioctl(tape, MTIOCTOP, &buf) < 0) {
+ goto ioerror;
+ }
+
+ if (atoi(pos) == LSEEK_GET_TAPEPOS) { /* get tapepos */
+ if (ioctl(tape, MTIOCPOS, &mtpos) < 0) {
+ goto ioerror;
+ }
+ rval = (OFF_T)mtpos;
+ } else {
+ buf.mt_op = MTSEEK;
+ buf.mt_count = atoi(count);
+ if (ioctl(tape, MTIOCTOP, &buf) < 0) {
+ goto ioerror;
+ }
+ rval = (OFF_T)buf.mt_count;
+ }
+ }
+ break;
+#endif /* USE_QFA */
+ default:
+ errno = EINVAL;
+ goto ioerror;
+ }
+ }