+
+#ifdef MTIOCGET
+ /* Now check that we opened a tape device. */
+ {
+ struct mtget mt;
+
+ memset(&mt, 0, SIZEOF(mt));
+ if (ioctl(ret, MTIOCGET, &mt) < 0) {
+ close(ret);
+ fprintf(stderr, "tapedev %s is not a tape device!\n", filename);
+ return -1;
+ }
+
+#ifdef GMT_ONLINE
+ if (!GMT_ONLINE(mt.mt_gstat)) {
+ close(ret);
+ fprintf(stderr, "tapedev %s is offline or has no loaded tape.\n",
+ filename);
+ return -1;
+ }
+#endif /* GMT_ONLINE */
+ }
+#endif /* MTIOCGET */
+
+