From 00f417f8f603277f239a48bbdef4647217f1804d Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 17 Oct 2005 23:15:05 +0000 Subject: [PATCH] Fix bug when recycling DVD devices (append flag was removed). git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2459 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/nb-1.37 | 4 +++- bacula/src/stored/dev.c | 1 + bacula/src/stored/dvd.c | 13 +++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bacula/nb-1.37 b/bacula/nb-1.37 index 291ed0d190..e879828837 100644 --- a/bacula/nb-1.37 +++ b/bacula/nb-1.37 @@ -4,10 +4,12 @@ General: Changes to 1.37.*: -16Oct05 +17Oct05 + - Fix bug when recycling DVD devices (append flag was removed). - Add tests for dvd+rw-format in configure script. - scripts/dvd-handler: Reformat DVD-RW when needed. This needs dvd+rw-format. - Add patch for dvd+rw-tools in patches dir (this should probably be elsewhere). +16Oct05 - Remove scripts/dvd-freespace and scripts/dvd-writepart, as they are now merged into scripts/dvd-handler. Note: Documentation needs to be updated. - scripts/dvd-handler: "zero" brand-new DVD+/-RW to fix a problem with some diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 14c3d39355..b01c670383 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -523,6 +523,7 @@ void DEVICE::open_dvd_device(DCR *dcr, int omode) if (!check_can_write_on_non_blank_dvd(dcr)) { Mmsg(errmsg, _("The media in the device %s is not empty, please blank it before writing anything to it.\n"), print_name()); Emsg0(M_FATAL, 0, errmsg); + unmount_dev(this, 1); /* Unmount the device, so the operator can change it. */ fd = -1; return; } diff --git a/bacula/src/stored/dvd.c b/bacula/src/stored/dvd.c index af5ca1318b..54ee866347 100644 --- a/bacula/src/stored/dvd.c +++ b/bacula/src/stored/dvd.c @@ -209,7 +209,7 @@ get_out: dev->set_mounted(mount); /* set/clear mounted flag */ free_pool_memory(results); - /* Do not check free space when unmounting (otherwise it will mount it again) */ + /* Do not check free space when unmounting */ if (mount) { update_free_space_dev(dev); } @@ -505,8 +505,8 @@ int dvd_open_first_part(DCR *dcr, int mode) { DEVICE *dev = dcr->dev; - Dmsg4(29, "Enter: ==== open_first_part dev=%s Vol=%s mode=%d num_parts=%d\n", dev->print_name(), - dev->VolCatInfo.VolCatName, dev->openmode, dev->num_parts); + Dmsg5(29, "Enter: ==== open_first_part dev=%s Vol=%s mode=%d num_parts=%d append=%d\n", dev->print_name(), + dev->VolCatInfo.VolCatName, dev->openmode, dev->num_parts, dev->can_append()); if (dev->fd >= 0) { close(dev->fd); @@ -519,11 +519,16 @@ int dvd_open_first_part(DCR *dcr, int mode) Dmsg2(50, "Call dev->open(vol=%s, mode=%d)\n", dcr->VolCatInfo.VolCatName, mode); + int append = dev->can_append(); if (dev->open(dcr, mode) < 0) { Dmsg0(50, "open dev() failed\n"); return -1; } - Dmsg1(50, "Leave open_first_part state=%s\n", dev->is_open()?"open":"not open"); + if (append && (dev->part == dev->num_parts)) { /* If needed, set the append flag back */ + dev->set_append(); + } + Dmsg2(50, "Leave open_first_part state=%s append=%d\n", dev->is_open()?"open":"not open", dev->can_append()); + return dev->fd; } -- 2.39.5