/* External subroutines */
extern void free_config_resources();
+extern char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd);
/* Exported variables */
int quit = 0;
char buf[100000];
int bsize = TAPE_BSIZE;
char VolName[MAX_NAME_LENGTH];
+bool forge_on = false;
/*
* If you change the format of the state file,
static void rawfill_cmd();
static void bfill_cmd();
static bool open_the_device();
-static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd);
static void autochangercmd();
static void do_unfill();
my_name_is(margc, margv, "btape");
init_msg(NULL, NULL);
- while ((ch = getopt(margc, margv, "b:c:d:sv?")) != -1) {
+ while ((ch = getopt(margc, margv, "b:c:d:psv?")) != -1) {
switch (ch) {
case 'b': /* bootstrap file */
bsr = parse_bsr(NULL, optarg);
}
break;
+ case 'p':
+ forge_on = true;
+ break;
+
case 's':
- signals = FALSE;
+ signals = false;
break;
case 'v':
static void terminate_btape(int stat)
{
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
if (configfile) {
free(configfile);
}
term_msg();
close_memory_pool(); /* free memory in pool */
- sm_dump(False);
+ sm_dump(false);
exit(stat);
}
lock_device(dev);
if (!(dev->state & ST_OPENED)) {
Dmsg1(200, "Opening device %s\n", jcr->VolumeName);
- if (open_dev(dev, jcr->VolumeName, READ_WRITE) < 0) {
+ if (open_dev(dev, jcr->VolumeName, OPEN_READ_WRITE) < 0) {
Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
unlock_device(dev);
free_block(block);
return false;
}
}
- Dmsg1(000, "open_dev %s OK\n", dev_name(dev));
+ Pmsg1(000, "open_dev %s OK\n", dev_name(dev));
unlock_device(dev);
free_block(block);
return true;
return;
}
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
block = new_block(dev);
rec = new_record();
rec->data = check_pool_memory_size(rec->data, i);
memset(rec->data, i & 0xFF, i);
rec->data_len = i;
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
if (write_record_to_block(block, rec)) {
empty_block(block);
blkno++;
} else {
break;
}
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
}
free_record(rec);
free_block(block);
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
}
/*
Pmsg0(0, _("Error writing record to block.\n"));
goto bail_out;
}
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
Pmsg0(0, _("Error writing block to device.\n"));
goto bail_out;
} else {
Pmsg0(0, _("Error writing record to block.\n"));
goto bail_out;
}
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
Pmsg0(0, _("Error writing block to device.\n"));
goto bail_out;
} else {
Pmsg0(0, _("Error writing record to block.\n"));
goto bail_out;
}
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
Pmsg0(0, _("Error writing block to device.\n"));
goto bail_out;
} else {
Pmsg0(0, _("Error writing record to block.\n"));
goto bail_out;
}
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
Pmsg0(0, _("Error writing block to device.\n"));
goto bail_out;
}
Pmsg0(0, _("Error writing record to block.\n"));
goto bail_out;
}
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
Pmsg0(0, _("Error writing block to device.\n"));
goto bail_out;
}
Pmsg0(0, _("Error writing record to block.\n"));
goto bail_out;
}
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
Pmsg0(0, _("Error writing block to device.\n"));
goto bail_out;
}
Pmsg0(0, _("Error writing record to block.\n"));
goto bail_out;
}
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
Pmsg0(0, _("Error writing block to device.\n"));
goto bail_out;
}
{
POOLMEM *results, *changer;
int slot, status, loaded;
- int timeout = 120;
+ int timeout = jcr->device->max_changer_wait;
int sleep_time = 0;
+ Dmsg1(100, "Max changer wait = %d sec\n", timeout);
if (!dev_cap(dev, CAP_AUTOCHANGER)) {
return 1;
}
return 1;
}
- Pmsg0(-1, "\nTo test the autochanger you must have a blank tape in Slot 1.\n"
- "I'm going to write on it.\n");
+ Pmsg0(-1, "\nAh, I see you have an autochanger configured.\n"
+ "To test the autochanger you must have a blank tape\n"
+ " that I can write on in Slot 1.\n");
if (!get_cmd("\nDo you wish to continue with the Autochanger test? (y/n): ")) {
return 0;
}
if (status == 0) {
loaded = atoi(results);
} else {
- Pmsg1(-1, _("3991 Bad autochanger \"load slot\" status=%d.\n"), status);
- loaded = -1; /* force unload */
+ Pmsg1(-1, _("3991 Bad autochanger command: %s\n"), changer);
+ Pmsg2(-1, _("3991 status=%d result=%s\n"), status, results);
goto bail_out;
}
if (loaded) {
Pmsg1(-1, "Slot %d loaded. I am going to unload it.\n", loaded);
} else {
- Pmsg0(-1, "Nothing loaded into the drive. OK.\n");
+ Pmsg0(-1, "Nothing loaded in the drive. OK.\n");
}
Dmsg1(100, "Results from loaded query=%s\n", results);
if (loaded) {
+ jcr->VolCatInfo.Slot = loaded;
offline_or_rewind_dev(dev);
/* We are going to load a new tape, so close the device */
force_close_dev(dev);
- Pmsg0(-1, _("3302 Issuing autochanger \"unload\" command.\n"));
+ Pmsg2(-1, _("3302 Issuing autochanger \"unload %d %d\" command.\n"),
+ loaded, dev->drive_index);
changer = edit_device_codes(jcr, changer,
jcr->device->changer_command, "unload");
- status = run_program(changer, timeout, NULL);
+ status = run_program(changer, timeout, results);
Pmsg2(-1, "unload status=%s %d\n", status==0?"OK":"Bad", status);
+ if (status != 0) {
+ Pmsg1(-1, _("3992 Bad autochanger command: %s\n"), changer);
+ Pmsg2(-1, _("3992 status=%d result=%s\n"), status, results);
+ }
}
/*
* Load the Slot 1
*/
- Pmsg1(-1, _("3303 Issuing autochanger \"load slot %d\" command.\n"), slot);
+
+ slot = 1;
+ jcr->VolCatInfo.Slot = slot;
+ Pmsg2(-1, _("3303 Issuing autochanger \"load slot %d %d\" command.\n"),
+ slot, dev->drive_index);
changer = edit_device_codes(jcr, changer, jcr->device->changer_command, "load");
- Dmsg1(200, "Changer=%s\n", changer);
- status = run_program(changer, timeout, NULL);
+ Dmsg1(100, "Changer=%s\n", changer);
+ force_close_dev(dev);
+ status = run_program(changer, timeout, results);
if (status == 0) {
- Pmsg1(-1, _("3304 Autochanger \"load slot %d\" status is OK.\n"), slot);
+ Pmsg2(-1, _("3303 Autochanger \"load slot %d %d\" status is OK.\n"),
+ slot, dev->drive_index);
} else {
- Pmsg1(-1, _("3992 Bad autochanger \"load slot\" status=%d.\n"), status);
+ Pmsg1(-1, _("3993 Bad autochanger command: %s\n"), changer);
+ Pmsg2(-1, _("3993 status=%d result=%s\n"), status, results);
goto bail_out;
}
if (dev->file != 5) {
goto bail_out;
}
-
+ Pmsg0(-1, _("\n=== End Forward space files test ===\n\n"));
return 1;
bail_out:
DEV_RECORD *rec;
int i;
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
block = new_block(dev);
rec = new_record();
dump_block(block, "test");
rec->data = check_pool_memory_size(rec->data, i);
memset(rec->data, i & 0xFF, i);
rec->data_len = i;
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
if (!write_record_to_block(block, rec)) {
Pmsg0(0, _("Error writing record to block.\n"));
goto bail_out;
}
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
Pmsg0(0, _("Error writing block to device.\n"));
goto bail_out;
} else {
Pmsg0(0, _("Wrote block to device.\n"));
bail_out:
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
free_record(rec);
free_block(block);
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
}
/*
/* Use fixed block size to simplify read back */
min_block_size = dev->min_block_size;
dev->min_block_size = dev->max_block_size;
- block = new_block(dev);
/*
* Acquire output device for writing. Note, after acquiring a
* subroutine.
*/
Dmsg0(100, "just before acquire_device\n");
- if (!(dev=acquire_device_for_append(jcr, dev, block))) {
+ if (!acquire_device_for_append(jcr)) {
set_jcr_job_status(jcr, JS_ErrorTerminated);
- free_block(block);
return;
}
+ block = jcr->dcr->block;
Dmsg0(100, "Just after acquire_device_for_append\n");
/*
/*
* Generate data as if from File daemon, write to device
*/
- jcr->VolFirstIndex = 0;
+ jcr->dcr->VolFirstIndex = 0;
time(&jcr->run_time); /* start counting time for rates */
if (simple) {
Pmsg0(-1, "Begin writing Bacula records to tape ...\n");
}
if (!write_session_label(jcr, block, EOS_LABEL)) {
Pmsg1(000, _("Error writting end session label. ERR=%s\n"), strerror_dev(dev));
- ok = FALSE;
+ ok = false;
}
/* Write out final block of this session */
- if (!write_block_to_device(jcr, dev, block)) {
- Pmsg0(-1, _("Set ok=FALSE after write_block_to_device.\n"));
- ok = FALSE;
+ if (!write_block_to_device(jcr->dcr, block)) {
+ Pmsg0(-1, _("Set ok=false after write_block_to_device.\n"));
+ ok = false;
}
Pmsg0(-1, _("Wrote End Of Session label.\n"));
}
/* Release the device */
- if (!release_device(jcr, dev)) {
+ if (!release_device(jcr)) {
Pmsg0(-1, _("Error in release_device\n"));
- ok = FALSE;
+ ok = false;
}
do_unfill();
dev->min_block_size = min_block_size;
- free_block(block);
free_memory(rec.data);
}
create_vol_list(jcr);
close_dev(dev);
dev->state &= ~ST_READ;
- if (!acquire_device_for_read(jcr, dev, block)) {
+ if (!acquire_device_for_read(jcr)) {
Pmsg1(-1, "%s", dev->errmsg);
goto bail_out;
}
}
dev->state &= ~ST_READ;
- if (!acquire_device_for_read(jcr, dev, block)) {
+ if (!acquire_device_for_read(jcr)) {
Pmsg1(-1, "%s", dev->errmsg);
goto bail_out;
}
/* Copy block */
this_file = dev->file;
this_block_num = dev->block_num;
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
Pmsg3(000, "Last block at: %u:%u this_dev_block_num=%d\n",
last_file, last_block_num, this_block_num);
if (vol_num == 1) {
/* Full test in progress */
if (!fixup_device_block_write_error(jcr, dev, block)) {
Pmsg1(000, _("Cannot fixup device error. %s\n"), strerror_dev(dev));
- ok = FALSE;
+ ok = false;
unlock_device(dev);
return 0;
}
count = 1000;
}
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
block = new_block(dev);
rec = new_record();
Pmsg0(0, _("Error writing record to block.\n"));
goto bail_out;
}
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
Pmsg0(0, _("Error writing block to device.\n"));
goto bail_out;
}
scan_blocks();
bail_out:
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
free_record(rec);
free_block(block);
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
}
*p = block_num;
block->binbuf = block->buf_len;
block->bufp = block->buf + block->binbuf;
- if (!write_block_to_dev(jcr, dev, block)) {
+ if (!write_block_to_dev(jcr->dcr, block)) {
break;
}
if ((block_num++ % 100) == 0) {
bool found;
while (get_cmd("*")) {
- sm_check(__FILE__, __LINE__, False);
+ sm_check(__FILE__, __LINE__, false);
found = false;
parse_args(cmd, &args, &argc, argk, argv, MAX_CMD_ARGS);
for (i=0; i<comsize; i++) /* search for command */
" -b <file> specify bootstrap file\n"
" -c <file> set configuration file to file\n"
" -d <nn> set debug level to nn\n"
+" -p proceed inspite of I/O errors\n"
" -s turn off signals\n"
" -v be verbose\n"
" -? print this message.\n"
int dir_create_jobmedia_record(JCR *jcr)
{
- jcr->WroteVol = false;
+ jcr->dcr->WroteVol = false;
return 1;
}
create_vol_list(jcr);
close_dev(dev);
dev->state &= ~ST_READ;
- if (!acquire_device_for_read(jcr, dev, block)) {
+ if (!acquire_device_for_read(jcr)) {
Pmsg2(0, "Cannot open Dev=%s, Vol=%s\n", dev_name(dev), jcr->VolumeName);
return 0;
}
static void set_volume_name(char *VolName, int volnum)
{
+ DCR *dcr = jcr->dcr;
VolumeName = VolName;
vol_num = volnum;
pm_strcpy(&jcr->VolumeName, VolName);
bstrncpy(dev->VolCatInfo.VolCatName, VolName, sizeof(dev->VolCatInfo.VolCatName));
bstrncpy(jcr->VolCatInfo.VolCatName, VolName, sizeof(jcr->VolCatInfo.VolCatName));
+ bstrncpy(dcr->VolCatInfo.VolCatName, VolName, sizeof(dcr->VolCatInfo.VolCatName));
+ bstrncpy(dcr->VolumeName, VolName, sizeof(dcr->VolumeName));
jcr->VolCatInfo.Slot = volnum;
+ dcr->VolCatInfo.Slot = volnum;
}
+#ifdef xxx
/*
* Edit codes into ChangerCommand
* %% = %
}
return omsg;
}
+#endif
#ifdef xxxx_needed
/*