/*
- Bacula® - The Network Backup Solution
+ Bacula(R) - The Network Backup Solution
- Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2016 Kern Sibbald
- The main author of Bacula is Kern Sibbald, with contributions from many
- others, a complete list can be found in the file AUTHORS.
+ The original author of Bacula is Kern Sibbald, with contributions
+ from many others, a complete list can be found in the file AUTHORS.
You may use this file and others of this release according to the
license defined in the LICENSE file, which includes the Affero General
Public License, v3.0 ("AGPLv3") and some additional permissions and
terms pursuant to its AGPLv3 Section 7.
- Bacula® is a registered trademark of Kern Sibbald.
+ This notice must be preserved when any source code is
+ conveyed and/or propagated.
+
+ Bacula(R) is a registered trademark of Kern Sibbald.
*/
/*
*
rhl = RECHDR1_LENGTH;
}
- if (block_len > 4000000) {
- Dmsg3(20, "!!!Dump block %s 0x%x blocksize too big %u\n", msg, b, block_len);
+ if (block_len > 4000000 || block_len < BLKHDR_CS_LENGTH) {
+ Dmsg4(20, "!!!Dump block %s %p blocksize too %s %lu\n",
+ msg, b,
+ (block_len < BLKHDR_CS_LENGTH)?"small":"big",
+ block_len);
return;
}
*/
block->buf_len = len;
block->buf = get_memory(block->buf_len);
- block->rechdr_queue = get_memory(block->buf_len);
block->rechdr_items = 0;
empty_block(block);
block->BlockVer = BLOCK_VER; /* default write version */
*/
void free_block(DEV_BLOCK *block)
{
- if (block) {
+ if (block && block->buf) {
Dmsg1(999, "free_block buffer %x\n", block->buf);
free_memory(block->buf);
- free_memory(block->rechdr_queue);
Dmsg1(999, "free_block block %x\n", block);
free_memory((POOLMEM *)block);
}
unser_uint32(BlockNumber);
unser_bytes(Id, BLKHDR_ID_LENGTH);
ASSERT(unser_length(block->buf) == BLKHDR1_LENGTH);
-
Id[BLKHDR_ID_LENGTH] = 0;
+
if (Id[3] == '1') {
bhl = BLKHDR1_LENGTH;
block->BlockVer = 1;
Jmsg(dcr->jcr, M_FATAL, 0, "%s", dev->errmsg);
ok = false;
}
+ flush_jobmedia_queue(dcr->jcr);
dcr->block->write_failed = true;
if (dev->can_append() && !dev->weof(1)) { /* end the tape */
dev->VolCatInfo.VolCatErrors++;
Dmsg0(100, "Canceled\n");
return false;
}
- /* Create a jobmedia record for this job */
- if (!dir_create_jobmedia_record(dcr)) {
+ /* If we wrote on Volume create a last jobmedia record for this job */
+ if (dcr->VolFirstIndex && !dir_create_jobmedia_record(dcr)) {
dcr->dev->dev_errno = EIO;
Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
dcr->getVolCatName(), jcr->Job);
return false;
}
if (dcr->NewVol) {
+ flush_jobmedia_queue(jcr);
/* Note, setting a new volume also handles any pending new file */
set_new_volume_parameters(dcr);
} else {