* Version $Id$
*/
/*
- Copyright (C) 2004-2006 Kern Sibbald
+ Bacula® - The Network Backup Solution
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as amended with additional clauses defined in the
- file LICENSE in the main source directory.
+ Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- the file LICENSE for additional details.
+ The main author of Bacula is Kern Sibbald, with contributions from
+ many others, a complete list can be found in the file AUTHORS.
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version two of the GNU General Public
+ License as published by the Free Software Foundation plus additions
+ that are listed in the file LICENSE.
- */
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Bacula® is a registered trademark of John Walker.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+ Switzerland, email:ftf@fsfeurope.org.
+*/
#include "bacula.h"
#include "stored.h"
bool begin_data_spool(DCR *dcr)
{
bool stat = true;
- if (dcr->jcr->spool_data) {
+ if (!dcr->dev->is_dvd() && dcr->jcr->spool_data) {
Dmsg0(100, "Turning on data spooling\n");
dcr->spool_data = true;
stat = open_data_spool_file(dcr);
} else {
dir = working_directory;
}
- Mmsg(name, "%s/%s.data.%s.%s.spool", dir, my_name, dcr->jcr->Job,
- dcr->device->hdr.name);
+ Mmsg(name, "%s/%s.data.%u.%s.%s.spool", dir, my_name, dcr->jcr->JobId,
+ dcr->jcr->Job, dcr->device->hdr.name);
}
lseek(rdcr->spool_fd, 0, SEEK_SET); /* rewind */
/* Add run time, to get current wait time */
- time_t despool_start = time(NULL) + jcr->run_time;
+ time_t despool_start = time(NULL) - jcr->run_time;
for ( ; ok; ) {
if (job_canceled(jcr)) {
Jmsg(dcr->jcr, M_INFO, 0, _("Despooling elapsed time = %02d:%02d:%02d, Transfer rate = %s bytes/second\n"),
despool_elapsed / 3600, despool_elapsed % 3600 / 60, despool_elapsed % 60,
- edit_uint64_with_commas(jcr->dcr->job_spool_size / despool_elapsed, ec1));
+ edit_uint64_with_suffix(jcr->dcr->job_spool_size / despool_elapsed, ec1));
dcr->block = block; /* reset block */
free_pool_memory(rdev->errmsg);
/* Be careful to NULL the jcr and free rdev after free_dcr() */
rdcr->jcr = NULL;
+ rdcr->dev = NULL;
free_dcr(rdcr);
free(rdev);
- dcr->dev_locked = false;
dcr->spooling = true; /* turn on spooling again */
dcr->despooling = false;
- unlock_device(dcr->dev);
+ /* If doing a commit, leave the device locked -- unlocked in release_device() */
+ if (!commit) {
+ dcr->dev_locked = false;
+ unlock_device(dcr->dev);
+ }
return ok;
}
if (stat != (ssize_t)sizeof(hdr)) {
/* If we wrote something, truncate it, then despool */
if (stat != -1) {
- if (ftruncate(dcr->spool_fd, lseek(dcr->spool_fd, (off_t)0, SEEK_CUR) - stat) != 0) {
+#if defined(HAVE_WIN32)
+ boffset_t pos = _lseeki64(dcr->spool_fd, (__int64)0, SEEK_CUR);
+#else
+ boffset_t pos = lseek(dcr->spool_fd, (off_t)0, SEEK_CUR);
+#endif
+ if (ftruncate(dcr->spool_fd, pos - stat) != 0) {
berrno be;
Jmsg(dcr->jcr, M_FATAL, 0, _("Ftruncate spool file failed: ERR=%s\n"),
be.strerror());
* If we wrote something, truncate it and the header, then despool
*/
if (stat != -1) {
- if (ftruncate(dcr->spool_fd, lseek(dcr->spool_fd, (off_t)0, SEEK_CUR)
- - stat - sizeof(spool_hdr)) != 0) {
+#if defined(HAVE_WIN32)
+ boffset_t pos = _lseeki64(dcr->spool_fd, (__int64)0, SEEK_CUR);
+#else
+ boffset_t pos = lseek(dcr->spool_fd, (off_t)0, SEEK_CUR);
+#endif
+ if (ftruncate(dcr->spool_fd, pos - stat - sizeof(spool_hdr)) != 0) {
berrno be;
Jmsg(dcr->jcr, M_FATAL, 0, _("Ftruncate spool file failed: ERR=%s\n"),
be.strerror());