From: Nicolas Boichat Date: Fri, 29 Jul 2005 13:49:33 +0000 (+0000) Subject: DVD sanity check : check if the last part was removed or truncated, or X-Git-Tag: Release-1.38.0~235 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5a64ff0f08d18f00eb68a359a66a61817edf6c51;p=bacula%2Fbacula DVD sanity check : check if the last part was removed or truncated, or if a written part was overwritten. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2269 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/stored/device.c b/bacula/src/stored/device.c index 282c486354..3cd95bf32d 100644 --- a/bacula/src/stored/device.c +++ b/bacula/src/stored/device.c @@ -296,6 +296,8 @@ bool open_device(DCR *dcr) } if (dev->open(dcr, mode) < 0) { /* If polling, ignore the error */ + /* If DVD, also ignore the error, very often you cannot open the device + * (when there is no DVD, or when the one inserted is a wrong one) */ if ((!dev->poll) && (!dev->is_dvd())) { Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open device %s: ERR=%s\n"), dev->print_name(), strerror_dev(dev)); diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index bf71087cf5..cba07154d2 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -149,6 +149,8 @@ mount_next_vol: /* Ensure the device is open */ if (!open_device(dcr)) { + /* If DVD, ignore the error, very often you cannot open the device + * (when there is no DVD, or when the one inserted is a wrong one) */ if ((dev->poll) || (dev->is_dvd())) { goto mount_next_vol; } else { @@ -365,6 +367,29 @@ read_volume: if (!dir_update_volume_info(dcr, false)) { return false; } + + /* DVD sanity check : check if the last part was removed or truncated, or if + * a written part was overwritten. */ + /* We need to do it after dir_update_volume_info, so we have the EndBlock + * info. (nb: I don't understand why VolCatFiles is set (used to check + * tape file number), but not EndBlock) */ + /* Maybe could it be changed "dev->is_file()" (would remove the fixme above) */ + if (dev->is_dvd()) { + Dmsg2(100, "DVD/File sanity check addr=%u vs endblock=%u\n", (unsigned int)dev->file_addr, (unsigned int)dev->VolCatInfo.EndBlock); + if (dev->file_addr == dev->VolCatInfo.EndBlock+1) { + Jmsg(jcr, M_INFO, 0, _("Ready to append to end of Volume \"%s\" at file address=%u.\n"), + dcr->VolumeName, (unsigned int)dev->file_addr); + } + else { + Jmsg(jcr, M_ERROR, 0, _("I cannot write on Volume \"%s\" because:\n" + "The EOD file address is wrong: Volume file address=%u != Catalog Endblock=%u(+1)\n" + "You probably removed DVD last part in spool directory.\n"), + dcr->VolumeName, (unsigned int)dev->file_addr, (unsigned int)dev->VolCatInfo.EndBlock); + mark_volume_in_error(dcr); + goto mount_next_vol; + } + } + /* Return an empty block */ empty_block(block); /* we used it for reading so set for write */ }