- if (!write_session_label(jcr, block, EOS_LABEL)) {
- Jmsg1(jcr, M_FATAL, 0, _("Error writting end session label. ERR=%s\n"),
- strerror_dev(dev));
- set_jcr_job_status(jcr, JS_ErrorTerminated);
- ok = FALSE;
+ /*
+ * If !OK, check if we can still write. This may not be the case
+ * if we are at the end of the tape or we got a fatal I/O error.
+ */
+ if (ok || dev->can_write()) {
+ if (!write_session_label(dcr, EOS_LABEL)) {
+ Jmsg1(jcr, M_FATAL, 0, _("Error writting end session label. ERR=%s\n"),
+ dev->bstrerror());
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
+ ok = false;
+ }
+ if (dev->VolCatInfo.VolCatName[0] == 0) {
+ Pmsg0(000, _("NULL Volume name. This shouldn't happen!!!\n"));
+ }
+ Dmsg0(90, "back from write_end_session_label()\n");
+ /* Flush out final partial block of this session */
+ if (!write_block_to_device(dcr)) {
+ Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"),
+ dev->print_name(), dev->bstrerror());
+ Dmsg0(100, _("Set ok=FALSE after write_block_to_device.\n"));
+ ok = false;
+ }