- Release Notes for Bacula 1.34.4
+ Release Notes for Bacula 1.34.5
Bacula code: Total files = 364 Total lines = 103,481 (*.h *.c *.in)
+Changes for 1.34.5:
+Major Changes:
+- Correct socket close on Win32 in bnet.c (in addition to compat.cpp).
+ Caused fd leak in Win32 for each connection.
+- Fix a number of places in query.sql where multiple JobIds are
+ printed (due to JobMedia records).
+- Abort configure if Internal is selected as the database.
+- Close socket in SD when connection rejected. Caused fd leaks.
+
+Items to note!!!!
+- If you are upgrading from 1.32, please be sure to see the database
+ upgrade procedure under the 1.34.0 notes.
+
+Other Items:
+- Fixed Gnome crash on up/down arrow with no history.
+- Fixed btape "fill" crash with multiple tape option.
+- Add new query: List jobs on Volume given Volume name.
+- Remove vol labeled test in askdir update_volume_info so that non-labeled
+ Volume in catalog can be marked in error.
+- Initialize job_start_wait cond variable after every new_jcr() otherwise
+ NetBSD gets error in library when trying to delete it without being inited.
+- Fix typo (9 instead of 0) return status in write_new_volume_label.
+- Fix mount.c to call routine that correctly marks a volume in error.
+- Eliminate printing INFO message in UpdateDB (cats) -- it generates
+ "false" error messages.
+- Eliminate some GTK error messages when running the Gnome2 console.
+- Apply Peter Eriksson's lib file order changes in linking for IRIX.
+- Add testimonials to the Web page
+- Add the bugs list to the Web page "lists".
+- Clarify the English in SuSE and Slackware when SD not running.
+- Applied the patches sent by Andreas Jellinghaus: build Gnome and
+ wx-console in client-only build if configured; add ./configure option
+ to permit setting of sbin modes -- default is 0745 as before; remove
+ cats library from Gnome console build; remove old version from Gnome
+ About box. Thanks Andreas.
+- Correct a typo in the FreeBSD SD autostart install.
+- New bacula.spec.in from Scott.
+- Use /usr/lib/sendmail instead of mail if no mail program is configured.
+ Submitted by Peter Eriksson. This *should* be more portable.
+
+
Changes for 1.34.4:
Major Changes/Features:
- Implement | and < in FD for new FileSet files.
#define LockRes() b_LockRes(__FILE__, __LINE__)
#define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
+#ifdef DEBUG_MEMSET
+#define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
+void b_memset(const char *file, int line, void *mem, int val, size_t num);
+#endif
+
/*
* The digit following Dmsg and Emsg indicates the number of substitutions in
}
#endif /* DEBUG_MUTEX */
+#ifdef DEBUG_MEMSET
+/* These routines are not normally turned on */
+#undef memset
+void b_memset(const char *file, int line, void *mem, int val, size_t num)
+{
+ /* Testing for 2000 byte zero at beginning of Volume block */
+ if (num > 1900 && num < 3000) {
+ Pmsg3(000, "Memset for %d bytes at %s:%d\n", (int)num, file, line);
+ }
+ memset(mem, val, num);
+}
+#endif
+
#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
static int del_pid_file_ok = FALSE;
#endif
*/
dcr->dev->state &= ~ST_LABEL; /* force reread of label */
Dmsg0(200, "calling read-vol-label\n");
- switch (read_dev_volume_label(jcr, dev, dcr->block)) {
+ switch (read_dev_volume_label(dcr, dcr->block)) {
case VOL_OK:
vol_ok = true;
break; /* got it */
}
out_block = out_jcr->dcr->block;
- read_records(in_jcr, in_dev, record_cb, mount_next_read_volume);
+ read_records(in_jcr->dcr, record_cb, mount_next_read_volume);
if (!write_block_to_device(out_jcr->dcr, out_block)) {
Pmsg0(000, _("Write of last block failed.\n"));
}
static bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
static DEVICE *dev = NULL;
+static DCR *dcr;
static BFILE bfd;
static JCR *jcr;
static FF_PKT my_ff;
if (!dev) {
exit(1);
}
+ dcr = jcr->dcr;
/* Make sure where directory exists and that it is a directory */
if (stat(where, &statp) < 0) {
compress_buf = get_memory(compress_buf_size);
- read_records(jcr, dev, record_cb, mount_next_read_volume);
+ read_records(dcr, record_cb, mount_next_read_volume);
/* If output file is still open, it was the last one in the
* archive since we just hit an end of file, so close the file.
*/
block->bufp = block->buf + bhl;
if (strncmp(Id, BLKHDR1_ID, BLKHDR_ID_LENGTH) != 0) {
dev->dev_errno = EIO;
- Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Wanted ID: %s, got %s. Buffer discarded.\n"),
+ Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"),
dev->file, dev->block_num, BLKHDR1_ID, Id);
if (block->read_errors == 0 || verbose >= 2) {
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
}
block->read_errors++;
- if (!forge_on) {
- return false;
- }
+ return false;
}
} else if (Id[3] == '2') {
unser_uint32(block->VolSessionId);
block->bufp = block->buf + bhl;
if (strncmp(Id, BLKHDR2_ID, BLKHDR_ID_LENGTH) != 0) {
dev->dev_errno = EIO;
- Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Wanted ID: %s, got %s. Buffer discarded.\n"),
+ Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"),
dev->file, dev->block_num, BLKHDR2_ID, Id);
if (block->read_errors == 0 || verbose >= 2) {
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
}
block->read_errors++;
- if (!forge_on) {
- return false;
- }
+ return false;
}
} else {
dev->dev_errno = EIO;
- Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Wanted ID: %s, got %s. Buffer discarded.\n"),
+ Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"),
dev->file, dev->block_num, BLKHDR2_ID, Id);
if (block->read_errors == 0 || verbose >= 2) {
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
}
block->read_errors++;
- if (!forge_on) {
- return false;
- }
unser_uint32(block->VolSessionId);
unser_uint32(block->VolSessionTime);
- bhl = BLKHDR2_LENGTH;
- block->BlockVer = 2;
- block->bufp = block->buf + bhl;
+ return false;
}
/* Sanity check */
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
}
block->read_errors++;
- if (!forge_on) {
- return false;
- }
+ return false;
}
Dmsg1(190, "unser_block_header block_len=%d\n", block_len);
dev->VolCatInfo.VolCatWrites++;
Dmsg1(200, "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) {
+ Jmsg0(jcr, M_ABORT, 0, "Write block header zeroed.\n");
+ }
+#endif
+
stat = write(dev->fd, block->buf, (size_t)wlen);
+
+#ifdef DEBUG_BLOCK_ZEROING
+ if (bp[0] == 0 && bp[1] == 0 && bp[2] == 0 && block->buf[12] == 0) {
+ Jmsg0(jcr, M_ABORT, 0, "Write block header zeroed.\n");
+ }
+#endif
+
if (stat != (ssize_t)wlen) {
/* We should check for errno == ENOSPC, BUT many
* devices simply report EIO when the volume is full.
* then re-read it and verify that the block number is
* correct.
*/
- if (dev->state & ST_TAPE && dev_cap(dev, CAP_BSR)) {
+ if ((dev->state & ST_TAPE) && dev_cap(dev, CAP_BSR)) {
/* Now back up over what we wrote and read the last block */
if (!bsf_dev(dev, 1)) {
if (ok) {
DEV_BLOCK *lblock = new_block(dev);
/* Note, this can destroy dev->errmsg */
- if (!read_block_from_dev(jcr, dev, lblock, NO_BLOCK_NUMBER_CHECK)) {
+ if (!read_block_from_dev(dcr, lblock, NO_BLOCK_NUMBER_CHECK)) {
Jmsg(jcr, M_ERROR, 0, _("Re-read last block at EOT failed. ERR=%s"), dev->errmsg);
} else {
if (lblock->BlockNumber+1 == block->BlockNumber) {
* Read block with locking
*
*/
-int read_block_from_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_block_numbers)
+bool read_block_from_device(DCR *dcr, DEV_BLOCK *block, bool check_block_numbers)
{
- int stat;
+ bool stat;
+ DEVICE *dev = dcr->dev;
Dmsg0(90, "Enter read_block_from_device\n");
lock_device(dev);
- stat = read_block_from_dev(jcr, dev, block, check_block_numbers);
+ stat = read_block_from_dev(dcr, block, check_block_numbers);
unlock_device(dev);
Dmsg0(90, "Leave read_block_from_device\n");
return stat;
* the block header. For a file, the block may be partially
* or completely in the current buffer.
*/
-int read_block_from_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_block_numbers)
+bool read_block_from_dev(DCR *dcr, DEV_BLOCK *block, bool check_block_numbers)
{
ssize_t stat;
int looping;
uint32_t BlockNumber;
int retry;
- DCR *dcr = jcr->dcr;
+ JCR *jcr = dcr->jcr;
+ DEVICE *dev = dcr->dev;
- if (!dcr) {
- Jmsg0(jcr, M_ABORT, 0, _("DCR is NULL!\n"));
- }
if (dev_state(dev, ST_EOT)) {
- return 0;
+ return false;
}
looping = 0;
Dmsg1(100, "Full read() in read_block_from_device() len=%d\n",
dev->dev_name);
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
block->read_len = 0;
- return 0;
+ return false;
}
retry = 0;
do {
+// uint32_t *bp = (uint32_t *)block->buf;
+// Dmsg3(000, "Read %p %u at %llu\n", block->buf, block->buf_len, lseek(dev->fd, 0, SEEK_CUR));
+
stat = read(dev->fd, block->buf, (size_t)block->buf_len);
+
+// Dmsg8(000, "stat=%d Csum=%u blen=%u bnum=%u %c%c%c%c\n",stat, bp[0],bp[1],bp[2],
+// block->buf[12],block->buf[13],block->buf[14],block->buf[15]);
+
if (retry == 1) {
dev->VolCatInfo.VolCatErrors++;
}
} while (stat == -1 && (errno == EINTR || errno == EIO) && retry++ < 11);
-// Dmsg1(100, "read stat = %d\n", stat);
if (stat < 0) {
Dmsg1(90, "Read device got: ERR=%s\n", strerror(errno));
clrerror_dev(dev, -1);
block->read_len = 0;
- Mmsg4(&dev->errmsg, _("Read error at file:block %d:%d on device %s. ERR=%s.\n"),
+ Mmsg4(&dev->errmsg, _("Read error at file:blk %u:%u on device %s. ERR=%s.\n"),
dev->file, dev->block_num, dev->dev_name, strerror(dev->dev_errno));
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
if (dev->state & ST_EOF) { /* EOF just seen? */
dev->state |= ST_EOT; /* yes, error => EOT */
}
- return 0;
+ return false;
}
Dmsg1(90, "Read device got %d bytes\n", stat);
if (stat == 0) { /* Got EOF ! */
dev->block_num = block->read_len = 0;
- Mmsg1(&dev->errmsg, _("Read zero bytes on device %s.\n"), dev->dev_name);
+ Mmsg3(&dev->errmsg, _("Read zero bytes at %u:%u on device %s.\n"),
+ dev->file, dev->block_num, dev->dev_name);
if (dev->state & ST_EOF) { /* EOF already read? */
dev->state |= ST_EOT; /* yes, 2 EOFs => EOT */
block->read_len = 0;
dev->file++; /* increment file */
dev->state |= ST_EOF; /* set EOF read */
block->read_len = 0;
- return 0; /* return eof */
+ return false; /* return eof */
}
/* Continue here for successful read */
block->read_len = stat; /* save length read */
if (block->read_len < BLKHDR2_LENGTH) {
dev->dev_errno = EIO;
- Mmsg2(&dev->errmsg, _("Volume data error! Very short block of %d bytes on device %s discarded.\n"),
- block->read_len, dev->dev_name);
+ Mmsg4(&dev->errmsg, _("Volume data error at %u:%u! Very short block of %d bytes on device %s discarded.\n"),
+ dev->file, dev->block_num, block->read_len, dev->dev_name);
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
dev->state |= ST_SHORT; /* set short block */
block->read_len = block->binbuf = 0;
- return 0; /* return error */
+ return false; /* return error */
}
BlockNumber = block->BlockNumber + 1;
if (!unser_block_header(jcr, dev, block)) {
- block->read_len = 0;
- return 0;
+ if (forge_on) {
+ dev->file_addr += block->read_len;
+ dev->file_size += block->read_len;
+ goto reread;
+ }
+ return false;
}
/*
if (!bsr_dev(dev, 1)) {
Jmsg(jcr, M_ERROR, 0, "%s", strerror_dev(dev));
block->read_len = 0;
- return 0;
+ return false;
}
} else {
- Dmsg0(100, "Seek to beginning of block for reread.\n");
+ Dmsg0(200, "Seek to beginning of block for reread.\n");
off_t pos = lseek(dev->fd, (off_t)0, SEEK_CUR); /* get curr pos */
pos -= block->read_len;
lseek(dev->fd, pos, SEEK_SET);
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
dev->state |= ST_SHORT; /* set short block */
block->read_len = block->binbuf = 0;
- return 0; /* return error */
+ return false; /* return error */
}
dev->state &= ~(ST_EOF|ST_SHORT); /* clear EOF and short block */
off_t pos = lseek(dev->fd, (off_t)0, SEEK_CUR); /* get curr pos */
pos -= (block->read_len - block->block_len);
lseek(dev->fd, pos, SEEK_SET);
- Dmsg2(100, "Did lseek blk_size=%d rdlen=%d\n", block->block_len,
+ Dmsg2(200, "Did lseek blk_size=%d rdlen=%d\n", block->block_len,
block->read_len);
dev->file_addr = pos;
+ dev->file_size = pos;
}
Dmsg2(200, "Exit read_block read_len=%d block_len=%d\n",
block->read_len, block->block_len);
block->block_read = true;
- return 1;
+ return true;
}
static bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec);
static DEVICE *dev;
+static DCR *dcr;
static bool dump_label = false;
static bool list_blocks = false;
static bool list_jobs = false;
if (!dev) {
exit(1);
}
+ dcr = jcr->dcr;
rec = new_record();
block = new_block(dev);
attr = new_attr();
rec = new_record();
}
for ( ;; ) {
- if (!read_block_from_device(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
+ if (!read_block_from_device(dcr, block, NO_BLOCK_NUMBER_CHECK)) {
Dmsg1(100, "!read_block(): ERR=%s\n", strerror_dev(dev));
if (dev->state & ST_EOT) {
if (!mount_next_read_volume(jcr, dev, block)) {
/* Read and discard Volume label */
DEV_RECORD *record;
record = new_record();
- read_block_from_device(jcr, dev, block, NO_BLOCK_NUMBER_CHECK);
+ read_block_from_device(dcr, block, NO_BLOCK_NUMBER_CHECK);
read_record_from_block(block, record);
get_session_record(dev, record, &sessrec);
free_record(record);
block->VolSessionId, block->VolSessionTime);
if (verbose == 1) {
read_record_from_block(block, rec);
- Pmsg7(-1, "Block: %u blen=%u First rec FI=%s SessId=%u SessTim=%u Strm=%s rlen=%d\n",
+ Pmsg9(-1, "File:blk=%u:%u blk_num=%u blen=%u First rec FI=%s SessId=%u SessTim=%u Strm=%s rlen=%d\n",
+ dev->file, dev->block_num,
block->BlockNumber, block->block_len,
FI_to_ascii(rec->FileIndex), rec->VolSessionId, rec->VolSessionTime,
stream_to_ascii(rec->Stream, rec->FileIndex), rec->data_len);
/* Do list job records */
static void do_jobs(char *infname)
{
- read_records(jcr, dev, jobs_cb, mount_next_read_volume);
+ read_records(dcr, jobs_cb, mount_next_read_volume);
}
/* Do an ls type listing of an archive */
dump_volume_label(dev);
return;
}
- read_records(jcr, dev, record_cb, mount_next_read_volume);
+ read_records(dcr, record_cb, mount_next_read_volume);
printf("%u files found.\n", num_files);
}
/* Detach bscan's jcr as we are not a real Job on the tape */
detach_jcr_from_device(dev, bjcr);
- read_records(bjcr, dev, record_cb, bscan_mount_next_read_volume);
+ read_records(bjcr->dcr, record_cb, bscan_mount_next_read_volume);
release_device(bjcr);
free_attr(attr);
static uint32_t btape_state_level = 2;
DEVICE *dev = NULL;
+DCR *dcr;
DEVRES *device = NULL;
if (!dev) {
exit(1);
}
+ dcr = jcr->dcr;
if (!open_the_device()) {
goto terminate;
}
DEV_BLOCK *block;
block = new_block(dev);
- stat = read_dev_volume_label(jcr, dev, block);
+ stat = read_dev_volume_label(dcr, block);
switch (stat) {
- case VOL_NO_LABEL:
- Pmsg0(0, "Volume has no label.\n");
- break;
- case VOL_OK:
- Pmsg0(0, "Volume label read correctly.\n");
- break;
- case VOL_IO_ERROR:
- Pmsg1(0, "I/O error on device: ERR=%s", strerror_dev(dev));
- break;
- case VOL_NAME_ERROR:
- Pmsg0(0, "Volume name error\n");
- break;
- case VOL_CREATE_ERROR:
- Pmsg1(0, "Error creating label. ERR=%s", strerror_dev(dev));
- break;
- case VOL_VERSION_ERROR:
- Pmsg0(0, "Volume version error.\n");
- break;
- case VOL_LABEL_ERROR:
- Pmsg0(0, "Bad Volume label type.\n");
- break;
- default:
- Pmsg0(0, "Unknown error.\n");
- break;
+ case VOL_NO_LABEL:
+ Pmsg0(0, "Volume has no label.\n");
+ break;
+ case VOL_OK:
+ Pmsg0(0, "Volume label read correctly.\n");
+ break;
+ case VOL_IO_ERROR:
+ Pmsg1(0, "I/O error on device: ERR=%s", strerror_dev(dev));
+ break;
+ case VOL_NAME_ERROR:
+ Pmsg0(0, "Volume name error\n");
+ break;
+ case VOL_CREATE_ERROR:
+ Pmsg1(0, "Error creating label. ERR=%s", strerror_dev(dev));
+ break;
+ case VOL_VERSION_ERROR:
+ Pmsg0(0, "Volume version error.\n");
+ break;
+ case VOL_LABEL_ERROR:
+ Pmsg0(0, "Bad Volume label type.\n");
+ break;
+ default:
+ Pmsg0(0, "Unknown error.\n");
+ break;
}
debug_level = 20;
goto bail_out;
}
Pmsg0(0, "Backspace record OK.\n");
- if (!read_block_from_dev(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
+ if (!read_block_from_dev(dcr, block, NO_BLOCK_NUMBER_CHECK)) {
Pmsg1(0, _("Read block failed! ERR=%s\n"), strerror(dev->dev_errno));
goto bail_out;
}
}
for (i=1; i<=2000; i++) {
read_again:
- if (!read_block_from_dev(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
+ if (!read_block_from_dev(dcr, block, NO_BLOCK_NUMBER_CHECK)) {
if (dev_state(dev, ST_EOF)) {
Pmsg0(-1, _("Got EOF on tape.\n"));
goto read_again;
goto bail_out;
}
read_again:
- if (!read_block_from_dev(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
+ if (!read_block_from_dev(dcr, block, NO_BLOCK_NUMBER_CHECK)) {
if (dev_state(dev, ST_EOF)) {
Pmsg0(-1, _("Got EOF on tape.\n"));
goto read_again;
update_pos_dev(dev);
tot_files = dev->file;
for (;;) {
- if (!read_block_from_device(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
+ if (!read_block_from_device(dcr, block, NO_BLOCK_NUMBER_CHECK)) {
Dmsg1(100, "!read_block(): ERR=%s\n", strerror_dev(dev));
if (dev->state & ST_EOT) {
if (blocks > 0) {
rewind_dev(dev); /* get to a known place on tape */
/* Read the first 1000 records */
Pmsg0(-1, _("Reading the first 1000 records.\n"));
- read_records(jcr, dev, quickie_cb, my_mount_next_read_volume);
+ read_records(dcr, quickie_cb, my_mount_next_read_volume);
Pmsg4(-1, _("Reposition from %u:%u to %u:%u\n"), dev->file, dev->block_num,
last_file, last_block_num);
if (!reposition_dev(dev, last_file, last_block_num)) {
Pmsg1(-1, "Reposition error. ERR=%s\n", strerror_dev(dev));
}
Pmsg1(-1, _("Reading block %u.\n"), last_block_num);
- if (!read_block_from_device(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
+ if (!read_block_from_device(dcr, block, NO_BLOCK_NUMBER_CHECK)) {
Pmsg1(-1, _("Error reading block: ERR=%s\n"), strerror_dev(dev));
goto bail_out;
}
goto bail_out;
}
Pmsg1(-1, _("Reading block %d.\n"), dev->block_num);
- if (!read_block_from_device(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
+ if (!read_block_from_device(dcr, block, NO_BLOCK_NUMBER_CHECK)) {
Pmsg1(-1, _("Error reading block: ERR=%s\n"), strerror_dev(dev));
goto bail_out;
}
goto bail_out;
}
Pmsg1(-1, _("Reading block %d.\n"), dev->block_num);
- if (!read_block_from_device(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
+ if (!read_block_from_device(dcr, block, NO_BLOCK_NUMBER_CHECK)) {
Pmsg1(-1, _("Error reading block: ERR=%s\n"), strerror_dev(dev));
goto bail_out;
}
}
/* See what we have for a Volume */
- switch (read_dev_volume_label(jcr, dev, block)) {
+ switch (read_dev_volume_label(jcr->dcr, block)) {
case VOL_NAME_ERROR:
case VOL_VERSION_ERROR:
case VOL_LABEL_ERROR:
jcr->VolumeName[0] = 0;
block = new_block(dev);
dev->state &= ~ST_LABEL; /* force read of label */
- switch (read_dev_volume_label(jcr, dev, block)) {
+ switch (read_dev_volume_label(jcr->dcr, block)) {
case VOL_OK:
bnet_fsend(dir, _("3001 Mounted Volume: %s\n"), dev->VolHdr.VolName);
stat = 1;
break;
}
block = new_block(dev);
- read_dev_volume_label(jcr, dev, block);
+ read_dev_volume_label(jcr->dcr, block);
free_block(block);
if (dev->dev_blocked == BST_UNMOUNTED) {
/* We blocked the device, so unblock it */
}
dev->state &= ~ST_LABEL; /* force read of label */
- switch (read_dev_volume_label(jcr, dev, block)) {
+ switch (read_dev_volume_label(jcr->dcr, block)) {
case VOL_OK:
/* DO NOT add quotes around the Volume name. It is scanned in the DIR */
bnet_fsend(dir, _("3001 Volume=%s Slot=%d\n"), dev->VolHdr.VolName, Slot);
* VOL_LABEL_ERROR
* VOL_NO_MEDIA
*/
-int read_dev_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
+int read_dev_volume_label(DCR *dcr, DEV_BLOCK *block)
{
+ JCR *jcr = dcr->jcr;
+ DEVICE *dev = dcr->dev;
char *VolName = jcr->VolumeName;
DEV_RECORD *record;
- int ok = 0;
+ bool ok = false;
Dmsg3(100, "Enter read_volume_label device=%s vol=%s dev_Vol=%s\n",
dev_name(dev), VolName, dev->VolHdr.VolName);
/* Read the Volume label block */
record = new_record();
Dmsg0(90, "Big if statement in read_volume_label\n");
- if (!read_block_from_dev(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) {
+ if (!read_block_from_dev(dcr, block, NO_BLOCK_NUMBER_CHECK)) {
Mmsg(&jcr->errmsg, _("Requested Volume \"%s\" on %s is not a Bacula "
"labeled Volume, because: ERR=%s"), NPRT(VolName), dev_name(dev),
strerror_dev(dev));
strcmp(dev->VolHdr.Id, OldBaculaId) != 0) {
Mmsg(&jcr->errmsg, _("Volume Header Id bad: %s\n"), dev->VolHdr.Id);
} else {
- ok = 1;
+ ok = true;
}
if (!ok) {
free_record(record);
create_volume_label(dev, jcr->VolumeName, "Default");
dev->VolHdr.LabelType = PRE_LABEL;
} else {
- vol_label_status = read_dev_volume_label(jcr, dev, block);
+ vol_label_status = read_dev_volume_label(jcr->dcr, block);
}
Dmsg2(100, "dirVol=%s dirStat=%s\n", jcr->VolumeName,
#define CHECK_BLOCK_NUMBERS true
#define NO_BLOCK_NUMBER_CHECK false
-int read_block_from_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_block_numbers);
-int read_block_from_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_block_numbers);
+bool read_block_from_device(DCR *dcr, DEV_BLOCK *block, bool check_block_numbers);
+bool read_block_from_dev(DCR *dcr, DEV_BLOCK *block, bool check_block_numbers);
/* From butil.c -- utilities for SD tool programs */
void print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
void handle_filed_connection(BSOCK *fd, char *job_name);
/* From label.c */
-int read_dev_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+int read_dev_volume_label(DCR *dcr, DEV_BLOCK *block);
void create_session_label(JCR *jcr, DEV_RECORD *rec, int label);
void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName);
bool write_new_volume_label_to_dev(JCR *jcr, DEVICE *dev, const char *VolName, const char *PoolName);
void free_record(DEV_RECORD *rec);
/* From read_record.c */
-bool read_records(JCR *jcr, DEVICE *dev,
+bool read_records(DCR *dcr,
bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec),
bool mount_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block));
{
BSOCK *fd = jcr->file_bsock;
bool ok = true;
- DEVICE *dev;
+ DCR *dcr;
Dmsg0(20, "Start read data.\n");
/*
* Ready device for reading, and read records
*/
- if (!acquire_device_for_read(jcr)) {
+ if (!(dcr=acquire_device_for_read(jcr))) {
free_vol_list(jcr);
return false;
}
- dev = jcr->dcr->dev;
- Dmsg1(20, "Begin read device=%s\n", dev_name(dev));
-
/* Tell File daemon we will send data */
bnet_fsend(fd, OK_data);
- ok = read_records(jcr, dev, record_cb, mount_next_read_volume);
+ ok = read_records(dcr, record_cb, mount_next_read_volume);
/* Send end of data to FD */
bnet_sig(fd, BNET_EOD);
static char *rec_state_to_str(DEV_RECORD *rec);
#endif
-bool read_records(JCR *jcr, DEVICE *dev,
+bool read_records(DCR *dcr,
bool record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec),
bool mount_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block))
{
+ JCR *jcr = dcr->jcr;
+ DEVICE *dev = dcr->dev;
DEV_BLOCK *block;
DEV_RECORD *rec = NULL;
uint32_t record;
ok = false;
break;
}
- if (!read_block_from_device(jcr, dev, block, CHECK_BLOCK_NUMBERS)) {
+ if (!read_block_from_device(dcr, block, CHECK_BLOCK_NUMBERS)) {
if (dev_state(dev, ST_EOT)) {
DEV_RECORD *trec = new_record();
* and pass it off to the callback routine, then continue
* most likely reading the previous record.
*/
- read_block_from_device(jcr, dev, block, NO_BLOCK_NUMBER_CHECK);
+ read_block_from_device(dcr, block, NO_BLOCK_NUMBER_CHECK);
read_record_from_block(block, trec);
handle_session_record(dev, trec, &sessrec);
ok = record_cb(jcr, dev, block, trec);
}
jcr->device = device;
dcr = new_dcr(jcr, device->dev);
- switch (read_dev_volume_label(jcr, device->dev, dcr->block)) {
+ switch (read_dev_volume_label(dcr, dcr->block)) {
case VOL_OK:
break;
default:
#undef VERSION
#define VERSION "1.35.0"
#define VSTRING "1"
-#define BDATE "07 July 2004"
-#define LSMDATE "07Jul04"
+#define BDATE "08 July 2004"
+#define LSMDATE "08Jul04"
/* Debug flags */
#undef DEBUG
#define SMCHECK
#define TRACE_FILE 1
-// #define TRACE_JCR_CHAIN 1
-// #define TRACE_RES 1
+
+/* Debug flags not normally turned on */
+
+/* #define TRACE_JCR_CHAIN 1 */
+/* #define TRACE_RES 1 */
+/* #define DEBUG_MEMSET 1 */
+#define DEBUG_BLOCK_ZEROING 1
/* #define FULL_DEBUG 1 */ /* normally on for testing only */