+ if (!mount_next_write_volume(dcr, 1)) {
+ free_block(label_blk);
+ dcr->block = block;
+ P(dev->mutex);
+ unblock_device(dev);
+ return false; /* device locked */
+ }
+ P(dev->mutex); /* lock again */
+
+ Jmsg(jcr, M_INFO, 0, _("New volume \"%s\" mounted on device %s at %s.\n"),
+ dcr->VolumeName, dev->print_name(), 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(dcr)) {
+ berrno be;
+ Pmsg1(0, "write_block_to_device Volume label failed. ERR=%s",
+ be.strerror(dev->dev_errno));
+ free_block(label_blk);
+ dcr->block = block;
+ unblock_device(dev);
+ return false; /* device locked */
+ }
+ free_block(label_blk);
+ dcr->block = block;
+
+ /*
+ * 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)); ) {
+ DCR *mdcr;
+ foreach_dlist(mdcr, dev->attached_dcrs) {
+ JCR *mjcr = mdcr->jcr;
+ if (mjcr->JobId == 0) {
+ continue; /* ignore console */