- if (debug_level >= 10) {
- dump_volume_label(dev);
- }
- Dmsg0(30, "Leave read_volume_label() VOL_OK\n");
- return VOL_OK;
-}
-
-/* Read the volume label by guessing the volume name. (only for DVD devices)
- * write is true if we are reading the label before writing to the device.
- *
- * If the volume name cannot be guessed :
- * Writing : returns the label of the current file (on the harddisk).
- * Reading : returns an error
- */
-int read_dvd_volume_label(DCR *dcr, bool write)
-{
- int vol_label_status;
- DEVICE *dev = dcr->dev;
- JCR *jcr = dcr->jcr;
- Dmsg3(100, "Enter read_dvd_volume_label device=%s vol=%s dev_Vol=%s\n",
- dev->print_name(), dcr->VolumeName, dev->VolHdr.VolName);
-
- if (!dev->is_dvd()) {
- Jmsg1(jcr, M_ABORT, 0, _("Device %s is not a DVD.\n"), dev->print_name());
- return -1; /* for compiler, won't get here */
- }
-
- if (!write && (dcr->VolCatInfo.VolCatParts == 0)) {
- Dmsg0(100, "Leave read_dvd_volume_label !writing, and VolCatParts == 0\n");
- return read_dev_volume_label(dcr);
- }
-
- /*
- * For mounted devices, try to guess the Volume name
- * and read the label if possible.
- */
- if (open_mounted_dev(dev) < 0) {
- if (!write || dcr->VolCatInfo.VolCatParts > 0) {
- Mmsg2(jcr->errmsg, _("Requested Volume \"%s\" on %s is not a Bacula labeled Volume."),
- dev->print_name(), dcr->VolumeName);
- Dmsg0(100, "Leave read_dvd_volume_label VOL_NO_LABEL (!open_mounted_dev)\n");
- return VOL_NO_LABEL;
- }
-
- if (write && dev->free_space_errno < 0) {
- Dmsg0(100, "Leave read_dvd_volume_label !free_space VOL_NO_MEDIA\n");
- Mmsg2(jcr->errmsg, _("free_space error on %s. The current medium is probably not writable: ERR=%s.\n"),
- dev->print_name(), dev->errmsg);
- return VOL_NO_MEDIA;
+ /* Compare VolType to Device Type */
+ switch (dev_type) {
+ case B_FILE_DEV:
+ if (strcmp(VolHdr.Id, BaculaId) != 0) {
+ Mmsg(jcr->errmsg, _("Wrong Volume Type. Wanted a File or Tape Volume %s on device %s, but got: %s\n"),
+ VolHdr.VolumeName, print_name(), VolHdr.Id);
+ stat = VOL_TYPE_ERROR;
+ goto bail_out;