- 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;
- }
-
- /*
- * If we can't guess the name, and we are writing,
- * just reopen the right file with open_first_part.
- */
- if (open_first_part(dev) < 0) {
- berrno be;
- Mmsg2(jcr->errmsg, _("open_first_part error on %s: ERR=%s.\n"),
- dev->print_name(), be.strerror());
- Dmsg0(100, "Leave read_dvd_volume_label VOL_IO_ERROR (!open_mounted_dev && !open_first_part)\n");
- return VOL_IO_ERROR;
- }
-
- Dmsg0(100, "Leave read_dvd_volume_label !open_mounted_dev\n");
- return read_dev_volume_label(dcr);
- } else {
- if (write && dcr->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;