From f381035a5bf45221ddeb67296c21c0a12e39a843 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 12 Oct 2005 10:02:04 +0000 Subject: [PATCH] - In block.c call dvd_write_part() to write last part rather than dvd_open_next_part(). - Prefix some DVD subroutines with dvd_ git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2433 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kes-1.37 | 4 ++++ bacula/src/stored/block.c | 8 ++++---- bacula/src/stored/dvd.c | 31 ++++++++++++++++--------------- bacula/src/stored/protos.h | 4 ++-- bacula/src/version.h | 4 ++-- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index f3ec1cbc2b..95efd7abf3 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,6 +4,10 @@ General: Changes to 1.37.41: +12Oct05 +- In block.c call dvd_write_part() to write last part rather + than dvd_open_next_part(). +- Prefix some DVD subroutines with dvd_ 11Oct05 - Add extra debug to Update media error for VolFiles decrease error. diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 1461f77714..566fcd8a89 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -693,8 +693,8 @@ static bool terminate_writing_volume(DCR *dcr) dev->VolCatInfo.VolCatFiles = dev->file; /* set number of files */ dev->VolCatInfo.VolCatJobs++; /* increment number of jobs */ - if (dev->is_dvd()) { /* Write the current (and last) part. */ - open_next_part(dcr); + if (dev->is_dvd()) { + dvd_write_part(dcr); /* write last part */ } if (!dir_update_volume_info(dcr, false)) { @@ -794,7 +794,7 @@ static bool do_dvd_size_checks(DCR *dcr) return false; } - if (open_next_part(dcr) < 0) { + if (dvd_open_next_part(dcr) < 0) { Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open device next part %s: ERR=%s\n"), dev->print_name(), strerror_dev(dev)); dev->dev_errno = EIO; @@ -904,7 +904,7 @@ reread: if ((dev->num_parts > 0) && ((dev->file_addr-dev->part_start) == dev->part_size) && (dev->part < dev->num_parts)) { - if (open_next_part(dcr) < 0) { + if (dvd_open_next_part(dcr) < 0) { Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open device next part %s: ERR=%s\n"), dev->print_name(), strerror_dev(dev)); dev->dev_errno = EIO; diff --git a/bacula/src/stored/dvd.c b/bacula/src/stored/dvd.c index 70c25c2940..000068524e 100644 --- a/bacula/src/stored/dvd.c +++ b/bacula/src/stored/dvd.c @@ -286,11 +286,12 @@ void update_free_space_dev(DEVICE* dev) /* * Write a part (Vol, Vol.1, ...) from the spool to the DVD - * This MUST only be called from open_next_part. Otherwise the part number - * is not updated. - * It is also called from truncate_dvd_dev to "blank" the medium. + * This routine does not update the part number, so normally, you + * should call open_next_part() + * It is also called from truncate_dvd_dev to "blank" the medium, as + * well as from block.c when the DVD is full to write the last part. */ -static bool dvd_write_part(DCR *dcr) +bool dvd_write_part(DCR *dcr) { DEVICE *dev = dcr->dev; POOL_MEM ocmd(PM_FNAME); @@ -338,7 +339,7 @@ static bool dvd_write_part(DCR *dcr) sm_check(__FILE__, __LINE__, false); } - /* growisofs umount the device, so remount it (it will update the free space) */ + /* growisofs umounted the device, so remount it (it will update the free space) */ dev->clear_mounted(); mount_dev(dev, 1); Jmsg(dcr->jcr, M_INFO, 0, _("Remaining free space %s on %s\n"), @@ -352,7 +353,7 @@ static bool dvd_write_part(DCR *dcr) * - Increment part number * - Reopen the device */ -int open_next_part(DCR *dcr) +int dvd_open_next_part(DCR *dcr) { DEVICE *dev = dcr->dev; @@ -459,7 +460,7 @@ int open_next_part(DCR *dcr) * - Close the fd * - Reopen the device */ -int open_first_part(DCR *dcr, int mode) +int dvd_open_first_part(DCR *dcr, int mode) { DEVICE *dev = dcr->dev; @@ -513,7 +514,7 @@ off_t lseek_dev(DEVICE *dev, off_t offset, int whence) } } else { /* Load next part, and start again */ - if (open_next_part(dcr) < 0) { + if (dvd_open_next_part(dcr) < 0) { Dmsg0(100, "lseek_dev failed while trying to open the next part\n"); return -1; } @@ -526,7 +527,7 @@ off_t lseek_dev(DEVICE *dev, off_t offset, int whence) * so just load the first one, and seek again * until the right one is loaded */ - if (open_first_part(dcr, dev->openmode) < 0) { + if (dvd_open_first_part(dcr, dev->openmode) < 0) { Dmsg0(100, "lseek_dev failed while trying to open the first part\n"); return -1; } @@ -580,19 +581,19 @@ off_t lseek_dev(DEVICE *dev, off_t offset, int whence) */ int modesave = dev->openmode; /* Works because num_parts > 0. */ - if (open_first_part(dcr, OPEN_READ_ONLY) < 0) { + if (dvd_open_first_part(dcr, OPEN_READ_ONLY) < 0) { Dmsg0(100, "lseek_dev failed while trying to open the first part\n"); return -1; } if (dev->num_parts > 0) { while (dev->part < (dev->num_parts-1)) { - if (open_next_part(dcr) < 0) { + if (dvd_open_next_part(dcr) < 0) { Dmsg0(100, "lseek_dev failed while trying to open the next part\n"); return -1; } } dev->openmode = modesave; - if (open_next_part(dcr) < 0) { + if (dvd_open_next_part(dcr) < 0) { Dmsg0(100, "lseek_dev failed while trying to open the next part\n"); return -1; } @@ -630,7 +631,7 @@ bool dvd_close_job(DCR *dcr) NB: No! If you call dvd_write_part, the part number is not updated. You must open the next part, it will automatically write the part and update the part number. */ - if (ok && (open_next_part(dcr) < 0)) { + if (ok && (dvd_open_next_part(dcr) < 0)) { Jmsg2(jcr, M_FATAL, 0, _("Unable to write part %s: ERR=%s\n"), dev->print_name(), strerror_dev(dev)); dev->dev_errno = EIO; @@ -653,7 +654,7 @@ bool truncate_dvd_dev(DCR *dcr) { Dmsg0(100, "truncate_dvd_dev: Opening first part (1)...\n"); dev->truncating = true; - if (open_first_part(dcr, OPEN_READ_WRITE) < 0) { + if (dvd_open_first_part(dcr, OPEN_READ_WRITE) < 0) { Dmsg0(100, "truncate_dvd_dev: Error while opening first part (1).\n"); dev->truncating = false; return false; @@ -681,7 +682,7 @@ bool truncate_dvd_dev(DCR *dcr) { return false; } - if (open_first_part(dcr, OPEN_READ_WRITE) < 0) { + if (dvd_open_first_part(dcr, OPEN_READ_WRITE) < 0) { Dmsg0(100, "truncate_dvd_dev: Error while opening first part (2).\n"); return false; } diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index 85443ad3be..1d0ff05c81 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -82,8 +82,6 @@ void display_tape_error_status(JCR *jcr, DEVICE *dev); /* From dev.c */ DEVICE *init_dev(JCR *jcr, DEVRES *device); off_t lseek_dev(DEVICE *dev, off_t offset, int whence); -int open_first_part(DCR *dcr, int mode); -int open_next_part(DCR *dcr); bool can_open_mounted_dev(DEVICE *dev); bool truncate_dev(DCR *dcr); void term_dev(DEVICE *dev); @@ -116,6 +114,8 @@ uint32_t dev_block(DEVICE *dev); uint32_t dev_file(DEVICE *dev); /* From dvd.c */ +int dvd_open_next_part(DCR *dcr); +bool dvd_write_part(DCR *dcr); bool dvd_close_job(DCR *dcr); bool mount_dev(DEVICE* dev, int timeout); bool unmount_dev(DEVICE* dev, int timeout); diff --git a/bacula/src/version.h b/bacula/src/version.h index ab50b34c8b..16719df25f 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "1.37.41" -#define BDATE "11 October 2005" -#define LSMDATE "11Oct05" +#define BDATE "12 October 2005" +#define LSMDATE "12Oct05" /* Debug flags */ #undef DEBUG -- 2.39.5