+ /* Inform User about end of medium */
+ Jmsg(jcr, M_INFO, 0, _("End of medium on Volume \"%s\" Bytes=%s Blocks=%s at %s.\n"),
+ PrevVolName, edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
+ edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2),
+ bstrftime(dt, sizeof(dt), time(NULL)));
+
+ if (!mount_next_write_volume(jcr, dev, label_blk, 1)) {
+ free_block(label_blk);
+ P(dev->mutex);
+ unblock_device(dev);
+ return 0; /* device locked */
+ }
+ P(dev->mutex); /* lock again */
+
+ Jmsg(jcr, M_INFO, 0, _("New volume \"%s\" mounted on device %s at %s.\n"),
+ jcr->VolumeName, dev_name(dev), bstrftime(dt, sizeof(dt), time(NULL)));
+
+ /*
+ * If this is a new tape, the label_blk will contain the
+ * label, so write it now. If this is a previously
+ * used tape, mount_next_write_volume() will return an
+ * empty label_blk, and nothing will be written.
+ */
+ Dmsg0(190, "write label block to dev\n");
+ if (!write_block_to_dev(jcr->dcr, label_blk)) {
+ Pmsg1(0, "write_block_to_device Volume label failed. ERR=%s",
+ strerror_dev(dev));
+ free_block(label_blk);
+ unblock_device(dev);
+ return 0; /* device locked */
+ }
+ free_block(label_blk);
+
+ /*
+ * Walk through all attached jcrs indicating the volume has changed
+ */
+ Dmsg1(100, "Walk attached jcrs. Volume=%s\n", dev->VolCatInfo.VolCatName);
+ for (JCR *mjcr=NULL; (mjcr=next_attached_jcr(dev, mjcr)); ) {
+ if (mjcr->JobId == 0) {
+ continue; /* ignore console */