block->binbuf = WRITE_BLKHDR_LENGTH;
block->bufp = block->buf + block->binbuf;
block->read_len = 0;
- block->failed_write = FALSE;
+ block->write_failed = false;
+ block->block_read = false;
}
/*
}
Jmsg(jcr, M_INFO, 0, _("User defined maximum volume capacity %s exceeded on device %s.\n"),
edit_uint64(max_cap, ed1), dev->dev_name);
- block->failed_write = TRUE;
+ block->write_failed = true;
dev->EndBlock = dev->block_num;
dev->EndFile = dev->file;
weof_dev(dev, 1); /* end the tape */
}
dev->VolCatInfo.VolCatWrites++;
- Dmsg1(500, "Write block of %u bytes\n", wlen);
+ Dmsg1(300, "Write block of %u bytes\n", wlen);
if ((uint32_t)(stat=write(dev->fd, block->buf, (size_t)wlen)) != wlen) {
/* We should check for errno == ENOSPC, BUT many
- * devices simply report EIO when it is full.
- * with a little more thought we may be able to check
+ * devices simply report EIO when the volume is full.
+ * With a little more thought we may be able to check
* capacity and distinguish real errors and EOT
* conditions. In any case, we probably want to
* simulate an End of Medium.
*/
- clrerror_dev(dev, -1);
-
- if (dev->dev_errno == 0) {
- dev->dev_errno = ENOSPC; /* out of space */
- }
-
- Dmsg4(10, "=== Write error. size=%u rtn=%d errno=%d: ERR=%s\n",
- wlen, stat, dev->dev_errno, strerror(dev->dev_errno));
-
if (stat == -1) {
+ clrerror_dev(dev, -1);
+ if (dev->dev_errno == 0) {
+ dev->dev_errno = ENOSPC; /* out of space */
+ }
Jmsg(jcr, M_ERROR, 0, _("Write error on device %s. ERR=%s.\n"),
dev->dev_name, strerror(dev->dev_errno));
} else {
+ dev->dev_errno = ENOSPC; /* out of space */
Jmsg3(jcr, M_INFO, 0, _("End of medium on device %s. Write of %u bytes got %d.\n"),
dev->dev_name, wlen, stat);
}
- block->failed_write = TRUE;
+
+ Dmsg4(10, "=== Write error. size=%u rtn=%d errno=%d: ERR=%s\n",
+ wlen, stat, dev->dev_errno, strerror(dev->dev_errno));
+
+ block->write_failed = true;
dev->EndBlock = dev->block_num;
dev->EndFile = dev->file;
weof_dev(dev, 1); /* end the tape */
dev->block_num++;
block->BlockNumber++;
-
Dmsg2(190, "write_block: wrote block %d bytes=%d\n", dev->block_num,
wlen);
empty_block(block);
if (retry == 1) {
dev->VolCatInfo.VolCatErrors++;
}
- } while (stat == -1 && (errno == EINTR || errno == EIO) && retry++ < 6);
+ } while (stat == -1 && (errno == EINTR || errno == EIO) && retry++ < 11);
if (stat < 0) {
Dmsg1(90, "Read device got: ERR=%s\n", strerror(errno));
clrerror_dev(dev, -1);
Mmsg2(&dev->errmsg, _("Read error on device %s. ERR=%s.\n"),
dev->dev_name, strerror(dev->dev_errno));
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
+ if (dev->state & ST_EOF) { /* EOF just seen? */
+ dev->state |= ST_EOT; /* yes, error => EOT */
+ }
return 0;
}
Dmsg1(90, "Read device got %d bytes\n", stat);
if (stat == 0) { /* Got EOF ! */
dev->block_num = block->read_len = 0;
Mmsg1(&dev->errmsg, _("Read zero bytes on device %s.\n"), dev->dev_name);
- if (dev->state & ST_EOF) { /* EOF alread read? */
+ if (dev->state & ST_EOF) { /* EOF already read? */
dev->state |= ST_EOT; /* yes, 2 EOFs => EOT */
block->read_len = 0;
return 0;
return 0;
}
-#ifdef somehow_working
- if (check_block_numbers) {
- if (BlockNumber != block->BlockNumber) {
- Jmsg(jcr, M_ERROR, 0, _("Incorrect block sequence number. Expected %u, got %u\n"),
- BlockNumber, block->BlockNumber);
- }
- }
-#endif
-
/*
* If the block is bigger than the buffer, we reposition for
* re-reading the block, allocate a buffer of the correct size,
}
Dmsg2(200, "Exit read_block read_len=%d block_len=%d\n",
block->read_len, block->block_len);
+ block->block_read = true;
return 1;
}