+/*
+ * This routine is meant to be called once the first pass
+ * to ensure that we have a candidate volume to mount.
+ * Otherwise, we ask the sysop to created one.
+ */
+bool DCR::find_a_volume()
+{
+ DCR *dcr = this;
+ if (!is_suitable_volume_mounted()) {
+ bool have_vol = false;
+ /* Do we have a candidate volume? */
+ if (dev->vol) {
+ bstrncpy(VolumeName, dev->vol->vol_name, sizeof(VolumeName));
+ have_vol = dir_get_volume_info(this, GET_VOL_INFO_FOR_WRITE);
+ }
+ /*
+ * Get Director's idea of what tape we should have mounted.
+ * in dcr->VolCatInfo
+ */
+ if (!have_vol) {
+ Dmsg0(200, "Before dir_find_next_appendable_volume.\n");
+ while (!dir_find_next_appendable_volume(dcr)) {
+ Dmsg0(200, "not dir_find_next\n");
+ if (job_canceled(jcr)) {
+ unlock_volumes();
+ return false;
+ }
+ unlock_volumes();
+ if (!dir_ask_sysop_to_create_appendable_volume(dcr)) {
+ return false;
+ }
+ lock_volumes();
+ Dmsg0(150, "Again dir_find_next_append...\n");
+ }
+ }
+ }
+ return true;
+}
+