/*
- Bacula® - The Network Backup Solution
+ Bacula(R) - The Network Backup Solution
+ Copyright (C) 2000-2015 Kern Sibbald
Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
- 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.
*/
/*
*
#include "vtape_dev.h"
#endif
-/* Dummy functions */
-int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
extern bool parse_sd_config(CONFIG *config, const char *configfile, int exit_code);
/* External subroutines */
static JCR *jcr = NULL;
-
static void usage();
static void terminate_btape(int sig);
int get_cmd(const char *prompt);
dev->rLock(false);
Dmsg1(200, "Opening device %s\n", dcr->VolumeName);
if (!dev->open(dcr, OPEN_READ_WRITE)) {
- Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
+ Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->print_errmsg());
ok = false;
goto bail_out;
}
Pmsg1(0, _("I/O error on device: ERR=%s"), dev->bstrerror());
break;
case VOL_TYPE_ERROR:
- Pmsg1(0, _("Volume type error: ERR=%s\n"), dev->errmsg);
+ Pmsg1(0, _("Volume type error: ERR=%s\n"), dev->print_errmsg());
break;
case VOL_NAME_ERROR:
Pmsg0(0, _("Volume name error\n"));
}
Pmsg0(0, _("Backspace record OK.\n"));
if (!dcr->read_block_from_dev(NO_BLOCK_NUMBER_CHECK)) {
- berrno be;
- Pmsg1(0, _("Read block failed! ERR=%s\n"), be.bstrerror(dev->dev_errno));
+ Pmsg1(0, _("Read block failed! ERR=%s\n"), dev->print_errmsg());
goto bail_out;
}
memset(rec->data, 0, rec->data_len);
/*
* Set big max_file_size so that write_record_to_block
* doesn't insert any additional EOF marks
+ * Do calculation in 64 bits to avoid overflow.
*/
- dev->max_file_size = 2 * num_recs * dev->max_block_size;
+ dev->max_file_size = (uint64_t)2 * (uint64_t)num_recs * (uint64_t)dev->max_block_size;
Pmsg2(-1, _("\n=== Write, rewind, and re-read test ===\n\n"
"I'm going to write %d records and an EOF\n"
"then write %d records and an EOF, then rewind,\n"
for (i=1; i<=2*num_recs; i++) {
read_again:
if (!dcr->read_block_from_dev(NO_BLOCK_NUMBER_CHECK)) {
- berrno be;
if (dev_state(dev, ST_EOF)) {
Pmsg0(-1, _("Got EOF on tape.\n"));
if (i == num_recs+1) {
goto read_again;
}
}
- Pmsg2(0, _("Read block %d failed! ERR=%s\n"), i, be.bstrerror(dev->dev_errno));
+ Pmsg2(0, _("Read block %d failed! ERR=%s\n"), i, dev->print_errmsg());
goto bail_out;
}
memset(rec->data, 0, rec->data_len);
}
read_again:
if (!dcr->read_block_from_dev(NO_BLOCK_NUMBER_CHECK)) {
- berrno be;
if (dev_state(dev, ST_EOF)) {
Pmsg0(-1, _("Got EOF on tape.\n"));
if (!got_eof) {
}
}
Pmsg4(0, _("Read block %d failed! file=%d blk=%d. ERR=%s\n\n"),
- recno, file, blk, be.bstrerror(dev->dev_errno));
+ recno, file, blk, dev->print_errmsg());
Pmsg0(0, _("This may be because the tape drive block size is not\n"
" set to variable blocking as normally used by Bacula.\n"
" Please see the Tape Testing chapter in the manual and \n"
printf(_("Short block read.\n"));
continue;
}
- printf(_("Error reading block. ERR=%s\n"), dev->bstrerror());
+ printf(_("Error reading block. ERR=%s\n"), dev->print_errmsg());
goto bail_out;
}
if (block->block_len != block_size) {
dev->close();
dev->num_writers = 0;
+ dcr->clear_writing();
if (!acquire_device_for_read(dcr)) {
- Pmsg1(-1, "%s", dev->errmsg);
+ Pmsg1(-1, "%s", dev->print_errmsg());
goto bail_out;
}
/*
}
Pmsg1(-1, _("Reading block %u.\n"), last_block_num);
if (!dcr->read_block_from_device(NO_BLOCK_NUMBER_CHECK)) {
- Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->bstrerror());
+ Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->print_errmsg());
goto bail_out;
}
if (compare_blocks(last_block, block)) {
}
dev->clear_read();
+ dcr->clear_writing();
if (!acquire_device_for_read(dcr)) {
- Pmsg1(-1, "%s", dev->errmsg);
+ Pmsg1(-1, "%s", dev->print_errmsg());
goto bail_out;
}
}
Pmsg1(-1, _("Reading block %d.\n"), dev->block_num);
if (!dcr->read_block_from_device(NO_BLOCK_NUMBER_CHECK)) {
- Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->bstrerror());
+ Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->print_errmsg());
goto bail_out;
}
if (compare_blocks(first_block, block)) {
}
Pmsg1(-1, _("Reading block %d.\n"), dev->block_num);
if (!dcr->read_block_from_device(NO_BLOCK_NUMBER_CHECK)) {
- Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->bstrerror());
+ Pmsg1(-1, _("Error reading block: ERR=%s\n"), dev->print_errmsg());
goto bail_out;
}
if (compare_blocks(last_block, block)) {
{
fprintf(stderr, _(
PROG_COPYRIGHT
-"\nVersion: %s (%s)\n\n"
+"\n%sVersion: %s (%s)\n\n"
"Usage: btape <options> <device_name>\n"
" -b <file> specify bootstrap file\n"
" -c <file> set configuration file to file\n"
" -s turn off signals\n"
" -v be verbose\n"
" -? print this message.\n"
-"\n"), 2000, VERSION, BDATE);
+"\n"), 2000, "", VERSION, BDATE);
}
/* Dummies to replace askdir.c */
bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
bool dir_send_job_status(JCR *jcr) {return 1;}
+bool flush_jobmedia_queue(JCR *jcr) { return true; }
bool dir_update_volume_info(DCR *dcr, bool relabel, bool update_LastWritten)
{
if (dcr->VolumeName[0] == 0) {
return dir_ask_sysop_to_create_appendable_volume(dcr);
}
- Pmsg1(-1, "%s", dev->errmsg); /* print reason */
+ Pmsg1(-1, "%s", dev->print_errmsg()); /* print reason */
if (dcr->VolumeName[0] == 0 || strcmp(dcr->VolumeName, "TestVolume2") == 0) {
fprintf(stderr, _("Mount second Volume on device %s and press return when ready: "),
dev->print_name());