From: Kern Sibbald Date: Wed, 29 Jun 2005 20:52:24 +0000 (+0000) Subject: - Detect device mounted for DVD and suppress be sure to X-Git-Tag: Release-7.0.0~8662 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f60f6d168d052c9334f6f4aedec3c71f4ba1055e;p=bacula%2Fbacula - Detect device mounted for DVD and suppress be sure to mount message after label. - Set Cleaning tape status to "Cleaning" and force no MediaType. - Get DVD writing working with new standard Bacula open() code. - Rename get_filename() to make more sense. - Detect "is already mounted on" on mount command so to avoid error if device is already mounted. - Eliminated guess_name() code. It may be necessary to add it back later. - Eliminate seg fault from printing invalid results. - Make dvd_write_part() bool. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2169 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index 5afe0f8e15..9bdca22393 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,6 +4,21 @@ General: Changes to 1.37.28: +30Jun05 +- Detect device mounted for DVD and suppress be sure to + mount message after label. +- Set Cleaning tape status to "Cleaning" and force no + MediaType. +- Get DVD writing working with new standard Bacula open() + code. +- Rename get_filename() to make more sense. +- Detect "is already mounted on" on mount command so to avoid + error if device is already mounted. +- Eliminated guess_name() code. It may be necessary to + add it back later. +- Eliminate seg fault from printing invalid results. +- Make dvd_write_part() bool. + 29Jun05 - Attempt to fix DVD writing by eliminating a number of the DVD subroutines to simplify. diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index e710da0c7c..da0054a921 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -419,10 +419,12 @@ checkName: /* Here we can get * 3001 OK mount. Device=xxx or * 3001 Mounted Volume vvvv + * 3002 Device "DVD-Writer" (/dev/hdc) is mounted. * 3906 is cannot mount non-tape * So for those, no need to print a reminder */ if (strncmp(sd->msg, "3001 ", 5) == 0 || + strncmp(sd->msg, "3002 ", 5) == 0 || strncmp(sd->msg, "3906 ", 5) == 0) { print_reminder = false; } @@ -521,11 +523,15 @@ static void label_from_barcodes(UAContext *ua) if (is_cleaning_tape(ua, &mr, &pr)) { if (media_record_exists) { /* we update it */ mr.VolBytes = 1; + bstrncpy(mr.VolStatus, "Cleaning", sizeof(mr.VolStatus)); + mr.MediaType[0] = 0; if (!db_update_media_record(ua->jcr, ua->db, &mr)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } } else { /* create the media record */ set_pool_dbr_defaults_in_media_dbr(&mr, &pr); + bstrncpy(mr.VolStatus, "Cleaning", sizeof(mr.VolStatus)); + mr.MediaType[0] = 0; if (db_create_media_record(ua->jcr, ua->db, &mr)) { bsendmsg(ua, _("Catalog record for cleaning tape \"%s\" successfully created.\n"), mr.VolumeName); diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 7268ab7aaf..d5d753debd 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -92,7 +92,7 @@ void free_dcr(DCR *dcr) if (dcr->reserved_device) { lock_device(dev); dev->reserved_device--; - Dmsg1(200, "=========== Dec reserve=%d\n", dev->reserved_device); + Dmsg1(200, "Dec reserve=%d\n", dev->reserved_device); dcr->reserved_device = false; if (dev->num_writers < 0) { Jmsg1(dcr->jcr, M_ERROR, 0, _("Hey! num_writers=%d!!!!\n"), dev->num_writers); @@ -314,7 +314,7 @@ DCR *acquire_device_for_append(DCR *dcr) if (dcr->reserved_device) { dev->reserved_device--; - Dmsg1(200, "============ Dec reserve=%d\n", dev->reserved_device); + Dmsg1(200, "Dec reserve=%d\n", dev->reserved_device); dcr->reserved_device = false; } @@ -423,7 +423,7 @@ bool release_device(DCR *dcr) /* if device is reserved, job never started, so release the reserve here */ if (dcr->reserved_device) { dev->reserved_device--; - Dmsg1(200, "========= Dec reserve=%d\n", dev->reserved_device); + Dmsg1(200, "Dec reserve=%d\n", dev->reserved_device); dcr->reserved_device = false; } diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 3e97f73c7d..56b7bd54f6 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -182,7 +182,7 @@ void ser_block_header(DEV_BLOCK *block) uint32_t CheckSum = 0; uint32_t block_len = block->binbuf; - Dmsg1(390, "ser_block_header: block_len=%d\n", block_len); + Dmsg1(1390, "ser_block_header: block_len=%d\n", block_len); ser_begin(block->buf, BLKHDR2_LENGTH); ser_uint32(CheckSum); ser_uint32(block_len); @@ -196,7 +196,7 @@ void ser_block_header(DEV_BLOCK *block) /* Checksum whole block except for the checksum */ CheckSum = bcrc32((uint8_t *)block->buf+BLKHDR_CS_LENGTH, block_len-BLKHDR_CS_LENGTH); - Dmsg1(390, "ser_bloc_header: checksum=%x\n", CheckSum); + Dmsg1(1390, "ser_bloc_header: checksum=%x\n", CheckSum); ser_begin(block->buf, BLKHDR2_LENGTH); ser_uint32(CheckSum); /* now add checksum to block header */ } @@ -500,7 +500,7 @@ bool write_block_to_dev(DCR *dcr) } dev->VolCatInfo.VolCatWrites++; - Dmsg1(300, "Write block of %u bytes\n", wlen); + Dmsg1(1300, "Write block of %u bytes\n", wlen); #ifdef DEBUG_BLOCK_ZEROING uint32_t *bp = (uint32_t *)block->buf; if (bp[0] == 0 && bp[1] == 0 && bp[2] == 0 && block->buf[12] == 0) { @@ -586,7 +586,7 @@ bool write_block_to_dev(DCR *dcr) dev->file_size += wlen; dev->part_size += wlen; - Dmsg2(300, "write_block: wrote block %d bytes=%d\n", dev->block_num, wlen); + Dmsg2(1300, "write_block: wrote block %d bytes=%d\n", dev->block_num, wlen); empty_block(block); return true; } diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index b084a94541..1958574770 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -446,7 +446,7 @@ static void open_file_device(DCR *dcr, int mode) } /* - * Open a DVD device. N.B. at this point, dev->VolCatInfo.VolCatName + * Open a DVD device. N.B. at this point, dcr->VolCatInfo.VolCatName * has the desired Volume name, but there is NO assurance that * any other field of VolCatInfo is correct. */ @@ -457,7 +457,7 @@ static void open_dvd_device(DCR *dcr, int mode) struct stat filestat; /* - * Handle opening of File Archive (not a tape) + * Handle opening of DVD Volume */ Dmsg3(29, "Enter: open_file_dev: %s dev=%s mode=%d\n", dev->is_dvd()?"DVD":"disk", archive_name.c_str(), mode); @@ -474,8 +474,6 @@ static void open_dvd_device(DCR *dcr, int mode) } dev->part_size = 0; - Dmsg1(100, "Call make_dvd_filename. Vol=%s\n", dev->VolCatInfo.VolCatName); - make_dvd_filename(dev, archive_name); if (mount_dev(dev, 1) < 0) { Mmsg(dev->errmsg, _("Could not mount device %s.\n"), @@ -496,8 +494,19 @@ static void open_dvd_device(DCR *dcr, int mode) if (dev->part < dev->num_parts) { mode = OPEN_READ_ONLY; } - dev->set_mode(mode); + + Dmsg1(100, "Call make_dvd_filename. Vol=%s\n", dev->VolCatInfo.VolCatName); + /* + * If we are opening it read-only, it is *probably* on the + * DVD, so try the DVD first, otherwise look in the spool dir. + */ + if (mode == OPEN_READ_ONLY) { + make_mounted_dvd_filename(dev, archive_name); + } else { + make_spooled_dvd_filename(dev, archive_name); + } + /* If creating file, give 0640 permissions */ Dmsg3(29, "mode=%d open(%s, 0x%x, 0640)\n", mode, archive_name.c_str(), dev->mode); if ((dev->fd = open(archive_name.c_str(), dev->mode, 0640)) < 0) { @@ -506,7 +515,12 @@ static void open_dvd_device(DCR *dcr, int mode) Mmsg2(dev->errmsg, _("Could not open: %s, ERR=%s\n"), archive_name.c_str(), be.strerror()); Dmsg1(29, "open failed: %s", dev->errmsg); - } else { + if (mode == OPEN_READ_ONLY) { + make_spooled_dvd_filename(dev, archive_name); + dev->fd = open(archive_name.c_str(), dev->mode, 0640); /* try on spool */ + } + } + if (dev->fd >= 0) { /* Get size of file */ if (fstat(dev->fd, &filestat) < 0) { berrno be; @@ -1589,7 +1603,7 @@ static void do_close(DEVICE *dev) POOL_MEM archive_name(PM_FNAME); dev->part = dev->num_parts; Dmsg1(100, "Call make_dvd_filename. Vol=%s\n", dev->VolCatInfo.VolCatName); - make_dvd_filename(dev, archive_name); + make_spooled_dvd_filename(dev, archive_name); /* Check that the part file is empty */ if ((stat(archive_name.c_str(), &statp) == 0) && (statp.st_size == 0)) { Dmsg1(100, "unlink(%s)\n", archive_name.c_str()); diff --git a/bacula/src/stored/dvd.c b/bacula/src/stored/dvd.c index c5ee187d9b..c60cb5f878 100644 --- a/bacula/src/stored/dvd.c +++ b/bacula/src/stored/dvd.c @@ -28,32 +28,32 @@ /* Forward referenced functions */ static char *edit_device_codes_dev(DEVICE *dev, char *omsg, const char *imsg); static bool do_mount_dev(DEVICE* dev, int mount, int dotimeout); -static int dvd_write_part(DEVICE *dev); +static bool dvd_write_part(DEVICE *dev); +static void add_file_and_part_name(DEVICE *dev, POOL_MEM &archive_name); /* * Write the current volume/part filename to archive_name. */ -void make_dvd_filename(DEVICE *dev, POOL_MEM &archive_name) +void make_mounted_dvd_filename(DEVICE *dev, POOL_MEM &archive_name) { - char partnumber[20]; - - /* - * If we try to open the last part, just open it from disk, - * otherwise, open it from the spooling directory. - */ - Dmsg2(100, "DVD part=%d num_parts=%d\n", dev->part, dev->num_parts); - if (dev->part < dev->num_parts) { - Dmsg1(100, "Arch = mount point: %s\n", dev->device->mount_point); - pm_strcpy(archive_name, dev->device->mount_point); + pm_strcpy(archive_name, dev->device->mount_point); + add_file_and_part_name(dev, archive_name); +} + +void make_spooled_dvd_filename(DEVICE *dev, POOL_MEM &archive_name) +{ + /* Use the working directory if spool directory is not defined */ + if (dev->device->spool_directory) { + pm_strcpy(archive_name, dev->device->spool_directory); } else { - /* Use the working directory if spool directory is not defined */ - if (dev->device->spool_directory) { - pm_strcpy(archive_name, dev->device->spool_directory); - } else { - pm_strcpy(archive_name, working_directory); - } + pm_strcpy(archive_name, working_directory); } - + add_file_and_part_name(dev, archive_name); +} + +static void add_file_and_part_name(DEVICE *dev, POOL_MEM &archive_name) +{ + char partnumber[20]; if (archive_name.c_str()[strlen(archive_name.c_str())-1] != '/') { pm_strcat(archive_name, "/"); } @@ -100,18 +100,18 @@ bool unmount_dev(DEVICE *dev, int timeout) static bool do_mount_dev(DEVICE* dev, int mount, int dotimeout) { POOL_MEM ocmd(PM_FNAME); - POOLMEM* results; - char* icmd; + POOLMEM *results; + char *icmd; int status, timeout; if (mount) { if (dev->is_mounted()) { - goto get_out; + return true; } icmd = dev->device->mount_command; } else { if (!dev->is_mounted()) { - goto get_out; + return true; } icmd = dev->device->unmount_command; } @@ -127,15 +127,18 @@ static bool do_mount_dev(DEVICE* dev, int mount, int dotimeout) timeout = 0; } results = get_pool_memory(PM_MESSAGE); + results[0] = 0; /* If busy retry each second */ while ((status = run_program_full_output(ocmd.c_str(), dev->max_open_wait/2, results)) != 0) { + if (fnmatch("*is already mounted on", results, 0) == 0) { + break; + } if (timeout-- > 0) { - Dmsg2(400, "Device %s cannot be (un)mounted. Retrying... ERR=%s\n", dev->dev_name, results); /* Sometimes the device cannot be mounted because it is already mounted. * Try to unmount it, then remount it */ if (mount) { - Dmsg1(400, "Trying to unmount the device %s...\n", dev->dev_name); + Dmsg1(400, "Trying to unmount the device %s...\n", dev->print_name()); do_mount_dev(dev, 0, 0); } bmicrosleep(1, 0); @@ -150,187 +153,8 @@ static bool do_mount_dev(DEVICE* dev, int mount, int dotimeout) dev->set_mounted(mount); /* set/clear mounted flag */ free_pool_memory(results); - -get_out: - Dmsg1(29, "Exit do_mount_dev: mounted=%d\n", !!dev->is_mounted()); - return true; -} - -/* Only for devices that require a mount -- currently DVDs only - * - * Try to find the Volume name of the loaded device. - * - * Returns true if read_dev_volume_label can now read the label, - * NOTE!!! at this point the device may not be - * opened. - * Maybe it should open the first part. ***FIXME*** - * - * false if an error occured, and read_dev_volume_label - * must abort with an IO_ERROR. - * - * To find the Volume name, it lists all the files on the DVD, - * and searches for a file which has a minimum size (500 bytes). - * If this file has a numeric extension, like part files, try to - * open the file which has no extension (e.g. the first part - * file). - * - * So, if the DVD does not contains a Bacula volume, a random file is opened, - * and no valid label could be read from this file. - * - * It is useful, so the operator can be told that a wrong volume is mounted, with - * the label name of the current volume. We can also check that the currently - * mounted disk is writable. (See also read_dev_volume_label_guess in label.c). - - If we are writing, then there is no need to guess. We should just - check that the Volume does not already exist. - - If we are reading, I don't see the reason to guess since we - know what Volume we want. The file either exists or does not - exist. - - * - */ -#ifdef xxx -bool can_open_mounted_dev(DEVICE *dev) -{ - Dmsg1(29, "Enter: dev=%s\n", dev->dev_name); - POOL_MEM guessedname(PM_FNAME); - DIR* dp; - struct dirent *entry, *result; - struct stat statp; - int index; - int name_max; - - if (!dev->is_dvd()) { - Dmsg1(100, "device does not require mount, returning 0. dev=%s\n", dev->dev_name); - return true; - } - -#ifndef HAVE_DIRENT_H - Dmsg0(29, "readdir not available, cannot guess volume name\n"); - return true; -#endif - - update_free_space_dev(dev); - - if (mount_dev(dev, 1) < 0) { - /* If the device cannot be mounted, check if it is writable */ - if (dev->have_media()) { - Dmsg1(100, "device cannot be mounted, but it seems to be writable, returning 0. dev=%s\n", dev->dev_name); - return true; - } else { - Dmsg1(100, "device cannot be mounted, and is not writable, returning -1. dev=%s\n", dev->dev_name); - return false; - } - } - - name_max = pathconf(".", _PC_NAME_MAX); - if (name_max < 1024) { - name_max = 1024; - } - - if (!(dp = opendir(dev->device->mount_point))) { - berrno be; - dev->dev_errno = errno; - Dmsg3(29, "failed to open dir %s (dev=%s), ERR=%s\n", dev->device->mount_point, dev->dev_name, be.strerror()); - return false; - } - - entry = (struct dirent *)malloc(sizeof(struct dirent) + name_max + 100); - while (1) { - if ((readdir_r(dp, entry, &result) != 0) || (result == NULL)) { - dev->dev_errno = ENOENT; - Dmsg2(29, "failed to find suitable file in dir %s (dev=%s)\n", dev->device->mount_point, dev->dev_name); - closedir(dp); - free(entry); - return false; - } - - ASSERT(name_max+1 > (int)sizeof(struct dirent) + (int)NAMELEN(entry)); - - if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) { - continue; - } - - pm_strcpy(guessedname, dev->device->mount_point); - if (guessedname.c_str()[strlen(guessedname.c_str())-1] != '/') { - pm_strcat(guessedname, "/"); - } - pm_strcat(guessedname, entry->d_name); - - if (stat(guessedname.c_str(), &statp) < 0) { - berrno be; - Dmsg3(29, "failed to stat %s (dev=%s), ERR=%s\n", - guessedname.c_str(), dev->dev_name, be.strerror()); - continue; - } - - if (!S_ISREG(statp.st_mode) || (statp.st_size < 500)) { - Dmsg2(100, "%s is not a regular file, or less than 500 bytes (dev=%s)\n", - guessedname.c_str(), dev->dev_name); - continue; - } - - /* Ok, we found a good file, remove the part extension if possible. */ - for (index = strlen(guessedname.c_str())-1; index >= 0; index--) { - if ((guessedname.c_str()[index] == '/') || - (guessedname.c_str()[index] < '0') || - (guessedname.c_str()[index] > '9')) { - break; - } - if (guessedname.c_str()[index] == '.') { - guessedname.c_str()[index] = '\0'; - break; - } - } - - if ((stat(guessedname.c_str(), &statp) < 0) || (statp.st_size < 500)) { - /* The file with extension truncated does not exists or is too small, so use it with its extension. */ - berrno be; - Dmsg3(100, "failed to stat %s (dev=%s), using the file with its extension, ERR=%s\n", - guessedname.c_str(), dev->dev_name, be.strerror()); - pm_strcpy(guessedname, dev->device->mount_point); - if (guessedname.c_str()[strlen(guessedname.c_str())-1] != '/') { - pm_strcat(guessedname, "/"); - } - pm_strcat(guessedname, entry->d_name); - continue; - } - break; - } - closedir(dp); - free(entry); - - if (dev->fd >= 0) { - close(dev->fd); - } - - Dmsg1(100, "open(%s) read-only\n", guessedname.c_str()); - if ((dev->fd = open(guessedname.c_str(), O_RDONLY | O_BINARY)) < 0) { - berrno be; - dev->dev_errno = errno; - Dmsg3(29, "failed to open %s (dev=%s), ERR=%s\n", - guessedname.c_str(), dev->dev_name, be.strerror()); - Dmsg0(100, "Call open_first_part\n"); - if (open_first_part(dev, OPEN_READ_ONLY) < 0) { - berrno be; - dev->dev_errno = errno; - Mmsg1(&dev->errmsg, _("Could not open_first_part, ERR=%s\n"), be.strerror()); - Emsg0(M_FATAL, 0, dev->errmsg); - } - return false; - } - dev->part_start = 0; - dev->part_size = statp.st_size; - dev->part = 0; - dev->set_opened(); - dev->use_count = 1; - Dmsg2(29, "Exit: %s opened (dev=%s)\n", guessedname.c_str(), dev->dev_name); - return true; } -#endif - /* Update the free space on the device */ void update_free_space_dev(DEVICE* dev) @@ -357,6 +181,7 @@ void update_free_space_dev(DEVICE* dev) Dmsg1(29, "update_free_space_dev: cmd=%s\n", ocmd.c_str()); results = get_pool_memory(PM_MESSAGE); + results[0] = 0; /* Try at most 3 times to get the free space on the device. This should perhaps be configurable. */ timeout = 3; @@ -400,7 +225,7 @@ void update_free_space_dev(DEVICE* dev) return; } -static int dvd_write_part(DEVICE *dev) +static bool dvd_write_part(DEVICE *dev) { Dmsg1(29, "dvd_write_part: device is %s\n", dev->dev_name); @@ -410,11 +235,12 @@ static int dvd_write_part(DEVICE *dev) POOL_MEM ocmd(PM_FNAME); POOLMEM *results; - results = get_pool_memory(PM_MESSAGE); char* icmd; int status; int timeout; + results = get_pool_memory(PM_MESSAGE); + results[0] = 0; icmd = dev->device->write_part_command; edit_device_codes_dev(dev, ocmd.c_str(), icmd); @@ -433,16 +259,15 @@ static int dvd_write_part(DEVICE *dev) Dmsg1(000, "%s", dev->errmsg); dev->dev_errno = EIO; free_pool_memory(results); - return -1; - } else { - Dmsg1(10, "dvd_write_part: command output=%s\n", results); - POOL_MEM archive_name(PM_FNAME); - Dmsg1(100, "Call get_filename. Vol=%s\n", dev->VolCatInfo.VolCatName); - make_dvd_filename(dev, archive_name); - unlink(archive_name.c_str()); - free_pool_memory(results); - return 0; + return false; } + + POOL_MEM archive_name(PM_FNAME); + /* Delete spool file */ + make_spooled_dvd_filename(dev, archive_name); + unlink(archive_name.c_str()); + free_pool_memory(results); + return true; } /* Open the next part file. @@ -454,7 +279,8 @@ int open_next_part(DCR *dcr) { DEVICE *dev = dcr->dev; - Dmsg3(29, "Enter: open_next_part %s %s %d\n", dev->dev_name, + Dmsg5(29, "Enter: open_next_part part=%d npart=%d dev=%s vol=%s mode=%d\n", + dev->part, dev->num_parts, dev->print_name(), dev->VolCatInfo.VolCatName, dev->openmode); /* When appending, do not open a new part if the current is empty */ if (dev->can_append() && (dev->part == dev->num_parts) && @@ -475,7 +301,7 @@ int open_next_part(DCR *dcr) * DVD before opening the next part. */ if (dev->is_dvd() && (dev->part == dev->num_parts) && dev->can_append()) { - if (dvd_write_part(dev) < 0) { + if (!dvd_write_part(dev)) { return -1; } } @@ -483,6 +309,7 @@ int open_next_part(DCR *dcr) dev->part_start += dev->part_size; dev->part++; + Dmsg2(29, "part=%d num_parts=%d\n", dev->part, dev->num_parts); if ((dev->num_parts < dev->part) && dev->can_append()) { POOL_MEM archive_name(PM_FNAME); struct stat buf; @@ -491,16 +318,16 @@ int open_next_part(DCR *dcr) * First check what is on DVD. If out part is there, we * are in trouble, so bail out. */ - make_dvd_filename(dev, archive_name); /* makes dvd name */ + make_mounted_dvd_filename(dev, archive_name); /* makes dvd name */ if (stat(archive_name.c_str(), &buf) == 0) { - /* bad new bail out */ + /* bad news bail out */ Mmsg1(&dev->errmsg, _("Next Volume part already exists on DVD. Cannot continue: %s\n"), archive_name.c_str()); return -1; } dev->num_parts = dev->part; - make_dvd_filename(dev, archive_name); /* makes spool name */ + make_spooled_dvd_filename(dev, archive_name); /* makes spool name */ /* Check if the next part exists in spool directory . */ if ((stat(archive_name.c_str(), &buf) == 0) || (errno != ENOENT)) { @@ -568,7 +395,7 @@ off_t lseek_dev(DEVICE *dev, off_t offset, int whence) dcr = (DCR *)dev->attached_dcrs->first(); /* any dcr will do */ switch(whence) { case SEEK_SET: - Dmsg1(100, "lseek_dev SEEK_SET called %d\n", offset); + Dmsg1(100, "lseek_dev SEEK_SET to %d\n", (int)offset); if ((uint64_t)offset >= dev->part_start) { if ((uint64_t)(offset - dev->part_start) < dev->part_size) { /* We are staying in the current part, just seek */ @@ -598,22 +425,21 @@ off_t lseek_dev(DEVICE *dev, off_t offset, int whence) } break; case SEEK_CUR: - Dmsg1(100, "lseek_dev SEEK_CUR called %d\n", offset); + Dmsg1(100, "lseek_dev SEEK_CUR to %d\n", (int)offset); if ((pos = lseek(dev->fd, (off_t)0, SEEK_CUR)) < 0) { return pos; } pos += dev->part_start; if (offset == 0) { return pos; - } - else { /* Not used in Bacula, but should work */ + } else { /* Not used in Bacula, but should work */ return lseek_dev(dev, pos, SEEK_SET); } break; case SEEK_END: - Dmsg1(100, "lseek_dev SEEK_END called %d\n", offset); + Dmsg1(100, "lseek_dev SEEK_END to %d\n", (int)offset); if (offset > 0) { /* Not used by bacula */ - Dmsg1(100, "lseek_dev SEEK_END called with an invalid offset %d\n", offset); + Dmsg1(100, "lseek_dev SEEK_END called with an invalid offset %d\n", (int)offset); errno = EINVAL; return -1; } @@ -680,7 +506,6 @@ bool dvd_close_job(DCR *dcr) dev->dev_errno = EIO; ok = false; } - dev->VolCatInfo.VolCatParts = dev->num_parts; } return ok; @@ -725,7 +550,7 @@ static char *edit_device_codes_dev(DEVICE* dev, char *omsg, const char *imsg) str = dev->device->mount_point; break; case 'v': - make_dvd_filename(dev, archive_name); + make_spooled_dvd_filename(dev, archive_name); str = archive_name.c_str(); break; default: @@ -740,9 +565,9 @@ static char *edit_device_codes_dev(DEVICE* dev, char *omsg, const char *imsg) add[1] = 0; str = add; } - Dmsg1(900, "add_str %s\n", str); + Dmsg1(1900, "add_str %s\n", str); pm_strcat(&omsg, (char *)str); - Dmsg1(800, "omsg=%s\n", omsg); + Dmsg1(1800, "omsg=%s\n", omsg); } return omsg; } diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index 67b748f498..b7a101b3ec 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -146,25 +146,12 @@ mount_next_vol: } /* Ensure the device is open */ - /* If we have a dvd that requires mount, we first want to guess - * which Volume is loaded, so we continue (if the wrong device is - * loaded, open_device just below would fail. - */ - if (!dev->is_dvd()) { - if (!open_device(dcr)) { - if (dev->poll) { - goto mount_next_vol; - } else { - return false; - } + if (!open_device(dcr)) { + if (dev->poll) { + goto mount_next_vol; + } else { + return false; } - } else { - /* - * Just copy the VolCatName in the device resource - * (usually done by open_dev). - * It is necessary so we can open the real files later. - */ - bstrncpy(dev->VolCatInfo.VolCatName, dcr->VolCatInfo.VolCatName, sizeof(dev->VolCatInfo.VolCatName)); } /* diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index 618ae64cb7..e08d3833dd 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -118,7 +118,8 @@ bool dvd_close_job(DCR *dcr); bool mount_dev(DEVICE* dev, int timeout); bool unmount_dev(DEVICE* dev, int timeout); void update_free_space_dev(DEVICE *dev); -void make_dvd_filename(DEVICE *dev, POOL_MEM &archive_name); +void make_mounted_dvd_filename(DEVICE *dev, POOL_MEM &archive_name); +void make_spooled_dvd_filename(DEVICE *dev, POOL_MEM &archive_name); /* From device.c */ bool open_device(DCR *dcr); diff --git a/bacula/src/stored/read.c b/bacula/src/stored/read.c index a02c70d757..724e560831 100644 --- a/bacula/src/stored/read.c +++ b/bacula/src/stored/read.c @@ -99,19 +99,19 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) if (rec->FileIndex < 0) { return true; } - Dmsg5(100, "Send to FD: SessId=%u SessTim=%u FI=%d Strm=%d, len=%d\n", + Dmsg5(400, "Send to FD: SessId=%u SessTim=%u FI=%d Strm=%d, len=%d\n", rec->VolSessionId, rec->VolSessionTime, rec->FileIndex, rec->Stream, rec->data_len); /* Send record header to File daemon */ if (!bnet_fsend(fd, rec_header, rec->VolSessionId, rec->VolSessionTime, rec->FileIndex, rec->Stream, rec->data_len)) { - Dmsg1(30, ">filed: Error Hdr=%s\n", fd->msg); + Pmsg1(000, ">filed: Error Hdr=%s\n", fd->msg); Jmsg1(jcr, M_FATAL, 0, _("Error sending to File daemon. ERR=%s\n"), bnet_strerror(fd)); return false; } else { - Dmsg1(31, ">filed: Hdr=%s\n", fd->msg); + Dmsg1(400, ">filed: Hdr=%s\n", fd->msg); } @@ -119,7 +119,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) save_msg = fd->msg; /* save fd message pointer */ fd->msg = rec->data; /* pass data directly to bnet_send */ fd->msglen = rec->data_len; - Dmsg1(31, ">filed: send %d bytes data.\n", fd->msglen); + Dmsg1(400, ">filed: send %d bytes data.\n", fd->msglen); if (!bnet_send(fd)) { Pmsg1(000, "Error sending to FD. ERR=%s\n", bnet_strerror(fd)); Jmsg1(jcr, M_FATAL, 0, _("Error sending to File daemon. ERR=%s\n"), diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index e48b9817f3..f6b17003d9 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -604,7 +604,7 @@ static bool reserve_device_for_append(DCR *dcr, bool PreferMountedVols) } dev->reserved_device++; - Dmsg1(200, "============= Inc reserve=%d\n", dev->reserved_device); + Dmsg1(200, "Inc reserve=%d\n", dev->reserved_device); dcr->reserved_device = true; ok = true; diff --git a/bacula/src/version.h b/bacula/src/version.h index 0ca77f7e05..c1659c1084 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.28" -#define BDATE "29 June 2005" -#define LSMDATE "29Jun05" +#define BDATE "30 June 2005" +#define LSMDATE "30Jun05" /* Debug flags */ #undef DEBUG