+ ret = open(filename, flags, mask);
+ }
+
+#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);
+ g_fprintf(stderr, _("tapedev %s is not a tape device!\n"), filename);
+ return -1;
+ }
+
+#ifdef GMT_ONLINE
+ if (!GMT_ONLINE(mt.mt_gstat)) {
+ close(ret);
+ g_fprintf(stderr, _("tapedev %s is offline or has no loaded tape.\n"),
+ filename);
+ return -1;
+ }
+#endif /* GMT_ONLINE */