/* 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);
}
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);
}
/*
{
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;
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);
}
/*
}
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->dcr, block)) {
- Pmsg0(-1, _("Set ok=FALSE after write_block_to_device.\n"));
- ok = FALSE;
+ 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)) {
Pmsg0(-1, _("Error in release_device\n"));
- ok = FALSE;
+ ok = false;
}
/* 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();
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);
}
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"
dcr->VolCatInfo.Slot = volnum;
}
+#ifdef xxx
/*
* Edit codes into ChangerCommand
* %% = %
}
return omsg;
}
+#endif
#ifdef xxxx_needed
/*