Hello,

I've created a patch, which is attached to this email, which does
*essentially* the same thing as the patch that was previously proposed,
except that it does a bit more of the necessary bookkeeping.  I have not
tested the patch, but would appreciate it if someone would apply it
(without the previous patch) and tell me if it works.  If it does bypass
the error conditions you saw without the previous patch, it stands a
better chance of maintaining the catalog in a correct state.



>> I haven't checked this, but the latest release announcement doesn't
>> mention such fix, so it probably didn't. If the patch works for you,
>> then let Bacula developers know about that to encourage them to apply
>> the patch or, at least, comment it.
>>
>> Greets,
>>         Jacek
>>
> WOW! Thanks for the patch. This is the first time after many failures that
> I have
> been able to get more than one successful backup to DVDs with bacula
> without
> blanking the media and starting over... :-)
>
> Attached is the patch along with a gentoo ebuild for 1.38.9 that applies
> this patch.
>
> John


Best regards, Kern
This patch should allow appending to DVDs in some situations.
It does so by bypassing rewriting the PRE_LABEL, which is not
really an ideal situation, but at least it should prevent errors.

Apply it to Bacula version 1.38.9 (and possibly some earlier versions)
with:

  cd <bacula-source>
  patch -p0 <1.38.9-dvd.patch
  make
  make install
  ...


Index: src/stored/label.c
===================================================================
RCS file: /cvsroot/bacula/bacula/src/stored/label.c,v
retrieving revision 1.87.2.3
diff -u -r1.87.2.3 label.c
--- src/stored/label.c	22 Dec 2005 21:35:25 -0000	1.87.2.3
+++ src/stored/label.c	26 May 2006 09:56:48 -0000
@@ -377,16 +377,26 @@
 {
    DEVICE *dev = dcr->dev;
    JCR *jcr = dcr->jcr;
+   bool can_write = true;
 
    if (dev->open(dcr, OPEN_READ_WRITE) < 0) {
-      return false;
+      /* If device is DVD, attempt to create it */
+      if (!dev->is_dvd()) {
+         return false;
+      }
+      if (dev->open(dcr, CREATE_READ_WRITE) < 0) {
+         /* We forge on for a DVD but don't do any writing */
+         can_write = false;
+      }
    }
    Dmsg2(190, "set append found freshly labeled volume. fd=%d dev=%x\n", dev->fd, dev);
    dev->VolHdr.LabelType = VOL_LABEL; /* set Volume label */
    dev->set_append();
-   if (!write_volume_label_to_block(dcr)) {
-      Dmsg0(200, "Error from write volume label.\n");
-      return false;
+   if (can_write) {
+      if (!write_volume_label_to_block(dcr)) {
+         Dmsg0(200, "Error from write volume label.\n");
+         return false;
+      }
    }
    /*
     * If we are not dealing with a streaming device,
@@ -395,7 +405,7 @@
     * We do not write the block now if this is an ANSI label. This
     *  avoids re-writing the ANSI label, which we do not want to do.
     */
-   if (!dev_cap(dev, CAP_STREAM)) {
+   if (can_write && !dev_cap(dev, CAP_STREAM)) {
       if (!dev->rewind(dcr)) {
          Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s: ERR=%s\n"),
                dev->print_name(), strerror_dev(dev));

Reply via email to