}
return 0;
}
+#ifdef MTEOM
if (dev_cap(dev, CAP_EOM)) {
mt_com.mt_op = MTEOM;
mt_com.mt_count = 1;
* Rewind then use FSF until EOT reached
*/
} else {
+#else
+ {
+#endif
if (!rewind_dev(dev)) {
return 0;
}
dev->file_addr = 0;
pos = lseek(dev->fd, (off_t)0, SEEK_CUR);
if (pos < 0) {
- Dmsg1(000, "Seek error: ERR=%s\n", strerror(dev->dev_errno));
+ Pmsg1(000, "Seek error: ERR=%s\n", strerror(dev->dev_errno));
dev->dev_errno = errno;
Mmsg2(&dev->errmsg, _("lseek error on %s. ERR=%s.\n"),
dev->dev_name, strerror(dev->dev_errno));
uint32_t stat = 0;
if (dev->state & (ST_EOT | ST_WEOT)) {
- stat |= MT_EOD;
+ stat |= BMT_EOD;
Dmsg0(-20, " EOD");
}
if (dev->state & ST_EOF) {
- stat |= MT_EOF;
+ stat |= BMT_EOF;
Dmsg0(-20, " EOF");
}
if (dev->state & ST_TAPE) {
- stat |= MT_TAPE;
+ stat |= BMT_TAPE;
Dmsg0(-20," Driver status:");
Dmsg2(-20," file=%d block=%d\n", dev->file, dev->block_num);
if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) < 0) {
#if defined(HAVE_LINUX_OS)
if (GMT_EOF(mt_stat.mt_gstat)) {
- stat |= MT_EOF;
+ stat |= BMT_EOF;
Dmsg0(-20, " EOF");
}
if (GMT_BOT(mt_stat.mt_gstat)) {
- stat |= MT_BOT;
+ stat |= BMT_BOT;
Dmsg0(-20, " BOT");
}
if (GMT_EOT(mt_stat.mt_gstat)) {
- stat |= MT_EOT;
+ stat |= BMT_EOT;
Dmsg0(-20, " EOT");
}
if (GMT_SM(mt_stat.mt_gstat)) {
- stat |= MT_SM;
+ stat |= BMT_SM;
Dmsg0(-20, " SM");
}
if (GMT_EOD(mt_stat.mt_gstat)) {
- stat |= MT_EOD;
+ stat |= BMT_EOD;
Dmsg0(-20, " EOD");
}
if (GMT_WR_PROT(mt_stat.mt_gstat)) {
- stat |= MT_WR_PROT;
+ stat |= BMT_WR_PROT;
Dmsg0(-20, " WR_PROT");
}
if (GMT_ONLINE(mt_stat.mt_gstat)) {
- stat |= MT_ONLINE;
+ stat |= BMT_ONLINE;
Dmsg0(-20, " ONLINE");
}
if (GMT_DR_OPEN(mt_stat.mt_gstat)) {
- stat |= MT_DR_OPEN;
+ stat |= BMT_DR_OPEN;
Dmsg0(-20, " DR_OPEN");
}
if (GMT_IM_REP_EN(mt_stat.mt_gstat)) {
- stat |= MT_IM_REP_EN;
+ stat |= BMT_IM_REP_EN;
Dmsg0(-20, " IM_REP_EN");
}
#endif /* !SunOS && !OSF */
Dmsg2(-20, " file=%d block=%d\n", mt_stat.mt_fileno, mt_stat.mt_blkno);
} else {
- stat |= MT_ONLINE | MT_BOT;
+ stat |= BMT_ONLINE | BMT_BOT;
}
*status = stat;
return 1;
dev->state &= ~(ST_EOF|ST_EOT);
}
- Dmsg0(200, "Doing MT_FSF\n");
+ Dmsg0(200, "Doing MTFSF\n");
stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com);
if (stat < 0) { /* error => EOT */
dev->state |= ST_EOT;
clrerror_dev(dev, MTFSF);
Mmsg2(&dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
dev->dev_name, strerror(dev->dev_errno));
- Dmsg0(200, "Got < 0 for MT_FSF\n");
+ Dmsg0(200, "Got < 0 for MTFSF\n");
Dmsg1(200, "%s", dev->errmsg);
} else {
dev->state |= ST_EOF; /* just read EOF */
msg = "WTWEOF";
dev->capabilities &= ~CAP_EOF; /* turn off feature */
break;
+#ifdef MTEOM
case MTEOM:
msg = "WTEOM";
dev->capabilities &= ~CAP_EOM; /* turn off feature */
break;
+#endif
case MTFSF:
msg = "MTFSF";
dev->capabilities &= ~CAP_FSF; /* turn off feature */
Emsg0(M_ERROR, 0, dev->errmsg);
}
}
+/* Found on Linux */
#ifdef MTIOCLRERR
{
struct mtop mt_com;
- int stat;
mt_com.mt_op = MTIOCLRERR;
mt_com.mt_count = 1;
- stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com);
+ /* Clear any error condition on the tape */
+ ioctl(dev->fd, MTIOCTOP, (char *)&mt_com);
Dmsg0(200, "Did MTIOCLRERR\n");
}
#endif
+
+/* Typically on FreeBSD */
+#ifdef MTIOCERRSTAT
+{
+ /* Read and clear SCSI error status */
+ union mterrstat mt_errstat;
+ ioctl(dev->fd, MTIOCERRSTAT, (char *)&mt_errstat);
+}
+#endif
}
/*
return (dev->state & ST_TAPE) ? 1 : 0;
}
+
+/*
+ * return 1 if the device is read for write, and 0 otherwise
+ * This is meant for checking at the end of a job to see
+ * if we still have a tape (perhaps not if at end of tape
+ * and the job is canceled).
+ */
+int
+dev_can_write(DEVICE *dev)
+{
+ if ((dev->state & ST_OPENED) && (dev->state & ST_APPEND) &&
+ (dev->state & ST_LABEL) && !(dev->state & ST_WEOT)) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
char *
dev_name(DEVICE *dev)
{