- /*
- * If permitted, we label the device, make sure we can do
- * it by checking that the VolCatBytes is zero => not labeled,
- * once the Volume is labeled we don't want to label another
- * blank tape with the same name. For disk, we go ahead and
- * label it anyway, because the OS insures that there is only
- * one Volume with that name.
- * As noted above, at this point dcr->VolCatInfo has what
- * the Director wants and dev->VolCatInfo has info on the
- * previous tape (or nothing).
- */
- if (dev_cap(dev, CAP_LABEL) && (dcr->VolCatInfo.VolCatBytes == 0 ||
- (!dev_is_tape(dev) && strcmp(dcr->VolCatInfo.VolCatStatus,
- "Recycle") == 0))) {
- Dmsg0(100, "Create volume label\n");
- /* Create a new Volume label and write it to the device */
- if (!write_new_volume_label_to_dev(dcr, dcr->VolumeName,
- dcr->pool_name)) {
- Dmsg0(100, "!write_vol_label\n");
- goto mount_next_vol;
- }
- Dmsg0(100, "dir_update_vol_info. Set Append\n");
- /* Copy Director's info into the device info */
- memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
- if (!dir_update_volume_info(dcr, true)) { /* indicate tape labeled */
- return false;
- }
- Jmsg(jcr, M_INFO, 0, _("Labeled new Volume \"%s\" on device %s.\n"),
- dcr->VolumeName, dev_name(dev));
- goto read_volume; /* read label we just wrote */
- }
- /* If not removable, Volume is broken */
- if (!dev_cap(dev, CAP_REM)) {
- Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s.\n"),
- dcr->VolumeName, dev_name(dev));
- mark_volume_in_error(dcr);
- goto mount_next_vol;
+ if (dev->is_dvd()) {
+ Jmsg(jcr, M_FATAL, 0, "%s", jcr->errmsg);
+ mark_volume_in_error(dcr);
+ return false; /* we could not write on DVD */
+ }
+ /* Fall through wanted */
+ case VOL_NO_LABEL:
+ switch (try_autolabel(dcr)) {
+ case try_next_vol:
+ goto mount_next_vol;
+ case try_read_vol:
+ goto read_volume;
+ case try_error:
+ return false;
+ case try_default:
+ break;