+/*
+ * We are at the end of reading a tape. Now, we simulate handling
+ * the end of writing a tape by wiffling through the attached
+ * jcrs creating jobmedia records.
+ */
+static bool bscan_mount_next_read_volume(DCR *dcr)
+{
+ DEVICE *dev = dcr->dev;
+ DCR *mdcr;
+ Dmsg1(100, "Walk attached jcrs. Volume=%s\n", dev->VolCatInfo.VolCatName);
+ foreach_dlist(mdcr, dev->attached_dcrs) {
+ JCR *mjcr = mdcr->jcr;
+ if (mjcr->JobId == 0) {
+ continue;
+ }
+ if (verbose) {
+ Pmsg1(000, _("Create JobMedia for Job %s\n"), mjcr->Job);
+ }
+ if (dev->is_tape()) {
+ mdcr->EndBlock = dcr->EndBlock;
+ mdcr->EndFile = dcr->EndFile;
+// } else {
+// mdcr->EndBlock = (uint32_t)dcr->file_addr;
+// mdcr->EndFile = (uint32_t)(dcr->file_addr >> 32);
+ }
+ mjcr->read_dcr->VolLastIndex = dcr->VolLastIndex;
+ if (!create_jobmedia_record(db, mjcr)) {
+ Pmsg2(000, _("Could not create JobMedia record for Volume=%s Job=%s\n"),
+ dev->VolCatInfo.VolCatName, mjcr->Job);
+ }
+ }
+ /* Now let common read routine get up next tape. Note,
+ * we call mount_next... with bscan's jcr because that is where we
+ * have the Volume list, but we get attached.
+ */
+ bool stat = mount_next_read_volume(dcr);
+
+ if (showProgress) {
+ char ed1[50];
+ struct stat sb;
+ fstat(dev->fd(), &sb);
+ currentVolumeSize = sb.st_size;
+ Pmsg1(000, _("First Volume Size = %sn"),
+ edit_uint64(currentVolumeSize, ed1));
+ }
+ return stat;
+}
+
+static void do_scan()